mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-10 16:42:45 +00:00
[cpp qt5 server] Improve qt5 server naming (#655)
* Adapted according to reviews * Add changed files * Update beta tag to the naming
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
|
||||
project(cpp-qt5-qhttpengine-server)
|
||||
|
||||
include(ExternalProject)
|
||||
|
||||
set(EXTERNAL_INSTALL_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/external)
|
||||
|
||||
ExternalProject_Add(QHTTPENGINE
|
||||
GIT_REPOSITORY https://github.com/etherealjoy/qhttpengine.git
|
||||
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EXTERNAL_INSTALL_LOCATION}
|
||||
)
|
||||
|
||||
include_directories(${EXTERNAL_INSTALL_LOCATION}/include)
|
||||
link_directories(${EXTERNAL_INSTALL_LOCATION}/lib)
|
||||
|
||||
add_subdirectory(src)
|
||||
@@ -0,0 +1,29 @@
|
||||
FROM alpine:latest AS build
|
||||
|
||||
RUN apk add --update \
|
||||
cmake \
|
||||
alpine-sdk \
|
||||
openssl \
|
||||
qt5-qtbase-dev \
|
||||
qt5-qttools-dev
|
||||
|
||||
WORKDIR /usr/server
|
||||
ADD ./src ./src
|
||||
ADD ./CMakeLists.txt ./
|
||||
RUN mkdir -p ./build
|
||||
WORKDIR /usr/server/build
|
||||
RUN cmake -DNODEBUG:STRING="ON" ..
|
||||
RUN make
|
||||
|
||||
FROM alpine:latest AS runtime
|
||||
RUN apk add --update \
|
||||
libgcc \
|
||||
libstdc++ \
|
||||
qt5-qtbase \
|
||||
openssl
|
||||
|
||||
WORKDIR /usr/server
|
||||
COPY --from=build /usr/server/build/src/cpp-qt5-server ./build/src/
|
||||
COPY --from=build /usr/server/external/ ./external
|
||||
EXPOSE 8080/tcp
|
||||
ENTRYPOINT ["/usr/server/build/src/cpp-qt5-server"]
|
||||
@@ -0,0 +1,11 @@
|
||||
QHttpEngine
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Nathan Osman
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -0,0 +1,29 @@
|
||||
BUILD_DIR=build
|
||||
DIST_DIR=.
|
||||
ECHO=echo
|
||||
CMAKE=cmake
|
||||
RM=rm
|
||||
MKDIR_P = mkdir -p
|
||||
CD=cd
|
||||
|
||||
default: all
|
||||
|
||||
checkdir:
|
||||
ifeq "$(wildcard $(BUILD_DIR) )" ""
|
||||
@$(ECHO) "Build Directory not existing, creating..."
|
||||
@${MKDIR_P} ${BUILD_DIR}
|
||||
endif
|
||||
|
||||
cmakestep: checkdir
|
||||
$(CD) $(BUILD_DIR) && $(CMAKE) ../${DIST_DIR}
|
||||
|
||||
all: cmakestep
|
||||
$(MAKE) -j8 -C $(BUILD_DIR) all
|
||||
|
||||
install: all
|
||||
$(MAKE) -C $(BUILD_DIR) install
|
||||
|
||||
clean:
|
||||
$(RM) -rf $(BUILD_DIR)/*
|
||||
|
||||
.PHONY: clean install
|
||||
@@ -0,0 +1,89 @@
|
||||
## Qt5 HTTP Server based on the Qhttpengine
|
||||
This server was generated by the [openapi-generator]
|
||||
(https://openapi-generator.tech) project.
|
||||
By using the [OpenAPI-Spec](https://github.com/OAI/OpenAPI-Specification) from a remote server, you can easily generate a server stub.
|
||||
-
|
||||
|
||||
To see how to make this your own, look here:
|
||||
|
||||
[README]((https://openapi-generator.tech))
|
||||
|
||||
- API version: 1.0.0
|
||||
|
||||
## QHTTPEngine
|
||||
|
||||
[](https://travis-ci.org/nitroshare/qhttpengine)
|
||||
[](http://opensource.org/licenses/MIT)
|
||||
|
||||
Simple set of classes for developing HTTP server applications in Qt.
|
||||
|
||||
### Documentation
|
||||
|
||||
To learn more about building and using the library, please visit this page:
|
||||
|
||||
https://ci.quickmediasolutions.com/job/qhttpengine-documentation/doxygen/
|
||||
|
||||
|
||||
### Viewing the code
|
||||
You can view the code using an editor like Microsoft Visual Studio Code or you can
|
||||
Use QtCreator and browse for the root CMakeLists.txt and load it as a project
|
||||
|
||||
### Build with make
|
||||
Install the tools [Linux/Debian]
|
||||
```
|
||||
sudo apt install cmake build-essential libssl-dev qtbase5-dev qtbase5-dev-tools git curl
|
||||
```
|
||||
|
||||
To build, go to the `server` folder
|
||||
```
|
||||
make
|
||||
```
|
||||
|
||||
To run the server
|
||||
```
|
||||
./build/src/cpp-qt5-server &
|
||||
```
|
||||
#### Invoke an API
|
||||
```
|
||||
curl -X GET http://localhost:8080/v2/store/inventory
|
||||
curl -X POST http://localhost:8080/v2/store/order -H "Content-Type: application/json" -d "{ \"id\": 22, \"petId\": 1541, \"quantity\": 5, \"shipDate\": \"2018-06-16T18:31:43.870Z\", \"status\": \"placed\", \"complete\": \"true\" }"
|
||||
curl -X GET http://localhost:8080/v2/pet/findByStatus
|
||||
curl -X GET http://localhost:8080/v2/store/inventory
|
||||
```
|
||||
|
||||
### Run and build with docker
|
||||
Building with docker multistage
|
||||
If you dont have docker install [here](https://docs.docker.com/install)
|
||||
Add yourself to the docker group
|
||||
|
||||
```
|
||||
docker build --network=host -t cpp-qt5-server .
|
||||
```
|
||||
Running with docker
|
||||
```
|
||||
docker run --rm -it --name=server-container cpp-qt5-server
|
||||
```
|
||||
|
||||
#### Invoking an API
|
||||
Mind the IP here
|
||||
```
|
||||
curl -X GET http://172.17.0.2:8080/v2/store/inventory
|
||||
curl -X POST http://172.17.0.2:8080/v2/store/order -H "Content-Type: application/json" -d "{ \"id\": 22, \"petId\": 1541, \"quantity\": 5, \"shipDate\": \"2018-06-16T18:31:43.870Z\", \"status\": \"placed\", \"complete\": \"true\" }"
|
||||
```
|
||||
|
||||
use this command to get the container IP
|
||||
```
|
||||
docker inspect server-container | grep "IPAddress"
|
||||
```
|
||||
To exit from the command line
|
||||
```
|
||||
Ctrl + p + q
|
||||
```
|
||||
To stop container
|
||||
```
|
||||
docker stop <containername>
|
||||
```
|
||||
or to terminate and quit
|
||||
```
|
||||
Ctrl+C
|
||||
```
|
||||
@@ -0,0 +1,48 @@
|
||||
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
|
||||
|
||||
set(CMAKE_VERBOSE_MAKEFILE ON)
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
|
||||
OPTION(NODEBUG "Deactivate No debugging option" "OFF")
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -Wall -Wno-unused-variable")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -std=c++14 -Wall -Wno-unused-variable")
|
||||
|
||||
if(${NODEBUG} STREQUAL "OFF")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pg -g3")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg -g3")
|
||||
else (${NODEBUG} STREQUAL "OFF")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s -O3")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s -O3")
|
||||
endif(${NODEBUG} STREQUAL "OFF")
|
||||
|
||||
find_package(Qt5Core REQUIRED)
|
||||
find_package(Qt5Network REQUIRED)
|
||||
|
||||
file(GLOB SRCS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/models/*.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/handlers/*.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/requests/*.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
|
||||
)
|
||||
|
||||
include_directories(
|
||||
${Qt5Core_INCLUDE_DIRS}
|
||||
${Qt5Network_INCLUDE_DIRS}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/models
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/handlers
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/requests
|
||||
)
|
||||
|
||||
link_directories(
|
||||
${CMAKE_PREFIX_PATH}/lib
|
||||
)
|
||||
|
||||
add_executable(${PROJECT_NAME} ${SRCS})
|
||||
add_dependencies(${PROJECT_NAME} QHTTPENGINE)
|
||||
target_link_libraries(${PROJECT_NAME} Qt5Core Qt5Network ssl crypto qhttpengine)
|
||||
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14)
|
||||
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
|
||||
@@ -0,0 +1,295 @@
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* OpenAPI spec version: 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 <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QVariantMap>
|
||||
#include <QRegularExpression>
|
||||
|
||||
#include "OAIApiRouter.h"
|
||||
#include "OAIPetApiRequest.h"
|
||||
#include "OAIStoreApiRequest.h"
|
||||
#include "OAIUserApiRequest.h"
|
||||
|
||||
|
||||
namespace OpenAPI {
|
||||
|
||||
inline QHttpEngine::Socket::Method toQHttpEngineMethod(QString method){
|
||||
|
||||
if( method == QString("OPTIONS"))
|
||||
return QHttpEngine::Socket::Method::OPTIONS;
|
||||
if( method == QString("GET"))
|
||||
return QHttpEngine::Socket::Method::GET;
|
||||
if( method == QString("HEAD"))
|
||||
return QHttpEngine::Socket::Method::HEAD;
|
||||
if( method == QString("POST"))
|
||||
return QHttpEngine::Socket::Method::POST;
|
||||
if( method == QString("PUT"))
|
||||
return QHttpEngine::Socket::Method::PUT;
|
||||
if( method == QString("DELETE"))
|
||||
return QHttpEngine::Socket::Method::DELETE;
|
||||
if( method == QString("TRACE"))
|
||||
return QHttpEngine::Socket::Method::TRACE;
|
||||
if( method == QString("CONNECT"))
|
||||
return QHttpEngine::Socket::Method::CONNECT;
|
||||
|
||||
return static_cast<QHttpEngine::Socket::Method>(-1);
|
||||
}
|
||||
|
||||
ApiRouter::ApiRouter() {
|
||||
OAIPetApiApiHandler = new OAIPetApiHandler();
|
||||
OAIStoreApiApiHandler = new OAIStoreApiHandler();
|
||||
OAIUserApiApiHandler = new OAIUserApiHandler();
|
||||
|
||||
}
|
||||
|
||||
ApiRouter::~ApiRouter(){
|
||||
qDebug() << "~ApiRouter()";
|
||||
delete OAIPetApiApiHandler;
|
||||
delete OAIStoreApiApiHandler;
|
||||
delete OAIUserApiApiHandler;
|
||||
|
||||
}
|
||||
|
||||
void ApiRouter::setUpRoutes() {
|
||||
|
||||
Routes.insert("/v2/pet",[this](QHttpEngine::Socket *socket) {
|
||||
if(toQHttpEngineMethod("POST") == socket->method()){
|
||||
auto reqObj = new OAIPetApiRequest(socket, OAIPetApiApiHandler);
|
||||
reqObj->addPetRequest();
|
||||
}
|
||||
});
|
||||
Routes.insert("/v2/pet/findByStatus",[this](QHttpEngine::Socket *socket) {
|
||||
if(toQHttpEngineMethod("GET") == socket->method()){
|
||||
auto reqObj = new OAIPetApiRequest(socket, OAIPetApiApiHandler);
|
||||
reqObj->findPetsByStatusRequest();
|
||||
}
|
||||
});
|
||||
Routes.insert("/v2/pet/findByTags",[this](QHttpEngine::Socket *socket) {
|
||||
if(toQHttpEngineMethod("GET") == socket->method()){
|
||||
auto reqObj = new OAIPetApiRequest(socket, OAIPetApiApiHandler);
|
||||
reqObj->findPetsByTagsRequest();
|
||||
}
|
||||
});
|
||||
Routes.insert("/v2/pet",[this](QHttpEngine::Socket *socket) {
|
||||
if(toQHttpEngineMethod("PUT") == socket->method()){
|
||||
auto reqObj = new OAIPetApiRequest(socket, OAIPetApiApiHandler);
|
||||
reqObj->updatePetRequest();
|
||||
}
|
||||
});
|
||||
Routes.insert("/v2/store/inventory",[this](QHttpEngine::Socket *socket) {
|
||||
if(toQHttpEngineMethod("GET") == socket->method()){
|
||||
auto reqObj = new OAIStoreApiRequest(socket, OAIStoreApiApiHandler);
|
||||
reqObj->getInventoryRequest();
|
||||
}
|
||||
});
|
||||
Routes.insert("/v2/store/order",[this](QHttpEngine::Socket *socket) {
|
||||
if(toQHttpEngineMethod("POST") == socket->method()){
|
||||
auto reqObj = new OAIStoreApiRequest(socket, OAIStoreApiApiHandler);
|
||||
reqObj->placeOrderRequest();
|
||||
}
|
||||
});
|
||||
Routes.insert("/v2/user",[this](QHttpEngine::Socket *socket) {
|
||||
if(toQHttpEngineMethod("POST") == socket->method()){
|
||||
auto reqObj = new OAIUserApiRequest(socket, OAIUserApiApiHandler);
|
||||
reqObj->createUserRequest();
|
||||
}
|
||||
});
|
||||
Routes.insert("/v2/user/createWithArray",[this](QHttpEngine::Socket *socket) {
|
||||
if(toQHttpEngineMethod("POST") == socket->method()){
|
||||
auto reqObj = new OAIUserApiRequest(socket, OAIUserApiApiHandler);
|
||||
reqObj->createUsersWithArrayInputRequest();
|
||||
}
|
||||
});
|
||||
Routes.insert("/v2/user/createWithList",[this](QHttpEngine::Socket *socket) {
|
||||
if(toQHttpEngineMethod("POST") == socket->method()){
|
||||
auto reqObj = new OAIUserApiRequest(socket, OAIUserApiApiHandler);
|
||||
reqObj->createUsersWithListInputRequest();
|
||||
}
|
||||
});
|
||||
Routes.insert("/v2/user/login",[this](QHttpEngine::Socket *socket) {
|
||||
if(toQHttpEngineMethod("GET") == socket->method()){
|
||||
auto reqObj = new OAIUserApiRequest(socket, OAIUserApiApiHandler);
|
||||
reqObj->loginUserRequest();
|
||||
}
|
||||
});
|
||||
Routes.insert("/v2/user/logout",[this](QHttpEngine::Socket *socket) {
|
||||
if(toQHttpEngineMethod("GET") == socket->method()){
|
||||
auto reqObj = new OAIUserApiRequest(socket, OAIUserApiApiHandler);
|
||||
reqObj->logoutUserRequest();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void ApiRouter::processRequest(QHttpEngine::Socket *socket){
|
||||
if (Routes.contains(socket->path())) {
|
||||
auto itr = Routes.find(socket->path());
|
||||
while (itr != Routes.end() && itr.key() == socket->path()) {
|
||||
itr.value().operator()(socket);
|
||||
++itr;
|
||||
}
|
||||
} else
|
||||
{
|
||||
{
|
||||
QString completePath("/v2/pet/{petId}");
|
||||
QString pet_idPathParam("{");
|
||||
pet_idPathParam.append("petId").append("}");
|
||||
completePath.replace("/", "\\/"); // replace '/' with '\/' for regex
|
||||
completePath.replace(pet_idPathParam, "([^\\/]*?)"); // match anything but '/''
|
||||
completePath.append("$"); // End of string
|
||||
QRegularExpression re(completePath, QRegularExpression::CaseInsensitiveOption);
|
||||
QRegularExpressionMatch match = re.match(socket->path());
|
||||
if ((toQHttpEngineMethod("DELETE") == socket->method()) && match.hasMatch() ) {
|
||||
QString pathparam = match.captured(1);
|
||||
auto reqObj = new OAIPetApiRequest(socket, OAIPetApiApiHandler);
|
||||
reqObj->deletePetRequest(pathparam);;
|
||||
return;
|
||||
}
|
||||
}
|
||||
{
|
||||
QString completePath("/v2/pet/{petId}");
|
||||
QString pet_idPathParam("{");
|
||||
pet_idPathParam.append("petId").append("}");
|
||||
completePath.replace("/", "\\/"); // replace '/' with '\/' for regex
|
||||
completePath.replace(pet_idPathParam, "([^\\/]*?)"); // match anything but '/''
|
||||
completePath.append("$"); // End of string
|
||||
QRegularExpression re(completePath, QRegularExpression::CaseInsensitiveOption);
|
||||
QRegularExpressionMatch match = re.match(socket->path());
|
||||
if ((toQHttpEngineMethod("GET") == socket->method()) && match.hasMatch() ) {
|
||||
QString pathparam = match.captured(1);
|
||||
auto reqObj = new OAIPetApiRequest(socket, OAIPetApiApiHandler);
|
||||
reqObj->getPetByIdRequest(pathparam);;
|
||||
return;
|
||||
}
|
||||
}
|
||||
{
|
||||
QString completePath("/v2/pet/{petId}");
|
||||
QString pet_idPathParam("{");
|
||||
pet_idPathParam.append("petId").append("}");
|
||||
completePath.replace("/", "\\/"); // replace '/' with '\/' for regex
|
||||
completePath.replace(pet_idPathParam, "([^\\/]*?)"); // match anything but '/''
|
||||
completePath.append("$"); // End of string
|
||||
QRegularExpression re(completePath, QRegularExpression::CaseInsensitiveOption);
|
||||
QRegularExpressionMatch match = re.match(socket->path());
|
||||
if ((toQHttpEngineMethod("POST") == socket->method()) && match.hasMatch() ) {
|
||||
QString pathparam = match.captured(1);
|
||||
auto reqObj = new OAIPetApiRequest(socket, OAIPetApiApiHandler);
|
||||
reqObj->updatePetWithFormRequest(pathparam);;
|
||||
return;
|
||||
}
|
||||
}
|
||||
{
|
||||
QString completePath("/v2/pet/{petId}/uploadImage");
|
||||
QString pet_idPathParam("{");
|
||||
pet_idPathParam.append("petId").append("}");
|
||||
completePath.replace("/", "\\/"); // replace '/' with '\/' for regex
|
||||
completePath.replace(pet_idPathParam, "([^\\/]*?)"); // match anything but '/''
|
||||
completePath.append("$"); // End of string
|
||||
QRegularExpression re(completePath, QRegularExpression::CaseInsensitiveOption);
|
||||
QRegularExpressionMatch match = re.match(socket->path());
|
||||
if ((toQHttpEngineMethod("POST") == socket->method()) && match.hasMatch() ) {
|
||||
QString pathparam = match.captured(1);
|
||||
auto reqObj = new OAIPetApiRequest(socket, OAIPetApiApiHandler);
|
||||
reqObj->uploadFileRequest(pathparam);;
|
||||
return;
|
||||
}
|
||||
}
|
||||
{
|
||||
QString completePath("/v2/store/order/{orderId}");
|
||||
QString order_idPathParam("{");
|
||||
order_idPathParam.append("orderId").append("}");
|
||||
completePath.replace("/", "\\/"); // replace '/' with '\/' for regex
|
||||
completePath.replace(order_idPathParam, "([^\\/]*?)"); // match anything but '/''
|
||||
completePath.append("$"); // End of string
|
||||
QRegularExpression re(completePath, QRegularExpression::CaseInsensitiveOption);
|
||||
QRegularExpressionMatch match = re.match(socket->path());
|
||||
if ((toQHttpEngineMethod("DELETE") == socket->method()) && match.hasMatch() ) {
|
||||
QString pathparam = match.captured(1);
|
||||
auto reqObj = new OAIStoreApiRequest(socket, OAIStoreApiApiHandler);
|
||||
reqObj->deleteOrderRequest(pathparam);;
|
||||
return;
|
||||
}
|
||||
}
|
||||
{
|
||||
QString completePath("/v2/store/order/{orderId}");
|
||||
QString order_idPathParam("{");
|
||||
order_idPathParam.append("orderId").append("}");
|
||||
completePath.replace("/", "\\/"); // replace '/' with '\/' for regex
|
||||
completePath.replace(order_idPathParam, "([^\\/]*?)"); // match anything but '/''
|
||||
completePath.append("$"); // End of string
|
||||
QRegularExpression re(completePath, QRegularExpression::CaseInsensitiveOption);
|
||||
QRegularExpressionMatch match = re.match(socket->path());
|
||||
if ((toQHttpEngineMethod("GET") == socket->method()) && match.hasMatch() ) {
|
||||
QString pathparam = match.captured(1);
|
||||
auto reqObj = new OAIStoreApiRequest(socket, OAIStoreApiApiHandler);
|
||||
reqObj->getOrderByIdRequest(pathparam);;
|
||||
return;
|
||||
}
|
||||
}
|
||||
{
|
||||
QString completePath("/v2/user/{username}");
|
||||
QString usernamePathParam("{");
|
||||
usernamePathParam.append("username").append("}");
|
||||
completePath.replace("/", "\\/"); // replace '/' with '\/' for regex
|
||||
completePath.replace(usernamePathParam, "([^\\/]*?)"); // match anything but '/''
|
||||
completePath.append("$"); // End of string
|
||||
QRegularExpression re(completePath, QRegularExpression::CaseInsensitiveOption);
|
||||
QRegularExpressionMatch match = re.match(socket->path());
|
||||
if ((toQHttpEngineMethod("DELETE") == socket->method()) && match.hasMatch() ) {
|
||||
QString pathparam = match.captured(1);
|
||||
auto reqObj = new OAIUserApiRequest(socket, OAIUserApiApiHandler);
|
||||
reqObj->deleteUserRequest(pathparam);;
|
||||
return;
|
||||
}
|
||||
}
|
||||
{
|
||||
QString completePath("/v2/user/{username}");
|
||||
QString usernamePathParam("{");
|
||||
usernamePathParam.append("username").append("}");
|
||||
completePath.replace("/", "\\/"); // replace '/' with '\/' for regex
|
||||
completePath.replace(usernamePathParam, "([^\\/]*?)"); // match anything but '/''
|
||||
completePath.append("$"); // End of string
|
||||
QRegularExpression re(completePath, QRegularExpression::CaseInsensitiveOption);
|
||||
QRegularExpressionMatch match = re.match(socket->path());
|
||||
if ((toQHttpEngineMethod("GET") == socket->method()) && match.hasMatch() ) {
|
||||
QString pathparam = match.captured(1);
|
||||
auto reqObj = new OAIUserApiRequest(socket, OAIUserApiApiHandler);
|
||||
reqObj->getUserByNameRequest(pathparam);;
|
||||
return;
|
||||
}
|
||||
}
|
||||
{
|
||||
QString completePath("/v2/user/{username}");
|
||||
QString usernamePathParam("{");
|
||||
usernamePathParam.append("username").append("}");
|
||||
completePath.replace("/", "\\/"); // replace '/' with '\/' for regex
|
||||
completePath.replace(usernamePathParam, "([^\\/]*?)"); // match anything but '/''
|
||||
completePath.append("$"); // End of string
|
||||
QRegularExpression re(completePath, QRegularExpression::CaseInsensitiveOption);
|
||||
QRegularExpressionMatch match = re.match(socket->path());
|
||||
if ((toQHttpEngineMethod("PUT") == socket->method()) && match.hasMatch() ) {
|
||||
QString pathparam = match.captured(1);
|
||||
auto reqObj = new OAIUserApiRequest(socket, OAIUserApiApiHandler);
|
||||
reqObj->updateUserRequest(pathparam);;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
socket->setStatusCode(QHttpEngine::Socket::NotFound);
|
||||
if(socket->isOpen()){
|
||||
socket->writeHeaders();
|
||||
socket->close();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -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.
|
||||
*
|
||||
* OpenAPI spec version: 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.
|
||||
*/
|
||||
|
||||
#ifndef OAI_APIROUTER_H
|
||||
#define OAI_APIROUTER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QStringList>
|
||||
#include <QSharedPointer>
|
||||
#include <QList>
|
||||
#include <QMultiMap>
|
||||
|
||||
#include <qhttpengine/socket.h>
|
||||
#include <qhttpengine/handler.h>
|
||||
#include <qhttpengine/qobjecthandler.h>
|
||||
|
||||
#include "OAIPetApiHandler.h"
|
||||
#include "OAIStoreApiHandler.h"
|
||||
#include "OAIUserApiHandler.h"
|
||||
|
||||
|
||||
namespace OpenAPI {
|
||||
|
||||
class RequestHandler : public QHttpEngine::QObjectHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
signals:
|
||||
void requestReceived(QHttpEngine::Socket *socket);
|
||||
|
||||
protected:
|
||||
virtual void process(QHttpEngine::Socket *socket, const QString &path){
|
||||
Q_UNUSED(path);
|
||||
emit requestReceived(socket);
|
||||
}
|
||||
};
|
||||
|
||||
class ApiRouter : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ApiRouter();
|
||||
virtual ~ApiRouter();
|
||||
|
||||
void setUpRoutes();
|
||||
void processRequest(QHttpEngine::Socket *socket);
|
||||
private:
|
||||
QMultiMap<QString, std::function<void(QHttpEngine::Socket *)>> Routes;
|
||||
|
||||
OAIPetApiHandler *OAIPetApiApiHandler;
|
||||
OAIStoreApiHandler *OAIStoreApiApiHandler;
|
||||
OAIUserApiHandler *OAIUserApiApiHandler;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif // OAI_APIROUTER_H
|
||||
@@ -0,0 +1,111 @@
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* OpenAPI spec version: 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 <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QVariantMap>
|
||||
#include <QDebug>
|
||||
|
||||
#include "OAIPetApiHandler.h"
|
||||
#include "OAIPetApiRequest.h"
|
||||
|
||||
namespace OpenAPI {
|
||||
|
||||
OAIPetApiHandler::OAIPetApiHandler(){
|
||||
|
||||
}
|
||||
|
||||
OAIPetApiHandler::~OAIPetApiHandler(){
|
||||
|
||||
}
|
||||
|
||||
void OAIPetApiHandler::addPet(OAIPet oai_pet) {
|
||||
Q_UNUSED(oai_pet);
|
||||
auto reqObj = qobject_cast<OAIPetApiRequest*>(sender());
|
||||
if( reqObj != nullptr )
|
||||
{
|
||||
|
||||
reqObj->addPetResponse();
|
||||
}
|
||||
}
|
||||
void OAIPetApiHandler::deletePet(qint64 pet_id, QString api_key) {
|
||||
Q_UNUSED(pet_id);
|
||||
Q_UNUSED(api_key);
|
||||
auto reqObj = qobject_cast<OAIPetApiRequest*>(sender());
|
||||
if( reqObj != nullptr )
|
||||
{
|
||||
|
||||
reqObj->deletePetResponse();
|
||||
}
|
||||
}
|
||||
void OAIPetApiHandler::findPetsByStatus(QList<QString> status) {
|
||||
Q_UNUSED(status);
|
||||
auto reqObj = qobject_cast<OAIPetApiRequest*>(sender());
|
||||
if( reqObj != nullptr )
|
||||
{
|
||||
QList<OAIPet> res;
|
||||
reqObj->findPetsByStatusResponse(res);
|
||||
}
|
||||
}
|
||||
void OAIPetApiHandler::findPetsByTags(QList<QString> tags) {
|
||||
Q_UNUSED(tags);
|
||||
auto reqObj = qobject_cast<OAIPetApiRequest*>(sender());
|
||||
if( reqObj != nullptr )
|
||||
{
|
||||
QList<OAIPet> res;
|
||||
reqObj->findPetsByTagsResponse(res);
|
||||
}
|
||||
}
|
||||
void OAIPetApiHandler::getPetById(qint64 pet_id) {
|
||||
Q_UNUSED(pet_id);
|
||||
auto reqObj = qobject_cast<OAIPetApiRequest*>(sender());
|
||||
if( reqObj != nullptr )
|
||||
{
|
||||
OAIPet res;
|
||||
reqObj->getPetByIdResponse(res);
|
||||
}
|
||||
}
|
||||
void OAIPetApiHandler::updatePet(OAIPet oai_pet) {
|
||||
Q_UNUSED(oai_pet);
|
||||
auto reqObj = qobject_cast<OAIPetApiRequest*>(sender());
|
||||
if( reqObj != nullptr )
|
||||
{
|
||||
|
||||
reqObj->updatePetResponse();
|
||||
}
|
||||
}
|
||||
void OAIPetApiHandler::updatePetWithForm(qint64 pet_id, QString name, QString status) {
|
||||
Q_UNUSED(pet_id);
|
||||
Q_UNUSED(name);
|
||||
Q_UNUSED(status);
|
||||
auto reqObj = qobject_cast<OAIPetApiRequest*>(sender());
|
||||
if( reqObj != nullptr )
|
||||
{
|
||||
|
||||
reqObj->updatePetWithFormResponse();
|
||||
}
|
||||
}
|
||||
void OAIPetApiHandler::uploadFile(qint64 pet_id, QString additional_metadata, QIODevice* file) {
|
||||
Q_UNUSED(pet_id);
|
||||
Q_UNUSED(additional_metadata);
|
||||
Q_UNUSED(file);
|
||||
auto reqObj = qobject_cast<OAIPetApiRequest*>(sender());
|
||||
if( reqObj != nullptr )
|
||||
{
|
||||
OAIApiResponse res;
|
||||
reqObj->uploadFileResponse(res);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -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.
|
||||
*
|
||||
* OpenAPI spec version: 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.
|
||||
*/
|
||||
|
||||
#ifndef _OAI_OAIPetApiHandler_H_
|
||||
#define _OAI_OAIPetApiHandler_H_
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "OAIApiResponse.h"
|
||||
#include "OAIPet.h"
|
||||
#include <QIODevice>
|
||||
#include <QString>
|
||||
|
||||
namespace OpenAPI {
|
||||
|
||||
class OAIPetApiHandler : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
OAIPetApiHandler();
|
||||
virtual ~OAIPetApiHandler();
|
||||
|
||||
|
||||
public slots:
|
||||
virtual void addPet(OAIPet oai_pet);
|
||||
virtual void deletePet(qint64 pet_id, QString api_key);
|
||||
virtual void findPetsByStatus(QList<QString> status);
|
||||
virtual void findPetsByTags(QList<QString> tags);
|
||||
virtual void getPetById(qint64 pet_id);
|
||||
virtual void updatePet(OAIPet oai_pet);
|
||||
virtual void updatePetWithForm(qint64 pet_id, QString name, QString status);
|
||||
virtual void uploadFile(qint64 pet_id, QString additional_metadata, QIODevice* file);
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // _OAI_OAIPetApiHandler_H_
|
||||
@@ -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.
|
||||
*
|
||||
* OpenAPI spec version: 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 <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QVariantMap>
|
||||
#include <QDebug>
|
||||
|
||||
#include "OAIStoreApiHandler.h"
|
||||
#include "OAIStoreApiRequest.h"
|
||||
|
||||
namespace OpenAPI {
|
||||
|
||||
OAIStoreApiHandler::OAIStoreApiHandler(){
|
||||
|
||||
}
|
||||
|
||||
OAIStoreApiHandler::~OAIStoreApiHandler(){
|
||||
|
||||
}
|
||||
|
||||
void OAIStoreApiHandler::deleteOrder(QString order_id) {
|
||||
Q_UNUSED(order_id);
|
||||
auto reqObj = qobject_cast<OAIStoreApiRequest*>(sender());
|
||||
if( reqObj != nullptr )
|
||||
{
|
||||
|
||||
reqObj->deleteOrderResponse();
|
||||
}
|
||||
}
|
||||
void OAIStoreApiHandler::getInventory() {
|
||||
auto reqObj = qobject_cast<OAIStoreApiRequest*>(sender());
|
||||
if( reqObj != nullptr )
|
||||
{
|
||||
QMap<QString, qint32> res;
|
||||
reqObj->getInventoryResponse(res);
|
||||
}
|
||||
}
|
||||
void OAIStoreApiHandler::getOrderById(qint64 order_id) {
|
||||
Q_UNUSED(order_id);
|
||||
auto reqObj = qobject_cast<OAIStoreApiRequest*>(sender());
|
||||
if( reqObj != nullptr )
|
||||
{
|
||||
OAIOrder res;
|
||||
reqObj->getOrderByIdResponse(res);
|
||||
}
|
||||
}
|
||||
void OAIStoreApiHandler::placeOrder(OAIOrder oai_order) {
|
||||
Q_UNUSED(oai_order);
|
||||
auto reqObj = qobject_cast<OAIStoreApiRequest*>(sender());
|
||||
if( reqObj != nullptr )
|
||||
{
|
||||
OAIOrder res;
|
||||
reqObj->placeOrderResponse(res);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* OpenAPI spec version: 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.
|
||||
*/
|
||||
|
||||
#ifndef _OAI_OAIStoreApiHandler_H_
|
||||
#define _OAI_OAIStoreApiHandler_H_
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "OAIOrder.h"
|
||||
#include <QMap>
|
||||
#include <QString>
|
||||
|
||||
namespace OpenAPI {
|
||||
|
||||
class OAIStoreApiHandler : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
OAIStoreApiHandler();
|
||||
virtual ~OAIStoreApiHandler();
|
||||
|
||||
|
||||
public slots:
|
||||
virtual void deleteOrder(QString order_id);
|
||||
virtual void getInventory();
|
||||
virtual void getOrderById(qint64 order_id);
|
||||
virtual void placeOrder(OAIOrder oai_order);
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // _OAI_OAIStoreApiHandler_H_
|
||||
@@ -0,0 +1,107 @@
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* OpenAPI spec version: 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 <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QVariantMap>
|
||||
#include <QDebug>
|
||||
|
||||
#include "OAIUserApiHandler.h"
|
||||
#include "OAIUserApiRequest.h"
|
||||
|
||||
namespace OpenAPI {
|
||||
|
||||
OAIUserApiHandler::OAIUserApiHandler(){
|
||||
|
||||
}
|
||||
|
||||
OAIUserApiHandler::~OAIUserApiHandler(){
|
||||
|
||||
}
|
||||
|
||||
void OAIUserApiHandler::createUser(OAIUser oai_user) {
|
||||
Q_UNUSED(oai_user);
|
||||
auto reqObj = qobject_cast<OAIUserApiRequest*>(sender());
|
||||
if( reqObj != nullptr )
|
||||
{
|
||||
|
||||
reqObj->createUserResponse();
|
||||
}
|
||||
}
|
||||
void OAIUserApiHandler::createUsersWithArrayInput(QList<OAIUser> oai_user) {
|
||||
Q_UNUSED(oai_user);
|
||||
auto reqObj = qobject_cast<OAIUserApiRequest*>(sender());
|
||||
if( reqObj != nullptr )
|
||||
{
|
||||
|
||||
reqObj->createUsersWithArrayInputResponse();
|
||||
}
|
||||
}
|
||||
void OAIUserApiHandler::createUsersWithListInput(QList<OAIUser> oai_user) {
|
||||
Q_UNUSED(oai_user);
|
||||
auto reqObj = qobject_cast<OAIUserApiRequest*>(sender());
|
||||
if( reqObj != nullptr )
|
||||
{
|
||||
|
||||
reqObj->createUsersWithListInputResponse();
|
||||
}
|
||||
}
|
||||
void OAIUserApiHandler::deleteUser(QString username) {
|
||||
Q_UNUSED(username);
|
||||
auto reqObj = qobject_cast<OAIUserApiRequest*>(sender());
|
||||
if( reqObj != nullptr )
|
||||
{
|
||||
|
||||
reqObj->deleteUserResponse();
|
||||
}
|
||||
}
|
||||
void OAIUserApiHandler::getUserByName(QString username) {
|
||||
Q_UNUSED(username);
|
||||
auto reqObj = qobject_cast<OAIUserApiRequest*>(sender());
|
||||
if( reqObj != nullptr )
|
||||
{
|
||||
OAIUser res;
|
||||
reqObj->getUserByNameResponse(res);
|
||||
}
|
||||
}
|
||||
void OAIUserApiHandler::loginUser(QString username, QString password) {
|
||||
Q_UNUSED(username);
|
||||
Q_UNUSED(password);
|
||||
auto reqObj = qobject_cast<OAIUserApiRequest*>(sender());
|
||||
if( reqObj != nullptr )
|
||||
{
|
||||
QString res;
|
||||
reqObj->loginUserResponse(res);
|
||||
}
|
||||
}
|
||||
void OAIUserApiHandler::logoutUser() {
|
||||
auto reqObj = qobject_cast<OAIUserApiRequest*>(sender());
|
||||
if( reqObj != nullptr )
|
||||
{
|
||||
|
||||
reqObj->logoutUserResponse();
|
||||
}
|
||||
}
|
||||
void OAIUserApiHandler::updateUser(QString username, OAIUser oai_user) {
|
||||
Q_UNUSED(username);
|
||||
Q_UNUSED(oai_user);
|
||||
auto reqObj = qobject_cast<OAIUserApiRequest*>(sender());
|
||||
if( reqObj != nullptr )
|
||||
{
|
||||
|
||||
reqObj->updateUserResponse();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* OpenAPI spec version: 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.
|
||||
*/
|
||||
|
||||
#ifndef _OAI_OAIUserApiHandler_H_
|
||||
#define _OAI_OAIUserApiHandler_H_
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "OAIUser.h"
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
|
||||
namespace OpenAPI {
|
||||
|
||||
class OAIUserApiHandler : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
OAIUserApiHandler();
|
||||
virtual ~OAIUserApiHandler();
|
||||
|
||||
|
||||
public slots:
|
||||
virtual void createUser(OAIUser oai_user);
|
||||
virtual void createUsersWithArrayInput(QList<OAIUser> oai_user);
|
||||
virtual void createUsersWithListInput(QList<OAIUser> oai_user);
|
||||
virtual void deleteUser(QString username);
|
||||
virtual void getUserByName(QString username);
|
||||
virtual void loginUser(QString username, QString password);
|
||||
virtual void logoutUser();
|
||||
virtual void updateUser(QString username, OAIUser oai_user);
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // _OAI_OAIUserApiHandler_H_
|
||||
@@ -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.
|
||||
*
|
||||
* OpenAPI spec version: 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 <QCommandLineOption>
|
||||
#include <QCommandLineParser>
|
||||
#include <QCoreApplication>
|
||||
#include <QHostAddress>
|
||||
#include <QRegExp>
|
||||
#include <QStringList>
|
||||
#include <QSharedPointer>
|
||||
#include <QObject>
|
||||
#ifdef __linux__
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <qhttpengine/server.h>
|
||||
#include "OAIApiRouter.h"
|
||||
|
||||
#ifdef __linux__
|
||||
void catchUnixSignals(QList<int> quitSignals) {
|
||||
auto handler = [](int sig) -> void {
|
||||
// blocking and not aysnc-signal-safe func are valid
|
||||
qDebug() << "\nquit the application by signal " << sig;
|
||||
QCoreApplication::quit();
|
||||
};
|
||||
|
||||
sigset_t blocking_mask;
|
||||
sigemptyset(&blocking_mask);
|
||||
for (auto sig : quitSignals)
|
||||
sigaddset(&blocking_mask, sig);
|
||||
|
||||
struct sigaction sa;
|
||||
sa.sa_handler = handler;
|
||||
sa.sa_mask = blocking_mask;
|
||||
sa.sa_flags = 0;
|
||||
|
||||
for (auto sig : quitSignals)
|
||||
sigaction(sig, &sa, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
QCoreApplication a(argc, argv);
|
||||
#ifdef __linux__
|
||||
QList<int> sigs({SIGQUIT, SIGINT, SIGTERM, SIGHUP});
|
||||
catchUnixSignals(sigs);
|
||||
#endif
|
||||
// Build the command-line options
|
||||
QCommandLineParser parser;
|
||||
QCommandLineOption addressOption(
|
||||
QStringList() << "a" << "address",
|
||||
"address to bind to",
|
||||
"address",
|
||||
"0.0.0.0"
|
||||
);
|
||||
parser.addOption(addressOption);
|
||||
QCommandLineOption portOption(
|
||||
QStringList() << "p" << "port",
|
||||
"port to listen on",
|
||||
"port",
|
||||
"8080"
|
||||
);
|
||||
parser.addOption(portOption);
|
||||
parser.addHelpOption();
|
||||
|
||||
// Parse the options that were provided
|
||||
parser.process(a);
|
||||
|
||||
// Obtain the values
|
||||
QHostAddress address = QHostAddress(parser.value(addressOption));
|
||||
quint16 port = static_cast<quint16>(parser.value(portOption).toInt());
|
||||
|
||||
QSharedPointer<OpenAPI::RequestHandler> handler(new OpenAPI::RequestHandler());
|
||||
OpenAPI::ApiRouter router;
|
||||
QObject::connect(handler.data(), &OpenAPI::RequestHandler::requestReceived, [&](QHttpEngine::Socket *socket) {
|
||||
router.processRequest(socket);
|
||||
});
|
||||
|
||||
QHttpEngine::Server server(handler.data());
|
||||
qDebug() << "Serving on " << address.toString() << ":" << port;
|
||||
// Attempt to listen on the specified port
|
||||
if (!server.listen(address, port)) {
|
||||
qCritical("Unable to listen on the specified port.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* OpenAPI spec version: 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 "OAIApiResponse.h"
|
||||
|
||||
#include "OAIHelpers.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
|
||||
namespace OpenAPI {
|
||||
|
||||
OAIApiResponse::OAIApiResponse(QString json) {
|
||||
this->fromJson(json);
|
||||
}
|
||||
|
||||
OAIApiResponse::OAIApiResponse() {
|
||||
this->init();
|
||||
}
|
||||
|
||||
OAIApiResponse::~OAIApiResponse() {
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
OAIApiResponse::init() {
|
||||
m_code_isSet = false;
|
||||
m_type_isSet = false;
|
||||
m_message_isSet = false;
|
||||
}
|
||||
|
||||
void
|
||||
OAIApiResponse::fromJson(QString jsonString) {
|
||||
QByteArray array (jsonString.toStdString().c_str());
|
||||
QJsonDocument doc = QJsonDocument::fromJson(array);
|
||||
QJsonObject jsonObject = doc.object();
|
||||
this->fromJsonObject(jsonObject);
|
||||
}
|
||||
|
||||
void
|
||||
OAIApiResponse::fromJsonObject(QJsonObject json) {
|
||||
::OpenAPI::fromJsonValue(code, json[QString("code")]);
|
||||
|
||||
::OpenAPI::fromJsonValue(type, json[QString("type")]);
|
||||
|
||||
::OpenAPI::fromJsonValue(message, json[QString("message")]);
|
||||
|
||||
}
|
||||
|
||||
QString
|
||||
OAIApiResponse::asJson () const {
|
||||
QJsonObject obj = this->asJsonObject();
|
||||
QJsonDocument doc(obj);
|
||||
QByteArray bytes = doc.toJson();
|
||||
return QString(bytes);
|
||||
}
|
||||
|
||||
QJsonObject
|
||||
OAIApiResponse::asJsonObject() const {
|
||||
QJsonObject obj;
|
||||
if(m_code_isSet){
|
||||
obj.insert(QString("code"), ::OpenAPI::toJsonValue(code));
|
||||
}
|
||||
if(m_type_isSet){
|
||||
obj.insert(QString("type"), ::OpenAPI::toJsonValue(type));
|
||||
}
|
||||
if(m_message_isSet){
|
||||
obj.insert(QString("message"), ::OpenAPI::toJsonValue(message));
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
qint32
|
||||
OAIApiResponse::getCode() {
|
||||
return code;
|
||||
}
|
||||
void
|
||||
OAIApiResponse::setCode(const qint32 &code) {
|
||||
this->code = code;
|
||||
this->m_code_isSet = true;
|
||||
}
|
||||
|
||||
QString
|
||||
OAIApiResponse::getType() {
|
||||
return type;
|
||||
}
|
||||
void
|
||||
OAIApiResponse::setType(const QString &type) {
|
||||
this->type = type;
|
||||
this->m_type_isSet = true;
|
||||
}
|
||||
|
||||
QString
|
||||
OAIApiResponse::getMessage() {
|
||||
return message;
|
||||
}
|
||||
void
|
||||
OAIApiResponse::setMessage(const QString &message) {
|
||||
this->message = message;
|
||||
this->m_message_isSet = true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
OAIApiResponse::isSet() const {
|
||||
bool isObjectUpdated = false;
|
||||
do{
|
||||
if(m_code_isSet){ isObjectUpdated = true; break;}
|
||||
|
||||
if(m_type_isSet){ isObjectUpdated = true; break;}
|
||||
|
||||
if(m_message_isSet){ isObjectUpdated = true; break;}
|
||||
}while(false);
|
||||
return isObjectUpdated;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* OpenAPI spec version: 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* OAIApiResponse.h
|
||||
*
|
||||
* Describes the result of uploading an image resource
|
||||
*/
|
||||
|
||||
#ifndef OAIApiResponse_H_
|
||||
#define OAIApiResponse_H_
|
||||
|
||||
#include <QJsonObject>
|
||||
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "OAIObject.h"
|
||||
|
||||
namespace OpenAPI {
|
||||
|
||||
class OAIApiResponse: public OAIObject {
|
||||
public:
|
||||
OAIApiResponse();
|
||||
OAIApiResponse(QString json);
|
||||
~OAIApiResponse() override;
|
||||
void init();
|
||||
|
||||
QString asJson () const override;
|
||||
QJsonObject asJsonObject() const override;
|
||||
void fromJsonObject(QJsonObject json) override;
|
||||
void fromJson(QString jsonString) override;
|
||||
|
||||
qint32 getCode();
|
||||
void setCode(const qint32 &code);
|
||||
|
||||
QString getType();
|
||||
void setType(const QString &type);
|
||||
|
||||
QString getMessage();
|
||||
void setMessage(const QString &message);
|
||||
|
||||
virtual bool isSet() const override;
|
||||
|
||||
private:
|
||||
qint32 code;
|
||||
bool m_code_isSet;
|
||||
|
||||
QString type;
|
||||
bool m_type_isSet;
|
||||
|
||||
QString message;
|
||||
bool m_message_isSet;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* OAIApiResponse_H_ */
|
||||
@@ -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.
|
||||
*
|
||||
* OpenAPI spec version: 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 "OAICategory.h"
|
||||
|
||||
#include "OAIHelpers.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
|
||||
namespace OpenAPI {
|
||||
|
||||
OAICategory::OAICategory(QString json) {
|
||||
this->fromJson(json);
|
||||
}
|
||||
|
||||
OAICategory::OAICategory() {
|
||||
this->init();
|
||||
}
|
||||
|
||||
OAICategory::~OAICategory() {
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
OAICategory::init() {
|
||||
m_id_isSet = false;
|
||||
m_name_isSet = false;
|
||||
}
|
||||
|
||||
void
|
||||
OAICategory::fromJson(QString jsonString) {
|
||||
QByteArray array (jsonString.toStdString().c_str());
|
||||
QJsonDocument doc = QJsonDocument::fromJson(array);
|
||||
QJsonObject jsonObject = doc.object();
|
||||
this->fromJsonObject(jsonObject);
|
||||
}
|
||||
|
||||
void
|
||||
OAICategory::fromJsonObject(QJsonObject json) {
|
||||
::OpenAPI::fromJsonValue(id, json[QString("id")]);
|
||||
|
||||
::OpenAPI::fromJsonValue(name, json[QString("name")]);
|
||||
|
||||
}
|
||||
|
||||
QString
|
||||
OAICategory::asJson () const {
|
||||
QJsonObject obj = this->asJsonObject();
|
||||
QJsonDocument doc(obj);
|
||||
QByteArray bytes = doc.toJson();
|
||||
return QString(bytes);
|
||||
}
|
||||
|
||||
QJsonObject
|
||||
OAICategory::asJsonObject() const {
|
||||
QJsonObject obj;
|
||||
if(m_id_isSet){
|
||||
obj.insert(QString("id"), ::OpenAPI::toJsonValue(id));
|
||||
}
|
||||
if(m_name_isSet){
|
||||
obj.insert(QString("name"), ::OpenAPI::toJsonValue(name));
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
qint64
|
||||
OAICategory::getId() {
|
||||
return id;
|
||||
}
|
||||
void
|
||||
OAICategory::setId(const qint64 &id) {
|
||||
this->id = id;
|
||||
this->m_id_isSet = true;
|
||||
}
|
||||
|
||||
QString
|
||||
OAICategory::getName() {
|
||||
return name;
|
||||
}
|
||||
void
|
||||
OAICategory::setName(const QString &name) {
|
||||
this->name = name;
|
||||
this->m_name_isSet = true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
OAICategory::isSet() const {
|
||||
bool isObjectUpdated = false;
|
||||
do{
|
||||
if(m_id_isSet){ isObjectUpdated = true; break;}
|
||||
|
||||
if(m_name_isSet){ isObjectUpdated = true; break;}
|
||||
}while(false);
|
||||
return isObjectUpdated;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
* OpenAPI spec version: 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* OAICategory.h
|
||||
*
|
||||
* A category for a pet
|
||||
*/
|
||||
|
||||
#ifndef OAICategory_H_
|
||||
#define OAICategory_H_
|
||||
|
||||
#include <QJsonObject>
|
||||
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "OAIObject.h"
|
||||
|
||||
namespace OpenAPI {
|
||||
|
||||
class OAICategory: public OAIObject {
|
||||
public:
|
||||
OAICategory();
|
||||
OAICategory(QString json);
|
||||
~OAICategory() override;
|
||||
void init();
|
||||
|
||||
QString asJson () const override;
|
||||
QJsonObject asJsonObject() const override;
|
||||
void fromJsonObject(QJsonObject json) override;
|
||||
void fromJson(QString jsonString) override;
|
||||
|
||||
qint64 getId();
|
||||
void setId(const qint64 &id);
|
||||
|
||||
QString getName();
|
||||
void setName(const QString &name);
|
||||
|
||||
virtual bool isSet() const override;
|
||||
|
||||
private:
|
||||
qint64 id;
|
||||
bool m_id_isSet;
|
||||
|
||||
QString name;
|
||||
bool m_name_isSet;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* OAICategory_H_ */
|
||||
@@ -0,0 +1,289 @@
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* OpenAPI spec version: 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 <QDebug>
|
||||
#include "OAIHelpers.h"
|
||||
#include "OAIObject.h"
|
||||
|
||||
namespace OpenAPI {
|
||||
|
||||
|
||||
QString
|
||||
toStringValue(const QString &value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
QString
|
||||
toStringValue(const QDateTime &value){
|
||||
// ISO 8601
|
||||
return value.toString("yyyy-MM-ddTHH:mm:ss[Z|[+|-]HH:mm]");
|
||||
}
|
||||
|
||||
QString
|
||||
toStringValue(const QByteArray &value){
|
||||
return QString(value);
|
||||
}
|
||||
|
||||
QString
|
||||
toStringValue(const QDate &value){
|
||||
// ISO 8601
|
||||
return value.toString(Qt::DateFormat::ISODate);
|
||||
}
|
||||
|
||||
QString
|
||||
toStringValue(const qint32 &value) {
|
||||
return QString::number(value);
|
||||
}
|
||||
|
||||
QString
|
||||
toStringValue(const qint64 &value) {
|
||||
return QString::number(value);
|
||||
}
|
||||
|
||||
QString
|
||||
toStringValue(const bool &value) {
|
||||
return QString(value ? "true" : "false");
|
||||
}
|
||||
|
||||
QString
|
||||
toStringValue(const float &value){
|
||||
return QString::number(value);
|
||||
}
|
||||
|
||||
QString
|
||||
toStringValue(const double &value){
|
||||
return QString::number(value);
|
||||
}
|
||||
|
||||
QJsonValue
|
||||
toJsonValue(const QString &value){
|
||||
return QJsonValue(value);
|
||||
}
|
||||
|
||||
QJsonValue
|
||||
toJsonValue(const QDateTime &value){
|
||||
return QJsonValue(value.toString(Qt::ISODate));
|
||||
}
|
||||
|
||||
QJsonValue
|
||||
toJsonValue(const QByteArray &value){
|
||||
return QJsonValue(QString(value.toBase64()));
|
||||
}
|
||||
|
||||
QJsonValue
|
||||
toJsonValue(const QDate &value){
|
||||
return QJsonValue(value.toString(Qt::ISODate));
|
||||
}
|
||||
|
||||
QJsonValue
|
||||
toJsonValue(const qint32 &value){
|
||||
return QJsonValue(value);
|
||||
}
|
||||
|
||||
QJsonValue
|
||||
toJsonValue(const qint64 &value){
|
||||
return QJsonValue(value);
|
||||
}
|
||||
|
||||
QJsonValue
|
||||
toJsonValue(const bool &value){
|
||||
return QJsonValue(value);
|
||||
}
|
||||
|
||||
QJsonValue
|
||||
toJsonValue(const float &value){
|
||||
return QJsonValue(value);
|
||||
}
|
||||
|
||||
QJsonValue
|
||||
toJsonValue(const double &value){
|
||||
return QJsonValue(value);
|
||||
}
|
||||
|
||||
QJsonValue
|
||||
toJsonValue(const OAIObject &value){
|
||||
return value.asJsonObject();
|
||||
}
|
||||
|
||||
bool
|
||||
fromStringValue(const QString &inStr, QString &value){
|
||||
value.clear();
|
||||
value.append(inStr);
|
||||
return !inStr.isEmpty();
|
||||
}
|
||||
|
||||
bool
|
||||
fromStringValue(const QString &inStr, QDateTime &value){
|
||||
if(inStr.isEmpty()){
|
||||
return false;
|
||||
}
|
||||
else{
|
||||
auto dateTime = QDateTime::fromString(inStr, "yyyy-MM-ddTHH:mm:ss[Z|[+|-]HH:mm]");
|
||||
if(dateTime.isValid()){
|
||||
value.setDate(dateTime.date());
|
||||
value.setTime(dateTime.time());
|
||||
}
|
||||
else{
|
||||
qDebug() << "DateTime is invalid";
|
||||
}
|
||||
return dateTime.isValid();
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
fromStringValue(const QString &inStr, QByteArray &value){
|
||||
if(inStr.isEmpty()){
|
||||
return false;
|
||||
}
|
||||
else{
|
||||
value.clear();
|
||||
value.append(inStr.toUtf8());
|
||||
return value.count() > 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
fromStringValue(const QString &inStr, QDate &value){
|
||||
if(inStr.isEmpty()){
|
||||
return false;
|
||||
}
|
||||
else{
|
||||
auto date = QDate::fromString(inStr, Qt::DateFormat::ISODate);
|
||||
if(date.isValid()){
|
||||
value.setDate(date.year(), date.month(), date.day());
|
||||
}
|
||||
else{
|
||||
qDebug() << "Date is invalid";
|
||||
}
|
||||
return date.isValid();
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
fromStringValue(const QString &inStr, qint32 &value){
|
||||
bool ok = false;
|
||||
value = QVariant(inStr).toInt(&ok);
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool
|
||||
fromStringValue(const QString &inStr, qint64 &value){
|
||||
bool ok = false;
|
||||
value = QVariant(inStr).toLongLong(&ok);
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool
|
||||
fromStringValue(const QString &inStr, bool &value){
|
||||
value = QVariant(inStr).toBool();
|
||||
return ((inStr == "true") || (inStr == "false"));
|
||||
}
|
||||
|
||||
bool
|
||||
fromStringValue(const QString &inStr, float &value){
|
||||
bool ok = false;
|
||||
value = QVariant(inStr).toFloat(&ok);
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool
|
||||
fromStringValue(const QString &inStr, double &value){
|
||||
bool ok = false;
|
||||
value = QVariant(inStr).toDouble(&ok);
|
||||
return ok;
|
||||
}
|
||||
|
||||
void
|
||||
fromJsonValue(QString &value, const QJsonValue &jval){
|
||||
if(!(jval.isUndefined() || jval.isNull())){
|
||||
if(jval.isString()){
|
||||
value = jval.toString();
|
||||
} else if(jval.isBool()) {
|
||||
value = jval.toBool() ? "true" : "false";
|
||||
} else if(jval.isDouble()){
|
||||
value = QString::number(jval.toDouble());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
fromJsonValue(QDateTime &value, const QJsonValue &jval){
|
||||
if(!(jval.isUndefined() || jval.isNull())){
|
||||
value = QDateTime::fromString(jval.toString(), Qt::ISODate);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
fromJsonValue(QByteArray &value, const QJsonValue &jval){
|
||||
if(!(jval.isUndefined() || jval.isNull())){
|
||||
value = QByteArray::fromBase64(QByteArray::fromStdString(jval.toString().toStdString()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
fromJsonValue(QDate &value, const QJsonValue &jval){
|
||||
if(!(jval.isUndefined() || jval.isNull())){
|
||||
value = QDate::fromString(jval.toString(), Qt::ISODate);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
fromJsonValue(qint32 &value, const QJsonValue &jval){
|
||||
if(!(jval.isUndefined() || jval.isNull())){
|
||||
value = jval.toInt();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
fromJsonValue(qint64 &value, const QJsonValue &jval){
|
||||
if(!(jval.isUndefined() || jval.isNull())){
|
||||
value = jval.toVariant().toLongLong();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
fromJsonValue(bool &value, const QJsonValue &jval){
|
||||
if(!(jval.isUndefined() || jval.isNull())){
|
||||
value = jval.toBool();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
fromJsonValue(float &value, const QJsonValue &jval){
|
||||
if(!(jval.isUndefined() || jval.isNull())){
|
||||
value = static_cast<float>(jval.toDouble());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
fromJsonValue(double &value, const QJsonValue &jval){
|
||||
if(!(jval.isUndefined() || jval.isNull())){
|
||||
value = jval.toDouble();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
fromJsonValue(OAIObject &value, const QJsonValue &jval){
|
||||
if(jval.isObject()){
|
||||
value.fromJsonObject(jval.toObject());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* OpenAPI spec version: 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.
|
||||
*/
|
||||
|
||||
#ifndef OAI_HELPERS_H
|
||||
#define OAI_HELPERS_H
|
||||
|
||||
#include <QJsonObject>
|
||||
#include <QJsonValue>
|
||||
#include <QJsonArray>
|
||||
#include <QList>
|
||||
#include <QMap>
|
||||
#include <QDateTime>
|
||||
#include <QByteArray>
|
||||
#include <QDate>
|
||||
#include <QVariant>
|
||||
#include "OAIObject.h"
|
||||
|
||||
namespace OpenAPI {
|
||||
|
||||
QString toStringValue(const QString &value);
|
||||
QString toStringValue(const QDateTime &value);
|
||||
QString toStringValue(const QByteArray &value);
|
||||
QString toStringValue(const QDate &value);
|
||||
QString toStringValue(const qint32 &value);
|
||||
QString toStringValue(const qint64 &value);
|
||||
QString toStringValue(const bool &value);
|
||||
QString toStringValue(const float &value);
|
||||
QString toStringValue(const double &value);
|
||||
|
||||
template <typename T>
|
||||
QList<QString> toStringValue(const QList<T> &val) {
|
||||
QList<QString> strArray;
|
||||
for(auto item : val) {
|
||||
strArray.append(toStringValue(item));
|
||||
}
|
||||
return strArray;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
QMap<QString, QString> toStringValue(const QMap<QString, T> &val) {
|
||||
QMap<QString, QString> strMap;
|
||||
for(auto itemkey : val.keys()) {
|
||||
strMap.insert(itemkey, toStringValue(val.value(itemkey)));
|
||||
}
|
||||
return strMap;
|
||||
}
|
||||
|
||||
QJsonValue toJsonValue(const QString &value);
|
||||
QJsonValue toJsonValue(const QDateTime &value);
|
||||
QJsonValue toJsonValue(const QByteArray &value);
|
||||
QJsonValue toJsonValue(const QDate &value);
|
||||
QJsonValue toJsonValue(const qint32 &value);
|
||||
QJsonValue toJsonValue(const qint64 &value);
|
||||
QJsonValue toJsonValue(const bool &value);
|
||||
QJsonValue toJsonValue(const float &value);
|
||||
QJsonValue toJsonValue(const double &value);
|
||||
QJsonValue toJsonValue(const OAIObject &value);
|
||||
|
||||
template <typename T>
|
||||
QJsonValue toJsonValue(const QList<T> &val) {
|
||||
QJsonArray jArray;
|
||||
for(auto item : val) {
|
||||
jArray.append(toJsonValue(item));
|
||||
}
|
||||
return jArray;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
QJsonValue toJsonValue(const QMap<QString, T> &val) {
|
||||
QJsonObject jObject;
|
||||
for(auto itemkey : val.keys()) {
|
||||
jObject.insert(itemkey, toJsonValue(val.value(itemkey)));
|
||||
}
|
||||
return jObject;
|
||||
}
|
||||
|
||||
bool fromStringValue(const QString &inStr, QString &value);
|
||||
bool fromStringValue(const QString &inStr, QDateTime &value);
|
||||
bool fromStringValue(const QString &inStr, QByteArray &value);
|
||||
bool fromStringValue(const QString &inStr, QDate &value);
|
||||
bool fromStringValue(const QString &inStr, qint32 &value);
|
||||
bool fromStringValue(const QString &inStr, qint64 &value);
|
||||
bool fromStringValue(const QString &inStr, bool &value);
|
||||
bool fromStringValue(const QString &inStr, float &value);
|
||||
bool fromStringValue(const QString &inStr, double &value);
|
||||
|
||||
template <typename T>
|
||||
void fromStringValue(const QList<QString> &inStr, QList<T> &val) {
|
||||
for(auto item: inStr){
|
||||
T itemVal;
|
||||
fromStringValue(item, itemVal);
|
||||
val.push_back(itemVal);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void fromStringValue(const QMap<QString, QString> &inStr, QMap<QString, T> &val) {
|
||||
for(auto itemkey : inStr.keys()){
|
||||
T itemVal;
|
||||
fromStringValue(inStr.value(itemkey), itemVal);
|
||||
val.insert(itemkey, itemVal);
|
||||
}
|
||||
}
|
||||
|
||||
void fromJsonValue(QString &value, const QJsonValue &jval);
|
||||
void fromJsonValue(QDateTime &value, const QJsonValue &jval);
|
||||
void fromJsonValue(QByteArray &value, const QJsonValue &jval);
|
||||
void fromJsonValue(QDate &value, const QJsonValue &jval);
|
||||
void fromJsonValue(qint32 &value, const QJsonValue &jval);
|
||||
void fromJsonValue(qint64 &value, const QJsonValue &jval);
|
||||
void fromJsonValue(bool &value, const QJsonValue &jval);
|
||||
void fromJsonValue(float &value, const QJsonValue &jval);
|
||||
void fromJsonValue(double &value, const QJsonValue &jval);
|
||||
void fromJsonValue(OAIObject &value, const QJsonValue &jval);
|
||||
|
||||
template <typename T>
|
||||
void fromJsonValue(QList<T> &val, const QJsonValue &jval) {
|
||||
if(jval.isArray()){
|
||||
for(const QJsonValue &jitem : jval.toArray()){
|
||||
T item;
|
||||
fromJsonValue(item, jitem);
|
||||
val.push_back(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void fromJsonValue(QMap<QString, T> &val, const QJsonValue &jval) {
|
||||
auto varmap = jval.toObject().toVariantMap();
|
||||
if(varmap.count() > 0){
|
||||
for(auto itemkey : varmap.keys() ){
|
||||
T itemVal;
|
||||
fromJsonValue(itemVal, QJsonValue::fromVariant(varmap.value(itemkey)));
|
||||
val.insert(itemkey, val);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // OAI_HELPERS_H
|
||||
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* OpenAPI spec version: 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.
|
||||
*/
|
||||
|
||||
#ifndef _OAI_OBJECT_H_
|
||||
#define _OAI_OBJECT_H_
|
||||
|
||||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
|
||||
namespace OpenAPI {
|
||||
|
||||
class OAIObject {
|
||||
public:
|
||||
virtual ~OAIObject(){
|
||||
|
||||
}
|
||||
|
||||
virtual QJsonObject asJsonObject() const {
|
||||
return jObj;
|
||||
}
|
||||
|
||||
virtual QString asJson() const {
|
||||
QJsonDocument doc(jObj);
|
||||
return doc.toJson(QJsonDocument::Compact);
|
||||
}
|
||||
|
||||
virtual void fromJson(QString jsonString) {
|
||||
QJsonDocument doc = QJsonDocument::fromJson(jsonString.toUtf8());
|
||||
jObj = doc.object();
|
||||
}
|
||||
|
||||
virtual void fromJsonObject(QJsonObject json) {
|
||||
jObj = json;
|
||||
}
|
||||
|
||||
virtual bool isSet() const {
|
||||
return false;
|
||||
}
|
||||
private :
|
||||
QJsonObject jObj;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* _OAI_OBJECT_H_ */
|
||||
@@ -0,0 +1,184 @@
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* OpenAPI spec version: 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 "OAIOrder.h"
|
||||
|
||||
#include "OAIHelpers.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
|
||||
namespace OpenAPI {
|
||||
|
||||
OAIOrder::OAIOrder(QString json) {
|
||||
this->fromJson(json);
|
||||
}
|
||||
|
||||
OAIOrder::OAIOrder() {
|
||||
this->init();
|
||||
}
|
||||
|
||||
OAIOrder::~OAIOrder() {
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
OAIOrder::init() {
|
||||
m_id_isSet = false;
|
||||
m_pet_id_isSet = false;
|
||||
m_quantity_isSet = false;
|
||||
m_ship_date_isSet = false;
|
||||
m_status_isSet = false;
|
||||
m_complete_isSet = false;
|
||||
}
|
||||
|
||||
void
|
||||
OAIOrder::fromJson(QString jsonString) {
|
||||
QByteArray array (jsonString.toStdString().c_str());
|
||||
QJsonDocument doc = QJsonDocument::fromJson(array);
|
||||
QJsonObject jsonObject = doc.object();
|
||||
this->fromJsonObject(jsonObject);
|
||||
}
|
||||
|
||||
void
|
||||
OAIOrder::fromJsonObject(QJsonObject json) {
|
||||
::OpenAPI::fromJsonValue(id, json[QString("id")]);
|
||||
|
||||
::OpenAPI::fromJsonValue(pet_id, json[QString("petId")]);
|
||||
|
||||
::OpenAPI::fromJsonValue(quantity, json[QString("quantity")]);
|
||||
|
||||
::OpenAPI::fromJsonValue(ship_date, json[QString("shipDate")]);
|
||||
|
||||
::OpenAPI::fromJsonValue(status, json[QString("status")]);
|
||||
|
||||
::OpenAPI::fromJsonValue(complete, json[QString("complete")]);
|
||||
|
||||
}
|
||||
|
||||
QString
|
||||
OAIOrder::asJson () const {
|
||||
QJsonObject obj = this->asJsonObject();
|
||||
QJsonDocument doc(obj);
|
||||
QByteArray bytes = doc.toJson();
|
||||
return QString(bytes);
|
||||
}
|
||||
|
||||
QJsonObject
|
||||
OAIOrder::asJsonObject() const {
|
||||
QJsonObject obj;
|
||||
if(m_id_isSet){
|
||||
obj.insert(QString("id"), ::OpenAPI::toJsonValue(id));
|
||||
}
|
||||
if(m_pet_id_isSet){
|
||||
obj.insert(QString("petId"), ::OpenAPI::toJsonValue(pet_id));
|
||||
}
|
||||
if(m_quantity_isSet){
|
||||
obj.insert(QString("quantity"), ::OpenAPI::toJsonValue(quantity));
|
||||
}
|
||||
if(m_ship_date_isSet){
|
||||
obj.insert(QString("shipDate"), ::OpenAPI::toJsonValue(ship_date));
|
||||
}
|
||||
if(m_status_isSet){
|
||||
obj.insert(QString("status"), ::OpenAPI::toJsonValue(status));
|
||||
}
|
||||
if(m_complete_isSet){
|
||||
obj.insert(QString("complete"), ::OpenAPI::toJsonValue(complete));
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
qint64
|
||||
OAIOrder::getId() {
|
||||
return id;
|
||||
}
|
||||
void
|
||||
OAIOrder::setId(const qint64 &id) {
|
||||
this->id = id;
|
||||
this->m_id_isSet = true;
|
||||
}
|
||||
|
||||
qint64
|
||||
OAIOrder::getPetId() {
|
||||
return pet_id;
|
||||
}
|
||||
void
|
||||
OAIOrder::setPetId(const qint64 &pet_id) {
|
||||
this->pet_id = pet_id;
|
||||
this->m_pet_id_isSet = true;
|
||||
}
|
||||
|
||||
qint32
|
||||
OAIOrder::getQuantity() {
|
||||
return quantity;
|
||||
}
|
||||
void
|
||||
OAIOrder::setQuantity(const qint32 &quantity) {
|
||||
this->quantity = quantity;
|
||||
this->m_quantity_isSet = true;
|
||||
}
|
||||
|
||||
QDateTime
|
||||
OAIOrder::getShipDate() {
|
||||
return ship_date;
|
||||
}
|
||||
void
|
||||
OAIOrder::setShipDate(const QDateTime &ship_date) {
|
||||
this->ship_date = ship_date;
|
||||
this->m_ship_date_isSet = true;
|
||||
}
|
||||
|
||||
QString
|
||||
OAIOrder::getStatus() {
|
||||
return status;
|
||||
}
|
||||
void
|
||||
OAIOrder::setStatus(const QString &status) {
|
||||
this->status = status;
|
||||
this->m_status_isSet = true;
|
||||
}
|
||||
|
||||
bool
|
||||
OAIOrder::isComplete() {
|
||||
return complete;
|
||||
}
|
||||
void
|
||||
OAIOrder::setComplete(const bool &complete) {
|
||||
this->complete = complete;
|
||||
this->m_complete_isSet = true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
OAIOrder::isSet() const {
|
||||
bool isObjectUpdated = false;
|
||||
do{
|
||||
if(m_id_isSet){ isObjectUpdated = true; break;}
|
||||
|
||||
if(m_pet_id_isSet){ isObjectUpdated = true; break;}
|
||||
|
||||
if(m_quantity_isSet){ isObjectUpdated = true; break;}
|
||||
|
||||
if(m_ship_date_isSet){ isObjectUpdated = true; break;}
|
||||
|
||||
if(m_status_isSet){ isObjectUpdated = true; break;}
|
||||
|
||||
if(m_complete_isSet){ isObjectUpdated = true; break;}
|
||||
}while(false);
|
||||
return isObjectUpdated;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* OpenAPI spec version: 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* OAIOrder.h
|
||||
*
|
||||
* An order for a pets from the pet store
|
||||
*/
|
||||
|
||||
#ifndef OAIOrder_H_
|
||||
#define OAIOrder_H_
|
||||
|
||||
#include <QJsonObject>
|
||||
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QString>
|
||||
|
||||
#include "OAIObject.h"
|
||||
|
||||
namespace OpenAPI {
|
||||
|
||||
class OAIOrder: public OAIObject {
|
||||
public:
|
||||
OAIOrder();
|
||||
OAIOrder(QString json);
|
||||
~OAIOrder() override;
|
||||
void init();
|
||||
|
||||
QString asJson () const override;
|
||||
QJsonObject asJsonObject() const override;
|
||||
void fromJsonObject(QJsonObject json) override;
|
||||
void fromJson(QString jsonString) override;
|
||||
|
||||
qint64 getId();
|
||||
void setId(const qint64 &id);
|
||||
|
||||
qint64 getPetId();
|
||||
void setPetId(const qint64 &pet_id);
|
||||
|
||||
qint32 getQuantity();
|
||||
void setQuantity(const qint32 &quantity);
|
||||
|
||||
QDateTime getShipDate();
|
||||
void setShipDate(const QDateTime &ship_date);
|
||||
|
||||
QString getStatus();
|
||||
void setStatus(const QString &status);
|
||||
|
||||
bool isComplete();
|
||||
void setComplete(const bool &complete);
|
||||
|
||||
virtual bool isSet() const override;
|
||||
|
||||
private:
|
||||
qint64 id;
|
||||
bool m_id_isSet;
|
||||
|
||||
qint64 pet_id;
|
||||
bool m_pet_id_isSet;
|
||||
|
||||
qint32 quantity;
|
||||
bool m_quantity_isSet;
|
||||
|
||||
QDateTime ship_date;
|
||||
bool m_ship_date_isSet;
|
||||
|
||||
QString status;
|
||||
bool m_status_isSet;
|
||||
|
||||
bool complete;
|
||||
bool m_complete_isSet;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* OAIOrder_H_ */
|
||||
@@ -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.
|
||||
*
|
||||
* OpenAPI spec version: 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 "OAIPet.h"
|
||||
|
||||
#include "OAIHelpers.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
|
||||
namespace OpenAPI {
|
||||
|
||||
OAIPet::OAIPet(QString json) {
|
||||
this->fromJson(json);
|
||||
}
|
||||
|
||||
OAIPet::OAIPet() {
|
||||
this->init();
|
||||
}
|
||||
|
||||
OAIPet::~OAIPet() {
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
OAIPet::init() {
|
||||
m_id_isSet = false;
|
||||
m_category_isSet = false;
|
||||
m_name_isSet = false;
|
||||
m_photo_urls_isSet = false;
|
||||
m_tags_isSet = false;
|
||||
m_status_isSet = false;
|
||||
}
|
||||
|
||||
void
|
||||
OAIPet::fromJson(QString jsonString) {
|
||||
QByteArray array (jsonString.toStdString().c_str());
|
||||
QJsonDocument doc = QJsonDocument::fromJson(array);
|
||||
QJsonObject jsonObject = doc.object();
|
||||
this->fromJsonObject(jsonObject);
|
||||
}
|
||||
|
||||
void
|
||||
OAIPet::fromJsonObject(QJsonObject json) {
|
||||
::OpenAPI::fromJsonValue(id, json[QString("id")]);
|
||||
|
||||
::OpenAPI::fromJsonValue(category, json[QString("category")]);
|
||||
|
||||
::OpenAPI::fromJsonValue(name, json[QString("name")]);
|
||||
|
||||
|
||||
::OpenAPI::fromJsonValue(photo_urls, json[QString("photoUrls")]);
|
||||
|
||||
::OpenAPI::fromJsonValue(tags, json[QString("tags")]);
|
||||
::OpenAPI::fromJsonValue(status, json[QString("status")]);
|
||||
|
||||
}
|
||||
|
||||
QString
|
||||
OAIPet::asJson () const {
|
||||
QJsonObject obj = this->asJsonObject();
|
||||
QJsonDocument doc(obj);
|
||||
QByteArray bytes = doc.toJson();
|
||||
return QString(bytes);
|
||||
}
|
||||
|
||||
QJsonObject
|
||||
OAIPet::asJsonObject() const {
|
||||
QJsonObject obj;
|
||||
if(m_id_isSet){
|
||||
obj.insert(QString("id"), ::OpenAPI::toJsonValue(id));
|
||||
}
|
||||
if(category.isSet()){
|
||||
obj.insert(QString("category"), ::OpenAPI::toJsonValue(category));
|
||||
}
|
||||
if(m_name_isSet){
|
||||
obj.insert(QString("name"), ::OpenAPI::toJsonValue(name));
|
||||
}
|
||||
|
||||
if(photo_urls.size() > 0){
|
||||
obj.insert(QString("photoUrls"), ::OpenAPI::toJsonValue(photo_urls));
|
||||
}
|
||||
|
||||
if(tags.size() > 0){
|
||||
obj.insert(QString("tags"), ::OpenAPI::toJsonValue(tags));
|
||||
}
|
||||
if(m_status_isSet){
|
||||
obj.insert(QString("status"), ::OpenAPI::toJsonValue(status));
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
qint64
|
||||
OAIPet::getId() {
|
||||
return id;
|
||||
}
|
||||
void
|
||||
OAIPet::setId(const qint64 &id) {
|
||||
this->id = id;
|
||||
this->m_id_isSet = true;
|
||||
}
|
||||
|
||||
OAICategory
|
||||
OAIPet::getCategory() {
|
||||
return category;
|
||||
}
|
||||
void
|
||||
OAIPet::setCategory(const OAICategory &category) {
|
||||
this->category = category;
|
||||
this->m_category_isSet = true;
|
||||
}
|
||||
|
||||
QString
|
||||
OAIPet::getName() {
|
||||
return name;
|
||||
}
|
||||
void
|
||||
OAIPet::setName(const QString &name) {
|
||||
this->name = name;
|
||||
this->m_name_isSet = true;
|
||||
}
|
||||
|
||||
QList<QString>
|
||||
OAIPet::getPhotoUrls() {
|
||||
return photo_urls;
|
||||
}
|
||||
void
|
||||
OAIPet::setPhotoUrls(const QList<QString> &photo_urls) {
|
||||
this->photo_urls = photo_urls;
|
||||
this->m_photo_urls_isSet = true;
|
||||
}
|
||||
|
||||
QList<OAITag>
|
||||
OAIPet::getTags() {
|
||||
return tags;
|
||||
}
|
||||
void
|
||||
OAIPet::setTags(const QList<OAITag> &tags) {
|
||||
this->tags = tags;
|
||||
this->m_tags_isSet = true;
|
||||
}
|
||||
|
||||
QString
|
||||
OAIPet::getStatus() {
|
||||
return status;
|
||||
}
|
||||
void
|
||||
OAIPet::setStatus(const QString &status) {
|
||||
this->status = status;
|
||||
this->m_status_isSet = true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
OAIPet::isSet() const {
|
||||
bool isObjectUpdated = false;
|
||||
do{
|
||||
if(m_id_isSet){ isObjectUpdated = true; break;}
|
||||
|
||||
if(category.isSet()){ isObjectUpdated = true; break;}
|
||||
|
||||
if(m_name_isSet){ isObjectUpdated = true; break;}
|
||||
|
||||
if(photo_urls.size() > 0){ isObjectUpdated = true; break;}
|
||||
|
||||
if(tags.size() > 0){ isObjectUpdated = true; break;}
|
||||
|
||||
if(m_status_isSet){ isObjectUpdated = true; break;}
|
||||
}while(false);
|
||||
return isObjectUpdated;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* OpenAPI spec version: 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* OAIPet.h
|
||||
*
|
||||
* A pet for sale in the pet store
|
||||
*/
|
||||
|
||||
#ifndef OAIPet_H_
|
||||
#define OAIPet_H_
|
||||
|
||||
#include <QJsonObject>
|
||||
|
||||
|
||||
#include "OAICategory.h"
|
||||
#include "OAITag.h"
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
|
||||
#include "OAIObject.h"
|
||||
|
||||
namespace OpenAPI {
|
||||
|
||||
class OAIPet: public OAIObject {
|
||||
public:
|
||||
OAIPet();
|
||||
OAIPet(QString json);
|
||||
~OAIPet() override;
|
||||
void init();
|
||||
|
||||
QString asJson () const override;
|
||||
QJsonObject asJsonObject() const override;
|
||||
void fromJsonObject(QJsonObject json) override;
|
||||
void fromJson(QString jsonString) override;
|
||||
|
||||
qint64 getId();
|
||||
void setId(const qint64 &id);
|
||||
|
||||
OAICategory getCategory();
|
||||
void setCategory(const OAICategory &category);
|
||||
|
||||
QString getName();
|
||||
void setName(const QString &name);
|
||||
|
||||
QList<QString> getPhotoUrls();
|
||||
void setPhotoUrls(const QList<QString> &photo_urls);
|
||||
|
||||
QList<OAITag> getTags();
|
||||
void setTags(const QList<OAITag> &tags);
|
||||
|
||||
QString getStatus();
|
||||
void setStatus(const QString &status);
|
||||
|
||||
virtual bool isSet() const override;
|
||||
|
||||
private:
|
||||
qint64 id;
|
||||
bool m_id_isSet;
|
||||
|
||||
OAICategory category;
|
||||
bool m_category_isSet;
|
||||
|
||||
QString name;
|
||||
bool m_name_isSet;
|
||||
|
||||
QList<QString> photo_urls;
|
||||
bool m_photo_urls_isSet;
|
||||
|
||||
QList<OAITag> tags;
|
||||
bool m_tags_isSet;
|
||||
|
||||
QString status;
|
||||
bool m_status_isSet;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* OAIPet_H_ */
|
||||
@@ -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.
|
||||
*
|
||||
* OpenAPI spec version: 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 "OAITag.h"
|
||||
|
||||
#include "OAIHelpers.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
|
||||
namespace OpenAPI {
|
||||
|
||||
OAITag::OAITag(QString json) {
|
||||
this->fromJson(json);
|
||||
}
|
||||
|
||||
OAITag::OAITag() {
|
||||
this->init();
|
||||
}
|
||||
|
||||
OAITag::~OAITag() {
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
OAITag::init() {
|
||||
m_id_isSet = false;
|
||||
m_name_isSet = false;
|
||||
}
|
||||
|
||||
void
|
||||
OAITag::fromJson(QString jsonString) {
|
||||
QByteArray array (jsonString.toStdString().c_str());
|
||||
QJsonDocument doc = QJsonDocument::fromJson(array);
|
||||
QJsonObject jsonObject = doc.object();
|
||||
this->fromJsonObject(jsonObject);
|
||||
}
|
||||
|
||||
void
|
||||
OAITag::fromJsonObject(QJsonObject json) {
|
||||
::OpenAPI::fromJsonValue(id, json[QString("id")]);
|
||||
|
||||
::OpenAPI::fromJsonValue(name, json[QString("name")]);
|
||||
|
||||
}
|
||||
|
||||
QString
|
||||
OAITag::asJson () const {
|
||||
QJsonObject obj = this->asJsonObject();
|
||||
QJsonDocument doc(obj);
|
||||
QByteArray bytes = doc.toJson();
|
||||
return QString(bytes);
|
||||
}
|
||||
|
||||
QJsonObject
|
||||
OAITag::asJsonObject() const {
|
||||
QJsonObject obj;
|
||||
if(m_id_isSet){
|
||||
obj.insert(QString("id"), ::OpenAPI::toJsonValue(id));
|
||||
}
|
||||
if(m_name_isSet){
|
||||
obj.insert(QString("name"), ::OpenAPI::toJsonValue(name));
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
qint64
|
||||
OAITag::getId() {
|
||||
return id;
|
||||
}
|
||||
void
|
||||
OAITag::setId(const qint64 &id) {
|
||||
this->id = id;
|
||||
this->m_id_isSet = true;
|
||||
}
|
||||
|
||||
QString
|
||||
OAITag::getName() {
|
||||
return name;
|
||||
}
|
||||
void
|
||||
OAITag::setName(const QString &name) {
|
||||
this->name = name;
|
||||
this->m_name_isSet = true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
OAITag::isSet() const {
|
||||
bool isObjectUpdated = false;
|
||||
do{
|
||||
if(m_id_isSet){ isObjectUpdated = true; break;}
|
||||
|
||||
if(m_name_isSet){ isObjectUpdated = true; break;}
|
||||
}while(false);
|
||||
return isObjectUpdated;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
* OpenAPI spec version: 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* OAITag.h
|
||||
*
|
||||
* A tag for a pet
|
||||
*/
|
||||
|
||||
#ifndef OAITag_H_
|
||||
#define OAITag_H_
|
||||
|
||||
#include <QJsonObject>
|
||||
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "OAIObject.h"
|
||||
|
||||
namespace OpenAPI {
|
||||
|
||||
class OAITag: public OAIObject {
|
||||
public:
|
||||
OAITag();
|
||||
OAITag(QString json);
|
||||
~OAITag() override;
|
||||
void init();
|
||||
|
||||
QString asJson () const override;
|
||||
QJsonObject asJsonObject() const override;
|
||||
void fromJsonObject(QJsonObject json) override;
|
||||
void fromJson(QString jsonString) override;
|
||||
|
||||
qint64 getId();
|
||||
void setId(const qint64 &id);
|
||||
|
||||
QString getName();
|
||||
void setName(const QString &name);
|
||||
|
||||
virtual bool isSet() const override;
|
||||
|
||||
private:
|
||||
qint64 id;
|
||||
bool m_id_isSet;
|
||||
|
||||
QString name;
|
||||
bool m_name_isSet;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* OAITag_H_ */
|
||||
@@ -0,0 +1,220 @@
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* OpenAPI spec version: 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 "OAIUser.h"
|
||||
|
||||
#include "OAIHelpers.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
|
||||
namespace OpenAPI {
|
||||
|
||||
OAIUser::OAIUser(QString json) {
|
||||
this->fromJson(json);
|
||||
}
|
||||
|
||||
OAIUser::OAIUser() {
|
||||
this->init();
|
||||
}
|
||||
|
||||
OAIUser::~OAIUser() {
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
OAIUser::init() {
|
||||
m_id_isSet = false;
|
||||
m_username_isSet = false;
|
||||
m_first_name_isSet = false;
|
||||
m_last_name_isSet = false;
|
||||
m_email_isSet = false;
|
||||
m_password_isSet = false;
|
||||
m_phone_isSet = false;
|
||||
m_user_status_isSet = false;
|
||||
}
|
||||
|
||||
void
|
||||
OAIUser::fromJson(QString jsonString) {
|
||||
QByteArray array (jsonString.toStdString().c_str());
|
||||
QJsonDocument doc = QJsonDocument::fromJson(array);
|
||||
QJsonObject jsonObject = doc.object();
|
||||
this->fromJsonObject(jsonObject);
|
||||
}
|
||||
|
||||
void
|
||||
OAIUser::fromJsonObject(QJsonObject json) {
|
||||
::OpenAPI::fromJsonValue(id, json[QString("id")]);
|
||||
|
||||
::OpenAPI::fromJsonValue(username, json[QString("username")]);
|
||||
|
||||
::OpenAPI::fromJsonValue(first_name, json[QString("firstName")]);
|
||||
|
||||
::OpenAPI::fromJsonValue(last_name, json[QString("lastName")]);
|
||||
|
||||
::OpenAPI::fromJsonValue(email, json[QString("email")]);
|
||||
|
||||
::OpenAPI::fromJsonValue(password, json[QString("password")]);
|
||||
|
||||
::OpenAPI::fromJsonValue(phone, json[QString("phone")]);
|
||||
|
||||
::OpenAPI::fromJsonValue(user_status, json[QString("userStatus")]);
|
||||
|
||||
}
|
||||
|
||||
QString
|
||||
OAIUser::asJson () const {
|
||||
QJsonObject obj = this->asJsonObject();
|
||||
QJsonDocument doc(obj);
|
||||
QByteArray bytes = doc.toJson();
|
||||
return QString(bytes);
|
||||
}
|
||||
|
||||
QJsonObject
|
||||
OAIUser::asJsonObject() const {
|
||||
QJsonObject obj;
|
||||
if(m_id_isSet){
|
||||
obj.insert(QString("id"), ::OpenAPI::toJsonValue(id));
|
||||
}
|
||||
if(m_username_isSet){
|
||||
obj.insert(QString("username"), ::OpenAPI::toJsonValue(username));
|
||||
}
|
||||
if(m_first_name_isSet){
|
||||
obj.insert(QString("firstName"), ::OpenAPI::toJsonValue(first_name));
|
||||
}
|
||||
if(m_last_name_isSet){
|
||||
obj.insert(QString("lastName"), ::OpenAPI::toJsonValue(last_name));
|
||||
}
|
||||
if(m_email_isSet){
|
||||
obj.insert(QString("email"), ::OpenAPI::toJsonValue(email));
|
||||
}
|
||||
if(m_password_isSet){
|
||||
obj.insert(QString("password"), ::OpenAPI::toJsonValue(password));
|
||||
}
|
||||
if(m_phone_isSet){
|
||||
obj.insert(QString("phone"), ::OpenAPI::toJsonValue(phone));
|
||||
}
|
||||
if(m_user_status_isSet){
|
||||
obj.insert(QString("userStatus"), ::OpenAPI::toJsonValue(user_status));
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
qint64
|
||||
OAIUser::getId() {
|
||||
return id;
|
||||
}
|
||||
void
|
||||
OAIUser::setId(const qint64 &id) {
|
||||
this->id = id;
|
||||
this->m_id_isSet = true;
|
||||
}
|
||||
|
||||
QString
|
||||
OAIUser::getUsername() {
|
||||
return username;
|
||||
}
|
||||
void
|
||||
OAIUser::setUsername(const QString &username) {
|
||||
this->username = username;
|
||||
this->m_username_isSet = true;
|
||||
}
|
||||
|
||||
QString
|
||||
OAIUser::getFirstName() {
|
||||
return first_name;
|
||||
}
|
||||
void
|
||||
OAIUser::setFirstName(const QString &first_name) {
|
||||
this->first_name = first_name;
|
||||
this->m_first_name_isSet = true;
|
||||
}
|
||||
|
||||
QString
|
||||
OAIUser::getLastName() {
|
||||
return last_name;
|
||||
}
|
||||
void
|
||||
OAIUser::setLastName(const QString &last_name) {
|
||||
this->last_name = last_name;
|
||||
this->m_last_name_isSet = true;
|
||||
}
|
||||
|
||||
QString
|
||||
OAIUser::getEmail() {
|
||||
return email;
|
||||
}
|
||||
void
|
||||
OAIUser::setEmail(const QString &email) {
|
||||
this->email = email;
|
||||
this->m_email_isSet = true;
|
||||
}
|
||||
|
||||
QString
|
||||
OAIUser::getPassword() {
|
||||
return password;
|
||||
}
|
||||
void
|
||||
OAIUser::setPassword(const QString &password) {
|
||||
this->password = password;
|
||||
this->m_password_isSet = true;
|
||||
}
|
||||
|
||||
QString
|
||||
OAIUser::getPhone() {
|
||||
return phone;
|
||||
}
|
||||
void
|
||||
OAIUser::setPhone(const QString &phone) {
|
||||
this->phone = phone;
|
||||
this->m_phone_isSet = true;
|
||||
}
|
||||
|
||||
qint32
|
||||
OAIUser::getUserStatus() {
|
||||
return user_status;
|
||||
}
|
||||
void
|
||||
OAIUser::setUserStatus(const qint32 &user_status) {
|
||||
this->user_status = user_status;
|
||||
this->m_user_status_isSet = true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
OAIUser::isSet() const {
|
||||
bool isObjectUpdated = false;
|
||||
do{
|
||||
if(m_id_isSet){ isObjectUpdated = true; break;}
|
||||
|
||||
if(m_username_isSet){ isObjectUpdated = true; break;}
|
||||
|
||||
if(m_first_name_isSet){ isObjectUpdated = true; break;}
|
||||
|
||||
if(m_last_name_isSet){ isObjectUpdated = true; break;}
|
||||
|
||||
if(m_email_isSet){ isObjectUpdated = true; break;}
|
||||
|
||||
if(m_password_isSet){ isObjectUpdated = true; break;}
|
||||
|
||||
if(m_phone_isSet){ isObjectUpdated = true; break;}
|
||||
|
||||
if(m_user_status_isSet){ isObjectUpdated = true; break;}
|
||||
}while(false);
|
||||
return isObjectUpdated;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* OpenAPI spec version: 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* OAIUser.h
|
||||
*
|
||||
* A User who is purchasing from the pet store
|
||||
*/
|
||||
|
||||
#ifndef OAIUser_H_
|
||||
#define OAIUser_H_
|
||||
|
||||
#include <QJsonObject>
|
||||
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "OAIObject.h"
|
||||
|
||||
namespace OpenAPI {
|
||||
|
||||
class OAIUser: public OAIObject {
|
||||
public:
|
||||
OAIUser();
|
||||
OAIUser(QString json);
|
||||
~OAIUser() override;
|
||||
void init();
|
||||
|
||||
QString asJson () const override;
|
||||
QJsonObject asJsonObject() const override;
|
||||
void fromJsonObject(QJsonObject json) override;
|
||||
void fromJson(QString jsonString) override;
|
||||
|
||||
qint64 getId();
|
||||
void setId(const qint64 &id);
|
||||
|
||||
QString getUsername();
|
||||
void setUsername(const QString &username);
|
||||
|
||||
QString getFirstName();
|
||||
void setFirstName(const QString &first_name);
|
||||
|
||||
QString getLastName();
|
||||
void setLastName(const QString &last_name);
|
||||
|
||||
QString getEmail();
|
||||
void setEmail(const QString &email);
|
||||
|
||||
QString getPassword();
|
||||
void setPassword(const QString &password);
|
||||
|
||||
QString getPhone();
|
||||
void setPhone(const QString &phone);
|
||||
|
||||
qint32 getUserStatus();
|
||||
void setUserStatus(const qint32 &user_status);
|
||||
|
||||
virtual bool isSet() const override;
|
||||
|
||||
private:
|
||||
qint64 id;
|
||||
bool m_id_isSet;
|
||||
|
||||
QString username;
|
||||
bool m_username_isSet;
|
||||
|
||||
QString first_name;
|
||||
bool m_first_name_isSet;
|
||||
|
||||
QString last_name;
|
||||
bool m_last_name_isSet;
|
||||
|
||||
QString email;
|
||||
bool m_email_isSet;
|
||||
|
||||
QString password;
|
||||
bool m_password_isSet;
|
||||
|
||||
QString phone;
|
||||
bool m_phone_isSet;
|
||||
|
||||
qint32 user_status;
|
||||
bool m_user_status_isSet;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* OAIUser_H_ */
|
||||
@@ -0,0 +1,304 @@
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* OpenAPI spec version: 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 <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QVariantMap>
|
||||
#include <QDebug>
|
||||
|
||||
#include "OAIHelpers.h"
|
||||
#include "OAIPetApiRequest.h"
|
||||
|
||||
namespace OpenAPI {
|
||||
|
||||
OAIPetApiRequest::OAIPetApiRequest(QHttpEngine::Socket *s, OAIPetApiHandler* hdl) : QObject(s), socket(s), handler(hdl) {
|
||||
}
|
||||
|
||||
OAIPetApiRequest::~OAIPetApiRequest(){
|
||||
disconnect(this, nullptr, nullptr, nullptr);
|
||||
qDebug() << "OAIPetApiRequest::~OAIPetApiRequest()";
|
||||
}
|
||||
|
||||
QMap<QString, QString>
|
||||
OAIPetApiRequest::getDefaultHeaders(){
|
||||
return defaultHeaders;
|
||||
}
|
||||
|
||||
QHttpEngine::Socket* OAIPetApiRequest::getRawSocket(){
|
||||
return socket;
|
||||
}
|
||||
|
||||
|
||||
void OAIPetApiRequest::addPetRequest(){
|
||||
qDebug() << "/v2/pet";
|
||||
connect(this, &OAIPetApiRequest::addPet, handler, &OAIPetApiHandler::addPet);
|
||||
|
||||
|
||||
|
||||
QJsonDocument doc;
|
||||
socket->readJson(doc);
|
||||
QJsonObject obj = doc.object();
|
||||
OAIPet oai_pet;
|
||||
::OpenAPI::fromJsonValue(oai_pet, obj);
|
||||
|
||||
|
||||
emit addPet( oai_pet);
|
||||
}
|
||||
|
||||
|
||||
void OAIPetApiRequest::deletePetRequest(QString pet_idstr){
|
||||
qDebug() << "/v2/pet/{petId}";
|
||||
connect(this, &OAIPetApiRequest::deletePet, handler, &OAIPetApiHandler::deletePet);
|
||||
|
||||
|
||||
qint64 pet_id;
|
||||
fromStringValue(pet_idstr, pet_id);
|
||||
|
||||
QString api_key;
|
||||
if(socket->headers().keys().contains("api_key")){
|
||||
fromStringValue(socket->queryString().value("api_key"), api_key);
|
||||
}
|
||||
|
||||
|
||||
emit deletePet( pet_id, api_key);
|
||||
}
|
||||
|
||||
|
||||
void OAIPetApiRequest::findPetsByStatusRequest(){
|
||||
qDebug() << "/v2/pet/findByStatus";
|
||||
connect(this, &OAIPetApiRequest::findPetsByStatus, handler, &OAIPetApiHandler::findPetsByStatus);
|
||||
|
||||
|
||||
QList<QString> status;
|
||||
if(socket->queryString().keys().contains("status")){
|
||||
fromStringValue(socket->queryString().values("status"), status);
|
||||
}
|
||||
|
||||
|
||||
|
||||
emit findPetsByStatus( status);
|
||||
}
|
||||
|
||||
|
||||
void OAIPetApiRequest::findPetsByTagsRequest(){
|
||||
qDebug() << "/v2/pet/findByTags";
|
||||
connect(this, &OAIPetApiRequest::findPetsByTags, handler, &OAIPetApiHandler::findPetsByTags);
|
||||
|
||||
|
||||
QList<QString> tags;
|
||||
if(socket->queryString().keys().contains("tags")){
|
||||
fromStringValue(socket->queryString().values("tags"), tags);
|
||||
}
|
||||
|
||||
|
||||
|
||||
emit findPetsByTags( tags);
|
||||
}
|
||||
|
||||
|
||||
void OAIPetApiRequest::getPetByIdRequest(QString pet_idstr){
|
||||
qDebug() << "/v2/pet/{petId}";
|
||||
connect(this, &OAIPetApiRequest::getPetById, handler, &OAIPetApiHandler::getPetById);
|
||||
|
||||
|
||||
qint64 pet_id;
|
||||
fromStringValue(pet_idstr, pet_id);
|
||||
|
||||
|
||||
emit getPetById( pet_id);
|
||||
}
|
||||
|
||||
|
||||
void OAIPetApiRequest::updatePetRequest(){
|
||||
qDebug() << "/v2/pet";
|
||||
connect(this, &OAIPetApiRequest::updatePet, handler, &OAIPetApiHandler::updatePet);
|
||||
|
||||
|
||||
|
||||
QJsonDocument doc;
|
||||
socket->readJson(doc);
|
||||
QJsonObject obj = doc.object();
|
||||
OAIPet oai_pet;
|
||||
::OpenAPI::fromJsonValue(oai_pet, obj);
|
||||
|
||||
|
||||
emit updatePet( oai_pet);
|
||||
}
|
||||
|
||||
|
||||
void OAIPetApiRequest::updatePetWithFormRequest(QString pet_idstr){
|
||||
qDebug() << "/v2/pet/{petId}";
|
||||
connect(this, &OAIPetApiRequest::updatePetWithForm, handler, &OAIPetApiHandler::updatePetWithForm);
|
||||
|
||||
|
||||
qint64 pet_id;
|
||||
fromStringValue(pet_idstr, pet_id);
|
||||
|
||||
QString name;
|
||||
QString status;
|
||||
|
||||
emit updatePetWithForm( pet_id, name, status);
|
||||
}
|
||||
|
||||
|
||||
void OAIPetApiRequest::uploadFileRequest(QString pet_idstr){
|
||||
qDebug() << "/v2/pet/{petId}/uploadImage";
|
||||
connect(this, &OAIPetApiRequest::uploadFile, handler, &OAIPetApiHandler::uploadFile);
|
||||
|
||||
|
||||
qint64 pet_id;
|
||||
fromStringValue(pet_idstr, pet_id);
|
||||
|
||||
QString additional_metadata;
|
||||
QIODevice* file;
|
||||
|
||||
emit uploadFile( pet_id, additional_metadata, file);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void OAIPetApiRequest::addPetResponse(){
|
||||
socket->setStatusCode(QHttpEngine::Socket::OK);
|
||||
if(socket->isOpen()){
|
||||
socket->writeHeaders();
|
||||
socket->close();
|
||||
}
|
||||
}
|
||||
void OAIPetApiRequest::deletePetResponse(){
|
||||
socket->setStatusCode(QHttpEngine::Socket::OK);
|
||||
if(socket->isOpen()){
|
||||
socket->writeHeaders();
|
||||
socket->close();
|
||||
}
|
||||
}
|
||||
void OAIPetApiRequest::findPetsByStatusResponse(QList<OAIPet> res){
|
||||
socket->setStatusCode(QHttpEngine::Socket::OK);
|
||||
if(socket->isOpen()){
|
||||
socket->writeHeaders();
|
||||
socket->close();
|
||||
}
|
||||
}
|
||||
void OAIPetApiRequest::findPetsByTagsResponse(QList<OAIPet> res){
|
||||
socket->setStatusCode(QHttpEngine::Socket::OK);
|
||||
if(socket->isOpen()){
|
||||
socket->writeHeaders();
|
||||
socket->close();
|
||||
}
|
||||
}
|
||||
void OAIPetApiRequest::getPetByIdResponse(OAIPet res){
|
||||
socket->setStatusCode(QHttpEngine::Socket::OK);
|
||||
if(socket->isOpen()){
|
||||
socket->writeHeaders();
|
||||
socket->close();
|
||||
}
|
||||
}
|
||||
void OAIPetApiRequest::updatePetResponse(){
|
||||
socket->setStatusCode(QHttpEngine::Socket::OK);
|
||||
if(socket->isOpen()){
|
||||
socket->writeHeaders();
|
||||
socket->close();
|
||||
}
|
||||
}
|
||||
void OAIPetApiRequest::updatePetWithFormResponse(){
|
||||
socket->setStatusCode(QHttpEngine::Socket::OK);
|
||||
if(socket->isOpen()){
|
||||
socket->writeHeaders();
|
||||
socket->close();
|
||||
}
|
||||
}
|
||||
void OAIPetApiRequest::uploadFileResponse(OAIApiResponse res){
|
||||
socket->setStatusCode(QHttpEngine::Socket::OK);
|
||||
if(socket->isOpen()){
|
||||
socket->writeHeaders();
|
||||
socket->close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void OAIPetApiRequest::addPetError(QNetworkReply::NetworkError error_type, QString& error_str){
|
||||
Q_UNUSED(error_type);
|
||||
Q_UNUSED(error_str);
|
||||
socket->setStatusCode(QHttpEngine::Socket::NotFound);
|
||||
if(socket->isOpen()){
|
||||
socket->writeHeaders();
|
||||
socket->close();
|
||||
}
|
||||
}
|
||||
void OAIPetApiRequest::deletePetError(QNetworkReply::NetworkError error_type, QString& error_str){
|
||||
Q_UNUSED(error_type);
|
||||
Q_UNUSED(error_str);
|
||||
socket->setStatusCode(QHttpEngine::Socket::NotFound);
|
||||
if(socket->isOpen()){
|
||||
socket->writeHeaders();
|
||||
socket->close();
|
||||
}
|
||||
}
|
||||
void OAIPetApiRequest::findPetsByStatusError(QList<OAIPet> res, QNetworkReply::NetworkError error_type, QString& error_str){
|
||||
Q_UNUSED(error_type);
|
||||
Q_UNUSED(error_str);
|
||||
socket->setStatusCode(QHttpEngine::Socket::NotFound);
|
||||
if(socket->isOpen()){
|
||||
socket->writeHeaders();
|
||||
socket->close();
|
||||
}
|
||||
}
|
||||
void OAIPetApiRequest::findPetsByTagsError(QList<OAIPet> res, QNetworkReply::NetworkError error_type, QString& error_str){
|
||||
Q_UNUSED(error_type);
|
||||
Q_UNUSED(error_str);
|
||||
socket->setStatusCode(QHttpEngine::Socket::NotFound);
|
||||
if(socket->isOpen()){
|
||||
socket->writeHeaders();
|
||||
socket->close();
|
||||
}
|
||||
}
|
||||
void OAIPetApiRequest::getPetByIdError(OAIPet res, QNetworkReply::NetworkError error_type, QString& error_str){
|
||||
Q_UNUSED(error_type);
|
||||
Q_UNUSED(error_str);
|
||||
socket->setStatusCode(QHttpEngine::Socket::NotFound);
|
||||
if(socket->isOpen()){
|
||||
socket->writeHeaders();
|
||||
socket->close();
|
||||
}
|
||||
}
|
||||
void OAIPetApiRequest::updatePetError(QNetworkReply::NetworkError error_type, QString& error_str){
|
||||
Q_UNUSED(error_type);
|
||||
Q_UNUSED(error_str);
|
||||
socket->setStatusCode(QHttpEngine::Socket::NotFound);
|
||||
if(socket->isOpen()){
|
||||
socket->writeHeaders();
|
||||
socket->close();
|
||||
}
|
||||
}
|
||||
void OAIPetApiRequest::updatePetWithFormError(QNetworkReply::NetworkError error_type, QString& error_str){
|
||||
Q_UNUSED(error_type);
|
||||
Q_UNUSED(error_str);
|
||||
socket->setStatusCode(QHttpEngine::Socket::NotFound);
|
||||
if(socket->isOpen()){
|
||||
socket->writeHeaders();
|
||||
socket->close();
|
||||
}
|
||||
}
|
||||
void OAIPetApiRequest::uploadFileError(OAIApiResponse res, QNetworkReply::NetworkError error_type, QString& error_str){
|
||||
Q_UNUSED(error_type);
|
||||
Q_UNUSED(error_str);
|
||||
socket->setStatusCode(QHttpEngine::Socket::NotFound);
|
||||
if(socket->isOpen()){
|
||||
socket->writeHeaders();
|
||||
socket->close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* OpenAPI spec version: 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.
|
||||
*/
|
||||
|
||||
#ifndef _OAI_OAIPetApiRequest_H_
|
||||
#define _OAI_OAIPetApiRequest_H_
|
||||
|
||||
#include <QObject>
|
||||
#include <QStringList>
|
||||
#include <QNetworkReply>
|
||||
#include <QSharedPointer>
|
||||
|
||||
#include <qhttpengine/socket.h>
|
||||
#include "OAIApiResponse.h"
|
||||
#include "OAIPet.h"
|
||||
#include <QIODevice>
|
||||
#include <QString>
|
||||
#include "OAIPetApiHandler.h"
|
||||
|
||||
namespace OpenAPI {
|
||||
|
||||
class OAIPetApiRequest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
OAIPetApiRequest(QHttpEngine::Socket *s, OAIPetApiHandler* handler);
|
||||
virtual ~OAIPetApiRequest();
|
||||
|
||||
void addPetRequest();
|
||||
void deletePetRequest(QString pet_id);
|
||||
void findPetsByStatusRequest();
|
||||
void findPetsByTagsRequest();
|
||||
void getPetByIdRequest(QString pet_id);
|
||||
void updatePetRequest();
|
||||
void updatePetWithFormRequest(QString pet_id);
|
||||
void uploadFileRequest(QString pet_id);
|
||||
|
||||
|
||||
void addPetResponse();
|
||||
void deletePetResponse();
|
||||
void findPetsByStatusResponse(QList<OAIPet> res);
|
||||
void findPetsByTagsResponse(QList<OAIPet> res);
|
||||
void getPetByIdResponse(OAIPet res);
|
||||
void updatePetResponse();
|
||||
void updatePetWithFormResponse();
|
||||
void uploadFileResponse(OAIApiResponse res);
|
||||
|
||||
|
||||
void addPetError(QNetworkReply::NetworkError error_type, QString& error_str);
|
||||
void deletePetError(QNetworkReply::NetworkError error_type, QString& error_str);
|
||||
void findPetsByStatusError(QList<OAIPet> res, QNetworkReply::NetworkError error_type, QString& error_str);
|
||||
void findPetsByTagsError(QList<OAIPet> res, QNetworkReply::NetworkError error_type, QString& error_str);
|
||||
void getPetByIdError(OAIPet res, QNetworkReply::NetworkError error_type, QString& error_str);
|
||||
void updatePetError(QNetworkReply::NetworkError error_type, QString& error_str);
|
||||
void updatePetWithFormError(QNetworkReply::NetworkError error_type, QString& error_str);
|
||||
void uploadFileError(OAIApiResponse res, QNetworkReply::NetworkError error_type, QString& error_str);
|
||||
|
||||
|
||||
QMap<QString, QString> getDefaultHeaders();
|
||||
QHttpEngine::Socket* getRawSocket();
|
||||
|
||||
signals:
|
||||
void addPet(OAIPet oai_pet);
|
||||
void deletePet(qint64 pet_id, QString api_key);
|
||||
void findPetsByStatus(QList<QString> status);
|
||||
void findPetsByTags(QList<QString> tags);
|
||||
void getPetById(qint64 pet_id);
|
||||
void updatePet(OAIPet oai_pet);
|
||||
void updatePetWithForm(qint64 pet_id, QString name, QString status);
|
||||
void uploadFile(qint64 pet_id, QString additional_metadata, QIODevice* file);
|
||||
|
||||
|
||||
private:
|
||||
QMap<QString, QString> defaultHeaders;
|
||||
QHttpEngine::Socket *socket;
|
||||
OAIPetApiHandler *handler;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // _OAI_OAIPetApiRequest_H_
|
||||
@@ -0,0 +1,167 @@
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* OpenAPI spec version: 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 <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QVariantMap>
|
||||
#include <QDebug>
|
||||
|
||||
#include "OAIHelpers.h"
|
||||
#include "OAIStoreApiRequest.h"
|
||||
|
||||
namespace OpenAPI {
|
||||
|
||||
OAIStoreApiRequest::OAIStoreApiRequest(QHttpEngine::Socket *s, OAIStoreApiHandler* hdl) : QObject(s), socket(s), handler(hdl) {
|
||||
}
|
||||
|
||||
OAIStoreApiRequest::~OAIStoreApiRequest(){
|
||||
disconnect(this, nullptr, nullptr, nullptr);
|
||||
qDebug() << "OAIStoreApiRequest::~OAIStoreApiRequest()";
|
||||
}
|
||||
|
||||
QMap<QString, QString>
|
||||
OAIStoreApiRequest::getDefaultHeaders(){
|
||||
return defaultHeaders;
|
||||
}
|
||||
|
||||
QHttpEngine::Socket* OAIStoreApiRequest::getRawSocket(){
|
||||
return socket;
|
||||
}
|
||||
|
||||
|
||||
void OAIStoreApiRequest::deleteOrderRequest(QString order_idstr){
|
||||
qDebug() << "/v2/store/order/{orderId}";
|
||||
connect(this, &OAIStoreApiRequest::deleteOrder, handler, &OAIStoreApiHandler::deleteOrder);
|
||||
|
||||
|
||||
QString order_id;
|
||||
fromStringValue(order_idstr, order_id);
|
||||
|
||||
|
||||
emit deleteOrder( order_id);
|
||||
}
|
||||
|
||||
|
||||
void OAIStoreApiRequest::getInventoryRequest(){
|
||||
qDebug() << "/v2/store/inventory";
|
||||
connect(this, &OAIStoreApiRequest::getInventory, handler, &OAIStoreApiHandler::getInventory);
|
||||
|
||||
|
||||
|
||||
|
||||
emit getInventory();
|
||||
}
|
||||
|
||||
|
||||
void OAIStoreApiRequest::getOrderByIdRequest(QString order_idstr){
|
||||
qDebug() << "/v2/store/order/{orderId}";
|
||||
connect(this, &OAIStoreApiRequest::getOrderById, handler, &OAIStoreApiHandler::getOrderById);
|
||||
|
||||
|
||||
qint64 order_id;
|
||||
fromStringValue(order_idstr, order_id);
|
||||
|
||||
|
||||
emit getOrderById( order_id);
|
||||
}
|
||||
|
||||
|
||||
void OAIStoreApiRequest::placeOrderRequest(){
|
||||
qDebug() << "/v2/store/order";
|
||||
connect(this, &OAIStoreApiRequest::placeOrder, handler, &OAIStoreApiHandler::placeOrder);
|
||||
|
||||
|
||||
|
||||
QJsonDocument doc;
|
||||
socket->readJson(doc);
|
||||
QJsonObject obj = doc.object();
|
||||
OAIOrder oai_order;
|
||||
::OpenAPI::fromJsonValue(oai_order, obj);
|
||||
|
||||
|
||||
emit placeOrder( oai_order);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void OAIStoreApiRequest::deleteOrderResponse(){
|
||||
socket->setStatusCode(QHttpEngine::Socket::OK);
|
||||
if(socket->isOpen()){
|
||||
socket->writeHeaders();
|
||||
socket->close();
|
||||
}
|
||||
}
|
||||
void OAIStoreApiRequest::getInventoryResponse(QMap<QString, qint32> res){
|
||||
socket->setStatusCode(QHttpEngine::Socket::OK);
|
||||
if(socket->isOpen()){
|
||||
socket->writeHeaders();
|
||||
socket->close();
|
||||
}
|
||||
}
|
||||
void OAIStoreApiRequest::getOrderByIdResponse(OAIOrder res){
|
||||
socket->setStatusCode(QHttpEngine::Socket::OK);
|
||||
if(socket->isOpen()){
|
||||
socket->writeHeaders();
|
||||
socket->close();
|
||||
}
|
||||
}
|
||||
void OAIStoreApiRequest::placeOrderResponse(OAIOrder res){
|
||||
socket->setStatusCode(QHttpEngine::Socket::OK);
|
||||
if(socket->isOpen()){
|
||||
socket->writeHeaders();
|
||||
socket->close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void OAIStoreApiRequest::deleteOrderError(QNetworkReply::NetworkError error_type, QString& error_str){
|
||||
Q_UNUSED(error_type);
|
||||
Q_UNUSED(error_str);
|
||||
socket->setStatusCode(QHttpEngine::Socket::NotFound);
|
||||
if(socket->isOpen()){
|
||||
socket->writeHeaders();
|
||||
socket->close();
|
||||
}
|
||||
}
|
||||
void OAIStoreApiRequest::getInventoryError(QMap<QString, qint32> res, QNetworkReply::NetworkError error_type, QString& error_str){
|
||||
Q_UNUSED(error_type);
|
||||
Q_UNUSED(error_str);
|
||||
socket->setStatusCode(QHttpEngine::Socket::NotFound);
|
||||
if(socket->isOpen()){
|
||||
socket->writeHeaders();
|
||||
socket->close();
|
||||
}
|
||||
}
|
||||
void OAIStoreApiRequest::getOrderByIdError(OAIOrder res, QNetworkReply::NetworkError error_type, QString& error_str){
|
||||
Q_UNUSED(error_type);
|
||||
Q_UNUSED(error_str);
|
||||
socket->setStatusCode(QHttpEngine::Socket::NotFound);
|
||||
if(socket->isOpen()){
|
||||
socket->writeHeaders();
|
||||
socket->close();
|
||||
}
|
||||
}
|
||||
void OAIStoreApiRequest::placeOrderError(OAIOrder res, QNetworkReply::NetworkError error_type, QString& error_str){
|
||||
Q_UNUSED(error_type);
|
||||
Q_UNUSED(error_str);
|
||||
socket->setStatusCode(QHttpEngine::Socket::NotFound);
|
||||
if(socket->isOpen()){
|
||||
socket->writeHeaders();
|
||||
socket->close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* OpenAPI spec version: 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.
|
||||
*/
|
||||
|
||||
#ifndef _OAI_OAIStoreApiRequest_H_
|
||||
#define _OAI_OAIStoreApiRequest_H_
|
||||
|
||||
#include <QObject>
|
||||
#include <QStringList>
|
||||
#include <QNetworkReply>
|
||||
#include <QSharedPointer>
|
||||
|
||||
#include <qhttpengine/socket.h>
|
||||
#include "OAIOrder.h"
|
||||
#include <QMap>
|
||||
#include <QString>
|
||||
#include "OAIStoreApiHandler.h"
|
||||
|
||||
namespace OpenAPI {
|
||||
|
||||
class OAIStoreApiRequest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
OAIStoreApiRequest(QHttpEngine::Socket *s, OAIStoreApiHandler* handler);
|
||||
virtual ~OAIStoreApiRequest();
|
||||
|
||||
void deleteOrderRequest(QString order_id);
|
||||
void getInventoryRequest();
|
||||
void getOrderByIdRequest(QString order_id);
|
||||
void placeOrderRequest();
|
||||
|
||||
|
||||
void deleteOrderResponse();
|
||||
void getInventoryResponse(QMap<QString, qint32> res);
|
||||
void getOrderByIdResponse(OAIOrder res);
|
||||
void placeOrderResponse(OAIOrder res);
|
||||
|
||||
|
||||
void deleteOrderError(QNetworkReply::NetworkError error_type, QString& error_str);
|
||||
void getInventoryError(QMap<QString, qint32> res, QNetworkReply::NetworkError error_type, QString& error_str);
|
||||
void getOrderByIdError(OAIOrder res, QNetworkReply::NetworkError error_type, QString& error_str);
|
||||
void placeOrderError(OAIOrder res, QNetworkReply::NetworkError error_type, QString& error_str);
|
||||
|
||||
|
||||
QMap<QString, QString> getDefaultHeaders();
|
||||
QHttpEngine::Socket* getRawSocket();
|
||||
|
||||
signals:
|
||||
void deleteOrder(QString order_id);
|
||||
void getInventory();
|
||||
void getOrderById(qint64 order_id);
|
||||
void placeOrder(OAIOrder oai_order);
|
||||
|
||||
|
||||
private:
|
||||
QMap<QString, QString> defaultHeaders;
|
||||
QHttpEngine::Socket *socket;
|
||||
OAIStoreApiHandler *handler;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // _OAI_OAIStoreApiRequest_H_
|
||||
@@ -0,0 +1,315 @@
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* OpenAPI spec version: 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 <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QVariantMap>
|
||||
#include <QDebug>
|
||||
|
||||
#include "OAIHelpers.h"
|
||||
#include "OAIUserApiRequest.h"
|
||||
|
||||
namespace OpenAPI {
|
||||
|
||||
OAIUserApiRequest::OAIUserApiRequest(QHttpEngine::Socket *s, OAIUserApiHandler* hdl) : QObject(s), socket(s), handler(hdl) {
|
||||
}
|
||||
|
||||
OAIUserApiRequest::~OAIUserApiRequest(){
|
||||
disconnect(this, nullptr, nullptr, nullptr);
|
||||
qDebug() << "OAIUserApiRequest::~OAIUserApiRequest()";
|
||||
}
|
||||
|
||||
QMap<QString, QString>
|
||||
OAIUserApiRequest::getDefaultHeaders(){
|
||||
return defaultHeaders;
|
||||
}
|
||||
|
||||
QHttpEngine::Socket* OAIUserApiRequest::getRawSocket(){
|
||||
return socket;
|
||||
}
|
||||
|
||||
|
||||
void OAIUserApiRequest::createUserRequest(){
|
||||
qDebug() << "/v2/user";
|
||||
connect(this, &OAIUserApiRequest::createUser, handler, &OAIUserApiHandler::createUser);
|
||||
|
||||
|
||||
|
||||
QJsonDocument doc;
|
||||
socket->readJson(doc);
|
||||
QJsonObject obj = doc.object();
|
||||
OAIUser oai_user;
|
||||
::OpenAPI::fromJsonValue(oai_user, obj);
|
||||
|
||||
|
||||
emit createUser( oai_user);
|
||||
}
|
||||
|
||||
|
||||
void OAIUserApiRequest::createUsersWithArrayInputRequest(){
|
||||
qDebug() << "/v2/user/createWithArray";
|
||||
connect(this, &OAIUserApiRequest::createUsersWithArrayInput, handler, &OAIUserApiHandler::createUsersWithArrayInput);
|
||||
|
||||
|
||||
|
||||
QJsonDocument doc;
|
||||
QList<OAIUser> oai_user;
|
||||
if(socket->readJson(doc)){
|
||||
QJsonArray jsonArray = doc.array();
|
||||
foreach(QJsonValue obj, jsonArray) {
|
||||
OAIUser o;
|
||||
::OpenAPI::fromJsonValue(o, obj);
|
||||
oai_user.append(o);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
emit createUsersWithArrayInput( oai_user);
|
||||
}
|
||||
|
||||
|
||||
void OAIUserApiRequest::createUsersWithListInputRequest(){
|
||||
qDebug() << "/v2/user/createWithList";
|
||||
connect(this, &OAIUserApiRequest::createUsersWithListInput, handler, &OAIUserApiHandler::createUsersWithListInput);
|
||||
|
||||
|
||||
|
||||
QJsonDocument doc;
|
||||
QList<OAIUser> oai_user;
|
||||
if(socket->readJson(doc)){
|
||||
QJsonArray jsonArray = doc.array();
|
||||
foreach(QJsonValue obj, jsonArray) {
|
||||
OAIUser o;
|
||||
::OpenAPI::fromJsonValue(o, obj);
|
||||
oai_user.append(o);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
emit createUsersWithListInput( oai_user);
|
||||
}
|
||||
|
||||
|
||||
void OAIUserApiRequest::deleteUserRequest(QString usernamestr){
|
||||
qDebug() << "/v2/user/{username}";
|
||||
connect(this, &OAIUserApiRequest::deleteUser, handler, &OAIUserApiHandler::deleteUser);
|
||||
|
||||
|
||||
QString username;
|
||||
fromStringValue(usernamestr, username);
|
||||
|
||||
|
||||
emit deleteUser( username);
|
||||
}
|
||||
|
||||
|
||||
void OAIUserApiRequest::getUserByNameRequest(QString usernamestr){
|
||||
qDebug() << "/v2/user/{username}";
|
||||
connect(this, &OAIUserApiRequest::getUserByName, handler, &OAIUserApiHandler::getUserByName);
|
||||
|
||||
|
||||
QString username;
|
||||
fromStringValue(usernamestr, username);
|
||||
|
||||
|
||||
emit getUserByName( username);
|
||||
}
|
||||
|
||||
|
||||
void OAIUserApiRequest::loginUserRequest(){
|
||||
qDebug() << "/v2/user/login";
|
||||
connect(this, &OAIUserApiRequest::loginUser, handler, &OAIUserApiHandler::loginUser);
|
||||
|
||||
|
||||
QString username;
|
||||
if(socket->queryString().keys().contains("username")){
|
||||
fromStringValue(socket->queryString().value("username"), username);
|
||||
}
|
||||
|
||||
QString password;
|
||||
if(socket->queryString().keys().contains("password")){
|
||||
fromStringValue(socket->queryString().value("password"), password);
|
||||
}
|
||||
|
||||
|
||||
|
||||
emit loginUser( username, password);
|
||||
}
|
||||
|
||||
|
||||
void OAIUserApiRequest::logoutUserRequest(){
|
||||
qDebug() << "/v2/user/logout";
|
||||
connect(this, &OAIUserApiRequest::logoutUser, handler, &OAIUserApiHandler::logoutUser);
|
||||
|
||||
|
||||
|
||||
|
||||
emit logoutUser();
|
||||
}
|
||||
|
||||
|
||||
void OAIUserApiRequest::updateUserRequest(QString usernamestr){
|
||||
qDebug() << "/v2/user/{username}";
|
||||
connect(this, &OAIUserApiRequest::updateUser, handler, &OAIUserApiHandler::updateUser);
|
||||
|
||||
|
||||
QString username;
|
||||
fromStringValue(usernamestr, username);
|
||||
|
||||
QJsonDocument doc;
|
||||
socket->readJson(doc);
|
||||
QJsonObject obj = doc.object();
|
||||
OAIUser oai_user;
|
||||
::OpenAPI::fromJsonValue(oai_user, obj);
|
||||
|
||||
|
||||
emit updateUser( username, oai_user);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void OAIUserApiRequest::createUserResponse(){
|
||||
socket->setStatusCode(QHttpEngine::Socket::OK);
|
||||
if(socket->isOpen()){
|
||||
socket->writeHeaders();
|
||||
socket->close();
|
||||
}
|
||||
}
|
||||
void OAIUserApiRequest::createUsersWithArrayInputResponse(){
|
||||
socket->setStatusCode(QHttpEngine::Socket::OK);
|
||||
if(socket->isOpen()){
|
||||
socket->writeHeaders();
|
||||
socket->close();
|
||||
}
|
||||
}
|
||||
void OAIUserApiRequest::createUsersWithListInputResponse(){
|
||||
socket->setStatusCode(QHttpEngine::Socket::OK);
|
||||
if(socket->isOpen()){
|
||||
socket->writeHeaders();
|
||||
socket->close();
|
||||
}
|
||||
}
|
||||
void OAIUserApiRequest::deleteUserResponse(){
|
||||
socket->setStatusCode(QHttpEngine::Socket::OK);
|
||||
if(socket->isOpen()){
|
||||
socket->writeHeaders();
|
||||
socket->close();
|
||||
}
|
||||
}
|
||||
void OAIUserApiRequest::getUserByNameResponse(OAIUser res){
|
||||
socket->setStatusCode(QHttpEngine::Socket::OK);
|
||||
if(socket->isOpen()){
|
||||
socket->writeHeaders();
|
||||
socket->close();
|
||||
}
|
||||
}
|
||||
void OAIUserApiRequest::loginUserResponse(QString res){
|
||||
socket->setStatusCode(QHttpEngine::Socket::OK);
|
||||
if(socket->isOpen()){
|
||||
socket->writeHeaders();
|
||||
socket->close();
|
||||
}
|
||||
}
|
||||
void OAIUserApiRequest::logoutUserResponse(){
|
||||
socket->setStatusCode(QHttpEngine::Socket::OK);
|
||||
if(socket->isOpen()){
|
||||
socket->writeHeaders();
|
||||
socket->close();
|
||||
}
|
||||
}
|
||||
void OAIUserApiRequest::updateUserResponse(){
|
||||
socket->setStatusCode(QHttpEngine::Socket::OK);
|
||||
if(socket->isOpen()){
|
||||
socket->writeHeaders();
|
||||
socket->close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void OAIUserApiRequest::createUserError(QNetworkReply::NetworkError error_type, QString& error_str){
|
||||
Q_UNUSED(error_type);
|
||||
Q_UNUSED(error_str);
|
||||
socket->setStatusCode(QHttpEngine::Socket::NotFound);
|
||||
if(socket->isOpen()){
|
||||
socket->writeHeaders();
|
||||
socket->close();
|
||||
}
|
||||
}
|
||||
void OAIUserApiRequest::createUsersWithArrayInputError(QNetworkReply::NetworkError error_type, QString& error_str){
|
||||
Q_UNUSED(error_type);
|
||||
Q_UNUSED(error_str);
|
||||
socket->setStatusCode(QHttpEngine::Socket::NotFound);
|
||||
if(socket->isOpen()){
|
||||
socket->writeHeaders();
|
||||
socket->close();
|
||||
}
|
||||
}
|
||||
void OAIUserApiRequest::createUsersWithListInputError(QNetworkReply::NetworkError error_type, QString& error_str){
|
||||
Q_UNUSED(error_type);
|
||||
Q_UNUSED(error_str);
|
||||
socket->setStatusCode(QHttpEngine::Socket::NotFound);
|
||||
if(socket->isOpen()){
|
||||
socket->writeHeaders();
|
||||
socket->close();
|
||||
}
|
||||
}
|
||||
void OAIUserApiRequest::deleteUserError(QNetworkReply::NetworkError error_type, QString& error_str){
|
||||
Q_UNUSED(error_type);
|
||||
Q_UNUSED(error_str);
|
||||
socket->setStatusCode(QHttpEngine::Socket::NotFound);
|
||||
if(socket->isOpen()){
|
||||
socket->writeHeaders();
|
||||
socket->close();
|
||||
}
|
||||
}
|
||||
void OAIUserApiRequest::getUserByNameError(OAIUser res, QNetworkReply::NetworkError error_type, QString& error_str){
|
||||
Q_UNUSED(error_type);
|
||||
Q_UNUSED(error_str);
|
||||
socket->setStatusCode(QHttpEngine::Socket::NotFound);
|
||||
if(socket->isOpen()){
|
||||
socket->writeHeaders();
|
||||
socket->close();
|
||||
}
|
||||
}
|
||||
void OAIUserApiRequest::loginUserError(QString res, QNetworkReply::NetworkError error_type, QString& error_str){
|
||||
Q_UNUSED(error_type);
|
||||
Q_UNUSED(error_str);
|
||||
socket->setStatusCode(QHttpEngine::Socket::NotFound);
|
||||
if(socket->isOpen()){
|
||||
socket->writeHeaders();
|
||||
socket->close();
|
||||
}
|
||||
}
|
||||
void OAIUserApiRequest::logoutUserError(QNetworkReply::NetworkError error_type, QString& error_str){
|
||||
Q_UNUSED(error_type);
|
||||
Q_UNUSED(error_str);
|
||||
socket->setStatusCode(QHttpEngine::Socket::NotFound);
|
||||
if(socket->isOpen()){
|
||||
socket->writeHeaders();
|
||||
socket->close();
|
||||
}
|
||||
}
|
||||
void OAIUserApiRequest::updateUserError(QNetworkReply::NetworkError error_type, QString& error_str){
|
||||
Q_UNUSED(error_type);
|
||||
Q_UNUSED(error_str);
|
||||
socket->setStatusCode(QHttpEngine::Socket::NotFound);
|
||||
if(socket->isOpen()){
|
||||
socket->writeHeaders();
|
||||
socket->close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* OpenAPI spec version: 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.
|
||||
*/
|
||||
|
||||
#ifndef _OAI_OAIUserApiRequest_H_
|
||||
#define _OAI_OAIUserApiRequest_H_
|
||||
|
||||
#include <QObject>
|
||||
#include <QStringList>
|
||||
#include <QNetworkReply>
|
||||
#include <QSharedPointer>
|
||||
|
||||
#include <qhttpengine/socket.h>
|
||||
#include "OAIUser.h"
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
#include "OAIUserApiHandler.h"
|
||||
|
||||
namespace OpenAPI {
|
||||
|
||||
class OAIUserApiRequest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
OAIUserApiRequest(QHttpEngine::Socket *s, OAIUserApiHandler* handler);
|
||||
virtual ~OAIUserApiRequest();
|
||||
|
||||
void createUserRequest();
|
||||
void createUsersWithArrayInputRequest();
|
||||
void createUsersWithListInputRequest();
|
||||
void deleteUserRequest(QString username);
|
||||
void getUserByNameRequest(QString username);
|
||||
void loginUserRequest();
|
||||
void logoutUserRequest();
|
||||
void updateUserRequest(QString username);
|
||||
|
||||
|
||||
void createUserResponse();
|
||||
void createUsersWithArrayInputResponse();
|
||||
void createUsersWithListInputResponse();
|
||||
void deleteUserResponse();
|
||||
void getUserByNameResponse(OAIUser res);
|
||||
void loginUserResponse(QString res);
|
||||
void logoutUserResponse();
|
||||
void updateUserResponse();
|
||||
|
||||
|
||||
void createUserError(QNetworkReply::NetworkError error_type, QString& error_str);
|
||||
void createUsersWithArrayInputError(QNetworkReply::NetworkError error_type, QString& error_str);
|
||||
void createUsersWithListInputError(QNetworkReply::NetworkError error_type, QString& error_str);
|
||||
void deleteUserError(QNetworkReply::NetworkError error_type, QString& error_str);
|
||||
void getUserByNameError(OAIUser res, QNetworkReply::NetworkError error_type, QString& error_str);
|
||||
void loginUserError(QString res, QNetworkReply::NetworkError error_type, QString& error_str);
|
||||
void logoutUserError(QNetworkReply::NetworkError error_type, QString& error_str);
|
||||
void updateUserError(QNetworkReply::NetworkError error_type, QString& error_str);
|
||||
|
||||
|
||||
QMap<QString, QString> getDefaultHeaders();
|
||||
QHttpEngine::Socket* getRawSocket();
|
||||
|
||||
signals:
|
||||
void createUser(OAIUser oai_user);
|
||||
void createUsersWithArrayInput(QList<OAIUser> oai_user);
|
||||
void createUsersWithListInput(QList<OAIUser> oai_user);
|
||||
void deleteUser(QString username);
|
||||
void getUserByName(QString username);
|
||||
void loginUser(QString username, QString password);
|
||||
void logoutUser();
|
||||
void updateUser(QString username, OAIUser oai_user);
|
||||
|
||||
|
||||
private:
|
||||
QMap<QString, QString> defaultHeaders;
|
||||
QHttpEngine::Socket *socket;
|
||||
OAIUserApiHandler *handler;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // _OAI_OAIUserApiRequest_H_
|
||||
Reference in New Issue
Block a user