[Qt5 Server] Add Support for Qt5 server using QHttpEngine (#322)

* Initial wiring to get the QHttpEngine Server running for Qt5 server

* Add wiring for build environment

* Add current generated files

* Update README.md

* Solved Build for Docker and Host
Wired up main
TODO : Route API call to handlers

* Wire up routes

* Wiring up routes update

* Convert Path to QHttpEngine format

* Rename some files

* Extract query Parameters and path parameters

* Removed pri file, Qt can read CMakeLists.txt

* Initial support of deserialization

* Adding initial support for response serialization

* Setup simple signal handler to quite the server with Ctrl+C in a container and on the host

* Remove unneeded function

* Add executable permission to script and move from Debian to Alpine for Dockerfile

* Add stringValue of missing types

* Unify toJson'xxx' APIs the same way like setValue

* Rework to remove all pointer usages, pass by const references, simplify model, add emit signals to default handlers
This commit is contained in:
sunn
2018-07-26 12:30:13 +02:00
committed by William Cheng
parent 77df3d6770
commit 65bad61abb
58 changed files with 5934 additions and 0 deletions

32
bin/cpp-qt5-server-petstore.sh Executable file
View File

@@ -0,0 +1,32 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn -B clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/cpp-qt5-server -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g cpp-qt5-server -o samples/server/petstore/cpp-qt5-server $@"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -0,0 +1,478 @@
/*
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
* Copyright 2018 SmartBear Software
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openapitools.codegen.languages;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.utils.ModelUtils;
import io.swagger.v3.oas.models.media.*;
import io.swagger.v3.parser.util.SchemaTypeUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
public class CppQt5ServerCodegen extends AbstractCppCodegen implements CodegenConfig {
private static final Logger LOGGER = LoggerFactory.getLogger(CppQt5ServerCodegen.class);
public static final String CPP_NAMESPACE = "cppNamespace";
public static final String CPP_NAMESPACE_DESC = "C++ namespace (convention: name::space::for::api).";
protected final String PREFIX = "OAI";
protected final String SRC_DIR = "/src";
protected final String MODEL_DIR = "/src/models";
protected final String APIHANDLER_DIR = "/src/handlers";
protected final String APIREQUEST_DIR = "/src/requests";
protected Set<String> foundationClasses = new HashSet<String>();
// source folder where to write the files
protected String sourceFolder = "server";
protected String apiVersion = "1.0.0";
protected Map<String, String> namespaces = new HashMap<String, String>();
protected Set<String> systemIncludes = new HashSet<String>();
protected String cppNamespace = "OpenAPI";
public CppQt5ServerCodegen() {
super();
// set the output folder here
outputFolder = "generated-code/cpp-qt5-server";
// set modelNamePrefix as default for QT5CPP
if (StringUtils.isEmpty(modelNamePrefix)) {
modelNamePrefix = PREFIX;
}
/*
* Models. You can write model files using the modelTemplateFiles map.
* if you want to create one template for file, you can do so here.
* for multiple files for model, just put another entry in the `modelTemplateFiles` with
* a different extension
*/
modelTemplateFiles.put(
"model-header.mustache",
".h");
modelTemplateFiles.put(
"model-body.mustache",
".cpp");
/*
* Api classes. You can write classes for each Api file with the apiTemplateFiles map.
* as with models, add multiple entries with different extensions for multiple files per
* class
*/
apiTemplateFiles.put(
"apihandler.h.mustache", // the template to use
".h"); // the extension for each file to write
apiTemplateFiles.put(
"apihandler.cpp.mustache", // the template to use
".cpp"); // the extension for each file to write
apiTemplateFiles.put(
"apirequest.h.mustache", // the template to use
".h"); // the extension for each file to write
apiTemplateFiles.put(
"apirequest.cpp.mustache", // the template to use
".cpp"); // the extension for each file to write
/*
* Template Location. This is the location which templates will be read from. The generator
* will use the resource stream to attempt to read the templates.
*/
embeddedTemplateDir = templateDir = "cpp-qt5-server";
// CLI options
addOption(CPP_NAMESPACE, CPP_NAMESPACE_DESC, this.cppNamespace);
/*
* Additional Properties. These values can be passed to the templates and
* are available in models, apis, and supporting files
*/
additionalProperties.put("apiVersion", apiVersion);
additionalProperties().put("prefix", PREFIX);
// Write defaults namespace in properties so that it can be accessible in templates.
// At this point command line has not been parsed so if value is given
// in command line it will superseed this content
additionalProperties.put("cppNamespace", cppNamespace);
/*
* Language Specific Primitives. These types will not trigger imports by
* the client generator
*/
languageSpecificPrimitives = new HashSet<String>(
Arrays.asList(
"bool",
"qint32",
"qint64",
"float",
"double")
);
supportingFiles.add(new SupportingFile("helpers-header.mustache", sourceFolder + MODEL_DIR, PREFIX + "Helpers.h"));
supportingFiles.add(new SupportingFile("helpers-body.mustache", sourceFolder + MODEL_DIR, PREFIX + "Helpers.cpp"));
supportingFiles.add(new SupportingFile("object.mustache", sourceFolder + MODEL_DIR, PREFIX + "Object.h"));
supportingFiles.add(new SupportingFile("apirouter.h.mustache", sourceFolder + APIHANDLER_DIR, PREFIX + "ApiRouter.h"));
supportingFiles.add(new SupportingFile("apirouter.cpp.mustache", sourceFolder + APIHANDLER_DIR, PREFIX + "ApiRouter.cpp"));
supportingFiles.add(new SupportingFile("main.cpp.mustache", sourceFolder + SRC_DIR, "main.cpp"));
supportingFiles.add(new SupportingFile("src-CMakeLists.txt.mustache", sourceFolder + SRC_DIR, "CMakeLists.txt"));
supportingFiles.add(new SupportingFile("README.md.mustache", sourceFolder, "README.MD"));
supportingFiles.add(new SupportingFile("Makefile.mustache", sourceFolder, "Makefile"));
supportingFiles.add(new SupportingFile("CMakeLists.txt.mustache", sourceFolder, "CMakeLists.txt"));
supportingFiles.add(new SupportingFile("Dockerfile.mustache", sourceFolder, "Dockerfile"));
supportingFiles.add(new SupportingFile("LICENSE.txt.mustache", sourceFolder, "LICENSE.txt"));
super.typeMapping = new HashMap<String, String>();
typeMapping.put("date", "QDate");
typeMapping.put("DateTime", "QDateTime");
typeMapping.put("string", "QString");
typeMapping.put("integer", "qint32");
typeMapping.put("long", "qint64");
typeMapping.put("boolean", "bool");
typeMapping.put("array", "QList");
typeMapping.put("map", "QMap");
typeMapping.put("object", PREFIX + "Object");
// mapped as "file" type for OAS 3.0
typeMapping.put("ByteArray", "QByteArray");
// UUID support - possible enhancement : use QUuid instead of QString.
// beware though that Serialisation/deserialisation of QUuid does not
// come out of the box and will need to be sorted out (at least imply
// modifications on multiple templates)
typeMapping.put("UUID", "QString");
typeMapping.put("file", "QIODevice");
typeMapping.put("binary", "QIODevice");
importMapping = new HashMap<String, String>();
namespaces = new HashMap<String, String>();
foundationClasses.add("QString");
systemIncludes.add("QString");
systemIncludes.add("QList");
systemIncludes.add("QMap");
systemIncludes.add("QDate");
systemIncludes.add("QDateTime");
systemIncludes.add("QByteArray");
systemIncludes.add("QIODevice");
}
@Override
public void processOpts() {
super.processOpts();
if (additionalProperties.containsKey("cppNamespace")) {
cppNamespace = (String) additionalProperties.get("cppNamespace");
}
additionalProperties.put("cppNamespaceDeclarations", cppNamespace.split("\\::"));
if (additionalProperties.containsKey("modelNamePrefix")) {
supportingFiles.clear();
supportingFiles.add(new SupportingFile("helpers-header.mustache", sourceFolder + MODEL_DIR, modelNamePrefix + "Helpers.h"));
supportingFiles.add(new SupportingFile("helpers-body.mustache", sourceFolder + MODEL_DIR, modelNamePrefix + "Helpers.cpp"));
supportingFiles.add(new SupportingFile("object.mustache", sourceFolder + MODEL_DIR, modelNamePrefix + "Object.h"));
supportingFiles.add(new SupportingFile("apirouter.h.mustache", sourceFolder + APIHANDLER_DIR, modelNamePrefix + "ApiRouter.h"));
supportingFiles.add(new SupportingFile("apirouter.cpp.mustache", sourceFolder + APIHANDLER_DIR, modelNamePrefix + "ApiRouter.cpp"));
supportingFiles.add(new SupportingFile("main.cpp.mustache", sourceFolder + SRC_DIR, "main.cpp"));
supportingFiles.add(new SupportingFile("src-CMakeLists.txt.mustache", sourceFolder + SRC_DIR, "CMakeLists.txt"));
supportingFiles.add(new SupportingFile("README.md.mustache", sourceFolder, "README.MD"));
supportingFiles.add(new SupportingFile("Makefile.mustache", sourceFolder, "Makefile"));
supportingFiles.add(new SupportingFile("CMakeLists.txt.mustache", sourceFolder, "CMakeLists.txt"));
supportingFiles.add(new SupportingFile("Dockerfile.mustache", sourceFolder, "Dockerfile"));
supportingFiles.add(new SupportingFile("LICENSE.txt.mustache", sourceFolder, "LICENSE.txt"));
typeMapping.put("object", modelNamePrefix + "Object");
additionalProperties().put("prefix", modelNamePrefix);
}
}
/**
* Configures the type of generator.
*
* @return the CodegenType for this generator
* @see org.openapitools.codegen.CodegenType
*/
@Override
public CodegenType getTag() {
return CodegenType.SERVER;
}
/**
* Configures a friendly name for the generator. This will be used by the generator
* to select the library with the -g flag.
*
* @return the friendly name for the generator
*/
@Override
public String getName() {
return "cpp-qt5-server";
}
/**
* Returns human-friendly help for the generator. Provide the consumer with help
* tips, parameters here
*
* @return A string value for the help message
*/
@Override
public String getHelp() {
return "Generates a Qt5 C++ Server using the QHTTPEngine HTTP Library.";
}
@Override
public String toModelImport(String name) {
if( name.isEmpty() ) {
return null;
}
if (namespaces.containsKey(name)) {
return "using " + namespaces.get(name) + ";";
} else if (systemIncludes.contains(name)) {
return "#include <" + name + ">";
}
String folder = modelPackage().replace("::", File.separator);
if (!folder.isEmpty())
folder += File.separator;
return "#include \"" + folder + name + ".h\"";
}
/**
* Escapes a reserved word as defined in the `reservedWords` array. Handle escaping
* those terms here. This logic is only called if a variable matches the reserved words
*
* @return the escaped term
*/
@Override
public String escapeReservedWord(String name) {
if (this.reservedWordsMappings().containsKey(name)) {
return this.reservedWordsMappings().get(name);
}
return "_" + name;
}
/**
* Location to write model files. You can use the modelPackage() as defined when the class is
* instantiated
*/
@Override
public String modelFileFolder() {
return outputFolder + "/" + sourceFolder + MODEL_DIR + "/" + modelPackage().replace("::", File.separator);
}
/**
* Location to write api files. You can use the apiPackage() as defined when the class is
* instantiated
*/
@Override
public String apiFileFolder() {
return outputFolder + "/" + sourceFolder + APIHANDLER_DIR + "/" + apiPackage().replace("::", File.separator);
}
private String requestFileFolder() {
return outputFolder + "/" + sourceFolder + APIREQUEST_DIR + "/" + apiPackage().replace("::", File.separator);
}
@Override
public String toModelFilename(String name) {
return modelNamePrefix + initialCaps(name);
}
@Override
public String apiFilename(String templateName, String tag) {
String result = super.apiFilename(templateName, tag);
if (templateName.contains("apirequest")) {
result = result.replace("ApiHandler", "ApiRequest");
result = result.replace(apiFileFolder(), requestFileFolder());
}
return result;
}
@Override
public String toApiFilename(String name) {
return modelNamePrefix + initialCaps(name) + "ApiHandler";
}
/**
* Optional - type declaration. This is a String which is used by the templates to instantiate your
* types. There is typically special handling for different property types
*
* @return a string value used as the `dataType` field for model templates, `returnType` for api templates
*/
@Override
public String getTypeDeclaration(Schema p) {
String openAPIType = getSchemaType(p);
if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
return getSchemaType(p) + "<" + getTypeDeclaration(inner) + ">";
} else if (ModelUtils.isMapSchema(p)) {
Schema inner = (Schema) p.getAdditionalProperties();
return getSchemaType(p) + "<QString, " + getTypeDeclaration(inner) + ">";
} else if (ModelUtils.isBinarySchema(p)) {
return getSchemaType(p) + "*";
} else if (ModelUtils.isFileSchema(p)) {
return getSchemaType(p) + "*";
}
if (foundationClasses.contains(openAPIType)) {
return openAPIType;
} else if (languageSpecificPrimitives.contains(openAPIType)) {
return toModelName(openAPIType);
} else {
return openAPIType;
}
}
@Override
public String toDefaultValue(Schema p) {
if (ModelUtils.isBooleanSchema(p)) {
return "false";
} else if (ModelUtils.isDateSchema(p)) {
return "NULL";
} else if (ModelUtils.isDateTimeSchema(p)) {
return "NULL";
} else if (ModelUtils.isNumberSchema(p)) {
if (SchemaTypeUtil.FLOAT_FORMAT.equals(p.getFormat())) {
return "0.0f";
}
return "0.0";
} else if (ModelUtils.isIntegerSchema(p)) {
if (SchemaTypeUtil.INTEGER64_FORMAT.equals(p.getFormat())) {
return "0L";
}
return "0";
} else if (ModelUtils.isMapSchema(p)) {
Schema inner = (Schema) p.getAdditionalProperties();
return "QMap<QString, " + getTypeDeclaration(inner) + ">()";
} else if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
return "QList<" + getTypeDeclaration(inner) + ">()";
} else if (ModelUtils.isStringSchema(p)) {
return "QString(\"\")";
} else if (!StringUtils.isEmpty(p.get$ref())) {
return toModelName(ModelUtils.getSimpleRef(p.get$ref())) + "()";
}
return "NULL";
}
/**
* Optional - OpenAPI type conversion. This is used to map OpenAPI types in a `Schema` into
* either language specific types via `typeMapping` or into complex models if there is not a mapping.
*
* @return a string value of the type or complex model for this property
*/
@Override
public String getSchemaType(Schema p) {
String openAPIType = super.getSchemaType(p);
String type = null;
if (typeMapping.containsKey(openAPIType)) {
type = typeMapping.get(openAPIType);
if (languageSpecificPrimitives.contains(type)) {
return toModelName(type);
}
if (foundationClasses.contains(type)) {
return type;
}
} else {
type = openAPIType;
}
return toModelName(type);
}
@Override
public String toModelName(String type) {
if (type == null) {
LOGGER.warn("Model name can't be null. Defaul to 'UnknownModel'.");
type = "UnknownModel";
}
if (typeMapping.keySet().contains(type) ||
typeMapping.values().contains(type) ||
importMapping.values().contains(type) ||
defaultIncludes.contains(type) ||
languageSpecificPrimitives.contains(type)) {
return type;
} else {
return modelNamePrefix + Character.toUpperCase(type.charAt(0)) + type.substring(1);
}
}
@Override
public String toVarName(String name) {
// sanitize name
String varName = name;
varName = sanitizeName(name);
// if it's all uppper case, convert to lower case
if (varName.matches("^[A-Z_]*$")) {
varName = varName.toLowerCase();
}
// camelize (lower first character) the variable name
// petId => pet_id
varName = underscore(varName);
// for reserved word or word starting with number, append _
if (isReservedWord(varName) || varName.matches("^\\d.*")) {
varName = escapeReservedWord(varName);
}
return varName;
}
@Override
public String toParamName(String name) {
return toVarName(name);
}
@Override
public String toApiName(String type) {
return modelNamePrefix + Character.toUpperCase(type.charAt(0)) + type.substring(1) + "Api";
}
@Override
public String escapeQuotationMark(String input) {
// remove " to avoid code injection
return input.replace("\"", "");
}
@Override
public String escapeUnsafeCharacters(String input) {
return input.replace("*/", "*_/").replace("/*", "/_*");
}
@Override
public String getTypeDeclaration(String str) {
return str;
}
}

View File

@@ -8,6 +8,7 @@ org.openapitools.codegen.languages.BashClientCodegen
org.openapitools.codegen.languages.ClojureClientCodegen
org.openapitools.codegen.languages.ConfluenceWikiCodegen
org.openapitools.codegen.languages.CppQt5ClientCodegen
org.openapitools.codegen.languages.CppQt5ServerCodegen
org.openapitools.codegen.languages.CppPistacheServerCodegen
org.openapitools.codegen.languages.CppRestbedServerCodegen
org.openapitools.codegen.languages.CppRestSdkClientCodegen

View File

@@ -0,0 +1,16 @@
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
project(cpp-qt5-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)

View File

@@ -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"]

View File

@@ -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.

View File

@@ -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

View File

@@ -0,0 +1,93 @@
## 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: {{appVersion}}{{^hideGenerationTimestamp}}
- Build date: {{generatedDate}}{{/hideGenerationTimestamp}}
{{#infoUrl}}
For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
{{/infoUrl}}
## QHTTPEngine
[![Build Status](https://travis-ci.org/nitroshare/qhttpengine.svg?branch=master)](https://travis-ci.org/nitroshare/qhttpengine)
[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](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
```

View File

@@ -0,0 +1,38 @@
{{>licenseInfo}}
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
#include <QVariantMap>
#include <QDebug>
#include "{{classname}}Handler.h"
#include "{{classname}}Request.h"
{{#cppNamespaceDeclarations}}
namespace {{this}} {
{{/cppNamespaceDeclarations}}
{{classname}}Handler::{{classname}}Handler(){
}
{{classname}}Handler::~{{classname}}Handler(){
}
{{#operations}}{{#operation}}void {{classname}}Handler::{{nickname}}({{#allParams}}{{{dataType}}}{{#isBodyParam}}{{/isBodyParam}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {
{{#allParams}}
Q_UNUSED({{paramName}});
{{/allParams}}
auto reqObj = qobject_cast<{{classname}}Request*>(sender());
if( reqObj != nullptr )
{
{{#returnType}}{{{returnType}}} res;{{/returnType}}
reqObj->{{nickname}}Response({{#returnType}}res{{/returnType}});
}
}
{{/operation}}{{/operations}}
{{#cppNamespaceDeclarations}}
}
{{/cppNamespaceDeclarations}}

View File

@@ -0,0 +1,33 @@
{{>licenseInfo}}
#ifndef _{{prefix}}_{{classname}}Handler_H_
#define _{{prefix}}_{{classname}}Handler_H_
#include <QObject>
{{#imports}}{{{import}}}
{{/imports}}
{{#cppNamespaceDeclarations}}
namespace {{this}} {
{{/cppNamespaceDeclarations}}
class {{classname}}Handler : public QObject
{
Q_OBJECT
public:
{{classname}}Handler();
virtual ~{{classname}}Handler();
public slots:
{{#operations}}{{#operation}}virtual void {{nickname}}({{#allParams}}{{{dataType}}}{{#isBodyParam}}{{/isBodyParam}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
{{/operation}}{{/operations}}
};
{{#cppNamespaceDeclarations}}
}
{{/cppNamespaceDeclarations}}
#endif // _{{prefix}}_{{classname}}Handler_H_

View File

@@ -0,0 +1,124 @@
{{>licenseInfo}}
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
#include <QVariantMap>
#include <QDebug>
#include "{{prefix}}Helpers.h"
#include "{{classname}}Request.h"
{{#cppNamespaceDeclarations}}
namespace {{this}} {
{{/cppNamespaceDeclarations}}
{{classname}}Request::{{classname}}Request(QHttpEngine::Socket *s, {{classname}}Handler* hdl) : QObject(s), socket(s), handler(hdl) {
}
{{classname}}Request::~{{classname}}Request(){
disconnect(this, nullptr, nullptr, nullptr);
qDebug() << "{{classname}}Request::~{{classname}}Request()";
}
QMap<QString, QString>
{{classname}}Request::getDefaultHeaders(){
return defaultHeaders;
}
QHttpEngine::Socket* {{classname}}Request::getRawSocket(){
return socket;
}
{{#operations}}{{#operation}}
void {{classname}}Request::{{nickname}}Request({{#hasPathParams}}{{#pathParams}}QString {{{paramName}}}str{{/pathParams}}{{/hasPathParams}}){
qDebug() << "{{{basePathWithoutHost}}}{{{path}}}";
connect(this, &{{classname}}Request::{{nickname}}, handler, &{{classname}}Handler::{{nickname}});
{{#queryParams}}{{queryParam}}
{{{dataType}}} {{paramName}};
if(socket->queryString().keys().contains("{{paramName}}")){
fromStringValue(socket->queryString().value{{#isListContainer}}s{{/isListContainer}}("{{paramName}}"), {{paramName}});
}
{{queryParam}}{{/queryParams}}
{{#pathParams}}
{{{dataType}}} {{paramName}};
fromStringValue({{paramName}}str, {{paramName}});
{{/pathParams}}{{#headerParams}}
{{{dataType}}} {{paramName}};
if(socket->headers().keys().contains("{{paramName}}")){
fromStringValue(socket->queryString().value("{{paramName}}"), {{paramName}});
}
{{/headerParams}}{{#formParams}}
{{{dataType}}} {{paramName}};{{/formParams}}{{#bodyParams}} {{#bodyParam}}
{{#isListContainer}}
QJsonDocument doc;
{{{dataType}}} {{paramName}};
if(socket->readJson(doc)){
QJsonArray jsonArray = doc.array();
foreach(QJsonValue obj, jsonArray) {
{{items.baseType}} o;
::{{cppNamespace}}::fromJsonValue(o, obj);
{{paramName}}.append(o);
}
}
{{/isListContainer}}
{{^isListContainer}}
{{^isMapContainer}}
{{#isPrimitive}}
{{{dataType}}} {{paramName}};
::{{cppNamespace}}::fromStringValue((QString(socket->readAll()), {{paramName}});
{{/isPrimitive}}
{{/isMapContainer}}
{{#isMapContainer}}
QJsonDocument doc;
socket->readJson(doc);
QJsonObject obj = doc.object();
{{{dataType}}} {{paramName}};
foreach(QString key, obj.keys()) {
{{baseType}} val;
::{{cppNamespace}}::fromJsonValue(val, obj[key]);
{{paramName}}.insert(key, val);
}
{{/isMapContainer}}
{{^isMapContainer}}
{{^isPrimitive}}
QJsonDocument doc;
socket->readJson(doc);
QJsonObject obj = doc.object();
{{{dataType}}} {{paramName}};
::{{cppNamespace}}::fromJsonValue({{paramName}}, obj);
{{/isPrimitive}}
{{/isMapContainer}}
{{/isListContainer}}
{{/bodyParam}}{{/bodyParams}}
emit {{nickname}}({{#allParams}}{{#isBodyParam}}{{/isBodyParam}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
}
{{/operation}}{{/operations}}
{{#operations}}{{#operation}}void {{classname}}Request::{{nickname}}Response({{#returnType}}{{{returnType}}} res{{/returnType}}){
socket->setStatusCode(QHttpEngine::Socket::OK);
if(socket->isOpen()){
socket->writeHeaders();
socket->close();
}
}
{{/operation}}{{/operations}}
{{#operations}}{{#operation}}void {{classname}}Request::{{nickname}}Error({{#returnType}}{{{returnType}}} res, {{/returnType}}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();
}
}
{{/operation}}{{/operations}}
{{#cppNamespaceDeclarations}}
}
{{/cppNamespaceDeclarations}}

View File

@@ -0,0 +1,53 @@
{{>licenseInfo}}
#ifndef _{{prefix}}_{{classname}}Request_H_
#define _{{prefix}}_{{classname}}Request_H_
#include <QObject>
#include <QStringList>
#include <QNetworkReply>
#include <QSharedPointer>
#include <qhttpengine/socket.h>
{{#imports}}{{{import}}}
{{/imports}}
#include "{{classname}}Handler.h"
{{#cppNamespaceDeclarations}}
namespace {{this}} {
{{/cppNamespaceDeclarations}}
class {{classname}}Request : public QObject
{
Q_OBJECT
public:
{{classname}}Request(QHttpEngine::Socket *s, {{classname}}Handler* handler);
virtual ~{{classname}}Request();
{{#operations}}{{#operation}}void {{nickname}}Request({{#hasPathParams}}{{#pathParams}}QString {{{paramName}}}{{/pathParams}}{{/hasPathParams}});
{{/operation}}{{/operations}}
{{#operations}}{{#operation}}void {{nickname}}Response({{#returnType}}{{{returnType}}} res{{/returnType}});
{{/operation}}{{/operations}}
{{#operations}}{{#operation}}void {{nickname}}Error({{#returnType}}{{{returnType}}} res, {{/returnType}}QNetworkReply::NetworkError error_type, QString& error_str);
{{/operation}}{{/operations}}
QMap<QString, QString> getDefaultHeaders();
QHttpEngine::Socket* getRawSocket();
signals:
{{#operations}}{{#operation}}void {{nickname}}({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
{{/operation}}{{/operations}}
private:
QMap<QString, QString> defaultHeaders;
QHttpEngine::Socket *socket;
{{classname}}Handler *handler;
};
{{#cppNamespaceDeclarations}}
}
{{/cppNamespaceDeclarations}}
#endif // _{{prefix}}_{{classname}}Request_H_

View File

@@ -0,0 +1,94 @@
{{>licenseInfo}}
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
#include <QVariantMap>
#include <QRegularExpression>
#include "{{prefix}}ApiRouter.h"
{{#apiInfo}}{{#apis}}{{#operations}}#include "{{classname}}Request.h"
{{/operations}}{{/apis}}{{/apiInfo}}
{{#cppNamespaceDeclarations}}
namespace {{this}} {
{{/cppNamespaceDeclarations}}
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() {
{{#apiInfo}}{{#apis}}{{classname}}ApiHandler = new {{classname}}Handler();
{{/apis}}{{/apiInfo}}
}
ApiRouter::~ApiRouter(){
qDebug() << "~ApiRouter()";
{{#apiInfo}}{{#apis}}delete {{classname}}ApiHandler;
{{/apis}}{{/apiInfo}}
}
void ApiRouter::setUpRoutes() {
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}{{^pathParams}}
Routes.insert("{{{basePathWithoutHost}}}{{{path}}}",[this](QHttpEngine::Socket *socket) {
if(toQHttpEngineMethod("{{httpMethod}}") == socket->method()){
auto reqObj = new {{classname}}Request(socket, {{classname}}ApiHandler);
reqObj->{{nickname}}Request();
}
});{{/pathParams}}{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
}
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
{ {{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}{{#pathParams}}
{
QString completePath("{{{basePathWithoutHost}}}{{{path}}}");
QString {{paramName}}PathParam("{");
{{paramName}}PathParam.append("{{baseName}}").append("}");
completePath.replace("/", "\\/"); // replace '/' with '\/' for regex
completePath.replace({{paramName}}PathParam, "([^\\/]*?)"); // match anything but '/''
completePath.append("$"); // End of string
QRegularExpression re(completePath, QRegularExpression::CaseInsensitiveOption);
QRegularExpressionMatch match = re.match(socket->path());
if ((toQHttpEngineMethod("{{httpMethod}}") == socket->method()) && match.hasMatch() ) {
QString pathparam = match.captured(1);
auto reqObj = new {{classname}}Request(socket, {{classname}}ApiHandler);
reqObj->{{nickname}}Request({{#hasPathParams}}{{#pathParams}}pathparam{{/pathParams}}{{/hasPathParams}});;
return;
}
}{{/pathParams}}{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
}
socket->setStatusCode(QHttpEngine::Socket::NotFound);
if(socket->isOpen()){
socket->writeHeaders();
socket->close();
}
return;
}
{{#cppNamespaceDeclarations}}
}
{{/cppNamespaceDeclarations}}

View File

@@ -0,0 +1,55 @@
{{>licenseInfo}}
#ifndef {{prefix}}_APIROUTER_H
#define {{prefix}}_APIROUTER_H
#include <QObject>
#include <QStringList>
#include <QSharedPointer>
#include <QList>
#include <QMultiMap>
#include <qhttpengine/socket.h>
#include <qhttpengine/handler.h>
#include <qhttpengine/qobjecthandler.h>
{{#apiInfo}}{{#apis}}{{#operations}}#include "{{classname}}Handler.h"
{{/operations}}{{/apis}}{{/apiInfo}}
{{#cppNamespaceDeclarations}}
namespace {{this}} {
{{/cppNamespaceDeclarations}}
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;
{{#apiInfo}}{{#apis}}
{{classname}}Handler *{{classname}}ApiHandler;{{/apis}}{{/apiInfo}}
};
{{#cppNamespaceDeclarations}}
}
{{/cppNamespaceDeclarations}}
#endif // {{prefix}}_APIROUTER_H

View File

@@ -0,0 +1,282 @@
{{>licenseInfo}}
#include <QDebug>
#include "{{prefix}}Helpers.h"
#include "{{prefix}}Object.h"
{{#cppNamespaceDeclarations}}
namespace {{this}} {
{{/cppNamespaceDeclarations}}
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 {{prefix}}Object &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({{prefix}}Object &value, const QJsonValue &jval){
if(jval.isObject()){
value.fromJsonObject(jval.toObject());
}
}
{{#cppNamespaceDeclarations}}
}
{{/cppNamespaceDeclarations}}

View File

@@ -0,0 +1,144 @@
{{>licenseInfo}}
#ifndef {{prefix}}_HELPERS_H
#define {{prefix}}_HELPERS_H
#include <QJsonObject>
#include <QJsonValue>
#include <QJsonArray>
#include <QList>
#include <QMap>
#include <QDateTime>
#include <QByteArray>
#include <QDate>
#include <QVariant>
#include "{{prefix}}Object.h"
{{#cppNamespaceDeclarations}}
namespace {{this}} {
{{/cppNamespaceDeclarations}}
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 {{prefix}}Object &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({{prefix}}Object &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;
}
{{#cppNamespaceDeclarations}}
}
{{/cppNamespaceDeclarations}}
#endif // {{prefix}}_HELPERS_H

View File

@@ -0,0 +1,11 @@
/**
* {{{appName}}}
* {{{appDescription}}}
*
* {{#version}}OpenAPI spec version: {{{version}}}{{/version}}
* {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}}
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/

View File

@@ -0,0 +1,88 @@
{{>licenseInfo}}
#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 "{{prefix}}ApiRouter.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<{{cppNamespace}}::RequestHandler> handler(new {{cppNamespace}}::RequestHandler());
{{cppNamespace}}::ApiRouter router;
QObject::connect(handler.data(), &{{cppNamespace}}::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();
}

View File

@@ -0,0 +1,118 @@
{{>licenseInfo}}
{{#models}}{{#model}}
#include "{{classname}}.h"
#include "{{prefix}}Helpers.h"
#include <QJsonDocument>
#include <QJsonArray>
#include <QObject>
#include <QDebug>
{{#cppNamespaceDeclarations}}
namespace {{this}} {
{{/cppNamespaceDeclarations}}
{{classname}}::{{classname}}(QString json) {
this->fromJson(json);
}
{{classname}}::{{classname}}() {
this->init();
}
{{classname}}::~{{classname}}() {
}
void
{{classname}}::init() {
{{#vars}}
m_{{name}}_isSet = false;
{{/vars}}
}
void
{{classname}}::fromJson(QString jsonString) {
QByteArray array (jsonString.toStdString().c_str());
QJsonDocument doc = QJsonDocument::fromJson(array);
QJsonObject jsonObject = doc.object();
this->fromJsonObject(jsonObject);
}
void
{{classname}}::fromJsonObject(QJsonObject json) {
{{#vars}}
{{^isContainer}}::{{cppNamespace}}::fromJsonValue({{name}}, json[QString("{{baseName}}")]);{{/isContainer}}
{{#isContainer}}{{^items.isContainer}}::{{cppNamespace}}::fromJsonValue({{name}}, json[QString("{{baseName}}")]);{{/items.isContainer}}{{#items.isContainer}}{{#isListContainer}}
if(json["{{baseName}}"].isArray()){
auto arr = json["{{baseName}}"].toArray();
for (const QJsonValue & jval : arr) {
{{items.baseType}} item;
{{name}}.push_back(::{{cppNamespace}}::fromJsonValue(item, jval));
}
}{{/isListContainer}}{{#isMapContainer}}
if(json["{{baseName}}"].isObject()){
auto varmap = json["{{baseName}}"].toObject().toVariantMap();
if(varmap.count() > 0){
for(auto val : varmap.keys()){
{{items.baseType}} item;
auto jval = QJsonValue::fromVariant(varmap.value(val));
{{name}}.insert({{name}}.end(), val, ::{{cppNamespace}}::fromJsonValue(item, jval));
}
}
}{{/isMapContainer}}{{/items.isContainer}}{{/isContainer}}
{{/vars}}
}
QString
{{classname}}::asJson () const {
QJsonObject obj = this->asJsonObject();
QJsonDocument doc(obj);
QByteArray bytes = doc.toJson();
return QString(bytes);
}
QJsonObject
{{classname}}::asJsonObject() const {
QJsonObject obj;
{{#vars}}
{{^isContainer}}{{#complexType}}{{^isString}}{{^isDateTime}}{{^isByteArray}}{{^isDate}}if({{name}}.isSet()){{/isDate}}{{/isByteArray}}{{/isDateTime}}{{/isString}}{{/complexType}}{{^complexType}}if(m_{{name}}_isSet){{/complexType}}{{#isString}}if(m_{{name}}_isSet){{/isString}}{{#isDateTime}}if(m_{{name}}_isSet){{/isDateTime}}{{#isByteArray}}if(m_{{name}}_isSet){{/isByteArray}}{{#isDate}}if(m_{{name}}_isSet){{/isDate}}{
obj.insert(QString("{{baseName}}"), ::{{cppNamespace}}::toJsonValue({{name}}));
}{{/isContainer}}{{#isContainer}}
if({{name}}.size() > 0){
{{^items.isContainer}}obj.insert(QString("{{baseName}}"), ::{{cppNamespace}}::toJsonValue({{name}}));{{/items.isContainer}}{{#items.isContainer}}
obj.insert(QString("{{baseName}}"), toJsonValue({{name}}));{{/items.isContainer}}
} {{/isContainer}}
{{/vars}}
return obj;
}
{{#vars}}
{{{dataType}}}
{{classname}}::{{getter}}() {
return {{name}};
}
void
{{classname}}::{{setter}}(const {{{dataType}}} &{{name}}) {
this->{{name}} = {{name}};
this->m_{{name}}_isSet = true;
}
{{/vars}}
bool
{{classname}}::isSet() const {
bool isObjectUpdated = false;
do{ {{#vars}}
{{#isContainer}}if({{name}}.size() > 0){{/isContainer}}{{^isContainer}}{{#complexType}}{{^isString}}{{^isDateTime}}{{^isByteArray}}{{^isDate}}if({{name}}.isSet()){{/isDate}}{{/isByteArray}}{{/isDateTime}}{{/isString}}{{/complexType}}{{^complexType}}if(m_{{name}}_isSet){{/complexType}}{{#isString}}if(m_{{name}}_isSet){{/isString}}{{#isDateTime}}if(m_{{name}}_isSet){{/isDateTime}}{{#isByteArray}}if(m_{{name}}_isSet){{/isByteArray}}{{#isDate}}if(m_{{name}}_isSet){{/isDate}}{{/isContainer}}{ isObjectUpdated = true; break;}
{{/vars}}}while(false);
return isObjectUpdated;
}
{{#cppNamespaceDeclarations}}
}
{{/cppNamespaceDeclarations}}
{{/model}}
{{/models}}

View File

@@ -0,0 +1,58 @@
{{>licenseInfo}}
{{#models}}{{#model}}/*
* {{classname}}.h
*
* {{description}}
*/
#ifndef {{classname}}_H_
#define {{classname}}_H_
#include <QJsonObject>
{{/model}}{{/models}}
{{#imports}}{{{import}}}
{{/imports}}
#include "{{prefix}}Object.h"
{{#models}}
{{#model}}
{{#cppNamespaceDeclarations}}
namespace {{this}} {
{{/cppNamespaceDeclarations}}
class {{classname}}: public {{prefix}}Object {
public:
{{classname}}();
{{classname}}(QString json);
~{{classname}}() override;
void init();
QString asJson () const override;
QJsonObject asJsonObject() const override;
void fromJsonObject(QJsonObject json) override;
void fromJson(QString jsonString) override;
{{#vars}}
{{{dataType}}} {{getter}}();
void {{setter}}(const {{{dataType}}} &{{name}});
{{/vars}}
virtual bool isSet() const override;
private:
{{#vars}}
{{{dataType}}} {{name}};
bool m_{{name}}_isSet;
{{/vars}}
};
{{#cppNamespaceDeclarations}}
}
{{/cppNamespaceDeclarations}}
#endif /* {{classname}}_H_ */
{{/model}}
{{/models}}

View File

@@ -0,0 +1,47 @@
{{>licenseInfo}}
#ifndef _{{prefix}}_OBJECT_H_
#define _{{prefix}}_OBJECT_H_
#include <QJsonObject>
#include <QJsonDocument>
{{#cppNamespaceDeclarations}}
namespace {{this}} {
{{/cppNamespaceDeclarations}}
class {{prefix}}Object {
public:
virtual ~{{prefix}}Object(){
}
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;
};
{{#cppNamespaceDeclarations}}
}
{{/cppNamespaceDeclarations}}
#endif /* _{{prefix}}_OBJECT_H_ */

View File

@@ -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)

View File

@@ -0,0 +1,16 @@
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
project(cpp-qt5-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)

View File

@@ -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"]

View File

@@ -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.

View File

@@ -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

View File

@@ -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
[![Build Status](https://travis-ci.org/nitroshare/qhttpengine.svg?branch=master)](https://travis-ci.org/nitroshare/qhttpengine)
[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](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
```

View File

@@ -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)

View File

@@ -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);
}
}
}

View File

@@ -0,0 +1,49 @@
/**
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* 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_

View File

@@ -0,0 +1,69 @@
/**
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* 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);
}
}
}

View File

@@ -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_

View File

@@ -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();
}
}
}

View File

@@ -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_

View File

@@ -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;
}
}

View File

@@ -0,0 +1,66 @@
/**
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* 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

View File

@@ -0,0 +1,99 @@
/**
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* 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();
}

View File

@@ -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;
}
}

View File

@@ -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_ */

View File

@@ -0,0 +1,112 @@
/**
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* 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;
}
}

View File

@@ -0,0 +1,62 @@
/**
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* 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_ */

View File

@@ -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());
}
}
}

View File

@@ -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

View File

@@ -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_ */

View File

@@ -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;
}
}

View File

@@ -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_ */

View File

@@ -0,0 +1,186 @@
/**
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* 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;
}
}

View File

@@ -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_ */

View File

@@ -0,0 +1,112 @@
/**
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* 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;
}
}

View File

@@ -0,0 +1,62 @@
/**
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* 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_ */

View File

@@ -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;
}
}

View File

@@ -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_ */

View File

@@ -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();
}
}
}

View File

@@ -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_

View File

@@ -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();
}
}
}

View File

@@ -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_

View File

@@ -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();
}
}
}

View File

@@ -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_