forked from loafle/openapi-generator-original
Qt5 parameterized server (#8183)
* first Commit parameterzied Server support * fixed serverconfig classes * Defautl constructor f. Config, fixed regex replace * Polosihed Templates, Added MultiServer support * Update Readme. Fixed MultiServer. Fixed def. Value * Passing global Server to mustache. Small fixes * Updated samples, fixed mustache for multi server * added prefixes, removed unused imports * added newly generated samples * missing vendorExtension in mustache. Update smaple * update doc Co-authored-by: William Cheng <wing328hk@gmail.com>
This commit is contained in:
parent
0be3fe6104
commit
febd65d3b8
@ -187,7 +187,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
### Documentation Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|Readme|✗|ToolingExtension
|
||||
|Readme|✓|ToolingExtension
|
||||
|Model|✓|ToolingExtension
|
||||
|Api|✓|ToolingExtension
|
||||
|
||||
@ -204,8 +204,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|ExternalDocumentation|✓|OAS2,OAS3
|
||||
|Examples|✓|OAS2,OAS3
|
||||
|XMLStructureDefinitions|✗|OAS2,OAS3
|
||||
|MultiServer|✗|OAS3
|
||||
|ParameterizedServer|✗|OAS3
|
||||
|MultiServer|✓|OAS3
|
||||
|ParameterizedServer|✓|OAS3
|
||||
|ParameterStyling|✗|OAS3
|
||||
|Callbacks|✗|OAS3
|
||||
|LinkObjects|✗|OAS3
|
||||
|
@ -19,8 +19,14 @@ package org.openapitools.codegen.languages;
|
||||
|
||||
import com.google.common.collect.ImmutableMap.Builder;
|
||||
import com.samskivert.mustache.Mustache.Lambda;
|
||||
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import io.swagger.v3.oas.models.servers.Server;
|
||||
import io.swagger.v3.oas.models.servers.ServerVariables;
|
||||
import io.swagger.v3.oas.models.servers.ServerVariable;
|
||||
import org.openapitools.codegen.CodegenServer;
|
||||
import org.openapitools.codegen.CodegenServerVariable;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
@ -327,6 +333,8 @@ abstract public class AbstractCppCodegen extends DefaultCodegen implements Codeg
|
||||
|
||||
@Override
|
||||
public void preprocessOpenAPI(OpenAPI openAPI) {
|
||||
List<Server> serverList = openAPI.getServers();
|
||||
List<CodegenServer> CodegenServerList = new ArrayList<CodegenServer>();
|
||||
URL url = URLPathUtils.getServerURL(openAPI, serverVariableOverrides());
|
||||
String port = URLPathUtils.getPort(url, "");
|
||||
String host = url.getHost();
|
||||
@ -341,6 +349,28 @@ abstract public class AbstractCppCodegen extends DefaultCodegen implements Codeg
|
||||
if (!scheme.isEmpty()) {
|
||||
this.additionalProperties.put("scheme", scheme);
|
||||
}
|
||||
if (!serverList.isEmpty()) {
|
||||
for (Server server : serverList) {
|
||||
CodegenServer s = new CodegenServer();
|
||||
s.description = server.getDescription();
|
||||
s.url = server.getUrl();
|
||||
s.variables = new ArrayList<CodegenServerVariable>();
|
||||
ServerVariables serverVars = server.getVariables();
|
||||
if(serverVars != null){
|
||||
serverVars.forEach((key,value) -> {
|
||||
CodegenServerVariable codegenServerVar= new CodegenServerVariable();
|
||||
ServerVariable ServerVar = value;
|
||||
codegenServerVar.name = key;
|
||||
codegenServerVar.description = ServerVar.getDescription();
|
||||
codegenServerVar.defaultValue = ServerVar.getDefault();
|
||||
codegenServerVar.enumValues = ServerVar.getEnum();
|
||||
s.variables.add(codegenServerVar);
|
||||
});
|
||||
}
|
||||
CodegenServerList.add(s);
|
||||
}
|
||||
this.vendorExtensions.put("x-codegen-globalServerList", CodegenServerList);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -21,6 +21,8 @@ import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
import org.openapitools.codegen.meta.features.DocumentationFeature;
|
||||
import org.openapitools.codegen.meta.features.GlobalFeature;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@ -35,6 +37,13 @@ public class CppQt5ClientCodegen extends CppQt5AbstractCodegen implements Codege
|
||||
public CppQt5ClientCodegen() {
|
||||
super();
|
||||
|
||||
|
||||
modifyFeatureSet(features -> features
|
||||
.includeDocumentationFeatures(DocumentationFeature.Readme)
|
||||
.includeGlobalFeatures(GlobalFeature.ParameterizedServer)
|
||||
.includeGlobalFeatures(GlobalFeature.MultiServer)
|
||||
);
|
||||
|
||||
// set the output folder here
|
||||
outputFolder = "generated-code/qt5cpp";
|
||||
|
||||
@ -80,6 +89,8 @@ public class CppQt5ClientCodegen extends CppQt5AbstractCodegen implements Codege
|
||||
supportingFiles.add(new SupportingFile("HttpFileElement.cpp.mustache", sourceFolder, PREFIX + "HttpFileElement.cpp"));
|
||||
supportingFiles.add(new SupportingFile("object.mustache", sourceFolder, PREFIX + "Object.h"));
|
||||
supportingFiles.add(new SupportingFile("enum.mustache", sourceFolder, PREFIX + "Enum.h"));
|
||||
supportingFiles.add(new SupportingFile("ServerConfiguration.mustache", sourceFolder, PREFIX +"ServerConfiguration.h"));
|
||||
supportingFiles.add(new SupportingFile("ServerVariable.mustache", sourceFolder, PREFIX +"ServerVariable.h"));
|
||||
supportingFiles.add(new SupportingFile("README.mustache", "","README.md"));
|
||||
supportingFiles.add(new SupportingFile("CMakeLists.txt.mustache", sourceFolder, "CMakeLists.txt"));
|
||||
if (optionalProjectFileFlag) {
|
||||
@ -109,6 +120,8 @@ public class CppQt5ClientCodegen extends CppQt5AbstractCodegen implements Codege
|
||||
supportingFiles.add(new SupportingFile("HttpFileElement.cpp.mustache", sourceFolder, modelNamePrefix + "HttpFileElement.cpp"));
|
||||
supportingFiles.add(new SupportingFile("object.mustache", sourceFolder, modelNamePrefix + "Object.h"));
|
||||
supportingFiles.add(new SupportingFile("enum.mustache", sourceFolder, modelNamePrefix + "Enum.h"));
|
||||
supportingFiles.add(new SupportingFile("ServerConfiguration.mustache", sourceFolder, modelNamePrefix + "ServerConfiguration.h"));
|
||||
supportingFiles.add(new SupportingFile("ServerVariable.mustache", sourceFolder, modelNamePrefix + "ServerVariable.h"));
|
||||
supportingFiles.add(new SupportingFile("README.mustache", "","README.md"));
|
||||
supportingFiles.add(new SupportingFile("CMakeLists.txt.mustache", sourceFolder, "CMakeLists.txt"));
|
||||
|
||||
|
@ -20,7 +20,9 @@ HEADERS += \
|
||||
$${PWD}/{{prefix}}HttpRequest.h \
|
||||
$${PWD}/{{prefix}}Object.h \
|
||||
$${PWD}/{{prefix}}Enum.h \
|
||||
$${PWD}/{{prefix}}HttpFileElement.h
|
||||
$${PWD}/{{prefix}}HttpFileElement.h \
|
||||
$${PWD}/{{prefix}}ServerConfiguration.h \
|
||||
$${PWD}/{{prefix}}ServerVariable.h
|
||||
|
||||
SOURCES += \
|
||||
# Models
|
||||
|
@ -146,6 +146,58 @@ Class | Method | HTTP request | Description
|
||||
{{#models}}{{#model}} - [{{classname}}]({{modelDocPath}}{{classname}}.md)
|
||||
{{/model}}{{/models}}
|
||||
|
||||
## Documentation for Servers
|
||||
|
||||
Parameterized Servers are supported. Define a server in the API for each endpoint with arbitrary numbers of variables:
|
||||
|
||||
```
|
||||
servers:
|
||||
- url: http://{server}:{port}/{basePath}
|
||||
description: Description of the Server
|
||||
variables:
|
||||
server:
|
||||
enum:
|
||||
- 'petstore'
|
||||
- 'qa-petstore'
|
||||
- 'dev-petstore'
|
||||
default: 'petstore'
|
||||
port:
|
||||
enum:
|
||||
- '3000'
|
||||
- '1000'
|
||||
default: '3000'
|
||||
basePath:
|
||||
default: v1
|
||||
```
|
||||
To change the default variable, use this function in each Api:
|
||||
```
|
||||
int setDefaultServerValue(int serverIndex,const QString &operation, const QString &variable,const QString &val);
|
||||
```
|
||||
The parameter "serverIndex" will choose a server from the server list for each endpoint. There is always at least one server with index 0. The Paramter "operation" should be the desired endpoint operationid.
|
||||
Variable is the name of the variable you wish to change and the value is the new default Value.
|
||||
The function will return -1 when the variable does not exists, -2 if value is not defined in the variable enum and -3 if the operation is not found.
|
||||
|
||||
If your endpoint has multiple server objects in the servers array, you can set the server that will be used with this function:
|
||||
```
|
||||
void setServerIndex(const QString &operation, int serverIndex);
|
||||
```
|
||||
Parameter "operation" should be your operationid. "serverIndex" is the index you want to set as your default server. The function will check if there is a server with your index.
|
||||
Here is an example of multiple servers in the servers array. The first server will have index 0 and the second will have index 1.
|
||||
```
|
||||
servers:
|
||||
- url: http://{server}:8080/
|
||||
description: Description of the Server
|
||||
variables:
|
||||
server:
|
||||
enum:
|
||||
- 'petstore'
|
||||
- 'qa-petstore'
|
||||
- 'dev-petstore'
|
||||
default: 'petstore'
|
||||
- url: https://localhost:8080/v1
|
||||
```
|
||||
|
||||
|
||||
## Documentation for Authorization
|
||||
|
||||
{{^authMethods}}All endpoints do not require authorization.
|
||||
|
73
modules/openapi-generator/src/main/resources/cpp-qt5-client/ServerConfiguration.mustache
vendored
Normal file
73
modules/openapi-generator/src/main/resources/cpp-qt5-client/ServerConfiguration.mustache
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
{{>licenseInfo}}
|
||||
/**
|
||||
* Representing a Server configuration.
|
||||
*/
|
||||
#ifndef {{prefix}}_SERVERVCONFIGURATION_H
|
||||
#define {{prefix}}_SERVERVCONFIGURATION_H
|
||||
#include <QString>
|
||||
#include <QMap>
|
||||
#include <QRegularExpression>
|
||||
#include "{{prefix}}ServerVariable.h"
|
||||
|
||||
{{#cppNamespaceDeclarations}}
|
||||
namespace {{this}} {
|
||||
{{/cppNamespaceDeclarations}}
|
||||
|
||||
class {{prefix}}ServerConfiguration {
|
||||
public:
|
||||
/**
|
||||
* @param URL A URL to the target host.
|
||||
* @param description A description of the host designated by the URL.
|
||||
* @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
|
||||
*/
|
||||
{{prefix}}ServerConfiguration(const QString& URL, const QString& description, const QMap<QString, {{prefix}}ServerVariable>& variables)
|
||||
: _description(description),
|
||||
_variables(variables),
|
||||
_URL(URL){}
|
||||
{{prefix}}ServerConfiguration(){}
|
||||
~{{prefix}}ServerConfiguration(){}
|
||||
|
||||
/**
|
||||
* Format URL template using given variables.
|
||||
*
|
||||
* @param variables A map between a variable name and its value.
|
||||
* @return Formatted URL.
|
||||
*/
|
||||
QString URL() {
|
||||
QString url = _URL;
|
||||
if(!_variables.empty()){
|
||||
// go through variables and replace placeholders
|
||||
for (auto const& v : _variables.keys()) {
|
||||
QString name = v;
|
||||
{{prefix}}ServerVariable serverVariable = _variables.value(v);
|
||||
QString value = serverVariable._defaultValue;
|
||||
|
||||
if (!serverVariable._enumValues.empty() && !serverVariable._enumValues.contains(value)) {
|
||||
throw std::runtime_error(QString("The variable " + name + " in the server URL has invalid value " + value + ".").toUtf8());
|
||||
}
|
||||
QRegularExpression regex(QString("\\{" + name + "\\}"));
|
||||
url = url.replace(regex, value);
|
||||
|
||||
}
|
||||
return url;
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
int setDefaultValue(const QString& variable,const QString& value){
|
||||
if(_variables.contains(variable))
|
||||
return _variables[variable].setDefaultValue(value);
|
||||
return -1;
|
||||
}
|
||||
|
||||
QString _description;
|
||||
QMap<QString, {{prefix}}ServerVariable> _variables;
|
||||
QString _URL;
|
||||
|
||||
};
|
||||
|
||||
{{#cppNamespaceDeclarations}}
|
||||
} // namespace {{this}}
|
||||
{{/cppNamespaceDeclarations}}
|
||||
|
||||
#endif // {{prefix}}_SERVERVCONFIGURATION_H
|
52
modules/openapi-generator/src/main/resources/cpp-qt5-client/ServerVariable.mustache
vendored
Normal file
52
modules/openapi-generator/src/main/resources/cpp-qt5-client/ServerVariable.mustache
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
{{>licenseInfo}}
|
||||
/**
|
||||
* Representing a Server Variable for server URL template substitution.
|
||||
*/
|
||||
#ifndef {{prefix}}_SERVERVARIABLE_H
|
||||
#define {{prefix}}_SERVERVARIABLE_H
|
||||
#include <QString>
|
||||
#include <QSet>
|
||||
|
||||
{{#cppNamespaceDeclarations}}
|
||||
namespace {{this}} {
|
||||
{{/cppNamespaceDeclarations}}
|
||||
|
||||
class {{prefix}}ServerVariable {
|
||||
public:
|
||||
|
||||
/**
|
||||
* @param description A description for the server variable.
|
||||
* @param defaultValue The default value to use for substitution.
|
||||
* @param enumValues An enumeration of string values to be used if the substitution options are from a limited set.
|
||||
*/
|
||||
{{prefix}}ServerVariable(const QString &description, const QString &defaultValue, const QSet<QString> &enumValues)
|
||||
: _defaultValue(defaultValue),
|
||||
_description(description),
|
||||
_enumValues(enumValues){}
|
||||
|
||||
{{prefix}}ServerVariable(){}
|
||||
~{{prefix}}ServerVariable(){}
|
||||
|
||||
int setDefaultValue(const QString& value){
|
||||
if( _enumValues.contains(value)){
|
||||
_defaultValue = value;
|
||||
return 0;
|
||||
}
|
||||
return -2;
|
||||
}
|
||||
|
||||
QString getDefaultValue(){return _defaultValue;}
|
||||
QSet<QString> getEnumValues(){return _enumValues;}
|
||||
|
||||
|
||||
QString _defaultValue;
|
||||
QString _description;
|
||||
QSet<QString> _enumValues;
|
||||
|
||||
};
|
||||
|
||||
{{#cppNamespaceDeclarations}}
|
||||
} // namespace {{this}}
|
||||
{{/cppNamespaceDeclarations}}
|
||||
|
||||
#endif // {{prefix}}_SERVERVARIABLE_H
|
@ -1,7 +1,7 @@
|
||||
{{>licenseInfo}}
|
||||
#include "{{classname}}.h"
|
||||
#include "{{prefix}}Helpers.h"
|
||||
|
||||
#include "{{prefix}}ServerConfiguration.h"
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
|
||||
@ -17,11 +17,70 @@ namespace {{this}} {
|
||||
_timeOut(timeOut),
|
||||
_manager(nullptr),
|
||||
isResponseCompressionEnabled(false),
|
||||
isRequestCompressionEnabled(false) {}
|
||||
isRequestCompressionEnabled(false) {
|
||||
initializeServerConfigs();
|
||||
}
|
||||
|
||||
{{classname}}::~{{classname}}() {
|
||||
}
|
||||
|
||||
void {{classname}}::initializeServerConfigs(){
|
||||
|
||||
//Default server
|
||||
QList<{{prefix}}ServerConfiguration> defaultConf = QList<{{prefix}}ServerConfiguration>();
|
||||
//varying endpoint server
|
||||
QList<{{prefix}}ServerConfiguration> serverConf = QList<{{prefix}}ServerConfiguration>();
|
||||
{{#vendorExtensions}}
|
||||
{{#x-codegen-globalServerList}}
|
||||
defaultConf.append({{prefix}}ServerConfiguration(
|
||||
"{{{url}}}",
|
||||
"{{{description}}}{{^description}}No description provided{{/description}}",
|
||||
{{#variables}}{{#-first}}QMap<QString, {{prefix}}ServerVariable>{ {{/-first}}
|
||||
{"{{{name}}}", {{prefix}}ServerVariable("{{{description}}}{{^description}}No description provided{{/description}}","{{{defaultValue}}}",
|
||||
QSet<QString>{ {{#enumValues}}{"{{{.}}}"}{{#-last}} })},{{/-last}}{{^-last}},{{/-last}}{{/enumValues}}{{^enumValues}}{"{{defaultValue}}"} })},{{/enumValues}}{{#-last}} }));{{/-last}}
|
||||
{{/variables}}{{^variables}}QMap<QString, {{prefix}}ServerVariable>()));{{/variables}}
|
||||
{{/x-codegen-globalServerList}}
|
||||
{{/vendorExtensions}}
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
{{^servers}}
|
||||
_serverConfigs.insert("{{nickname}}",defaultConf);
|
||||
_serverIndices.insert("{{nickname}}",0);
|
||||
|
||||
{{/servers}}
|
||||
{{#servers}}
|
||||
serverConf.append({{prefix}}ServerConfiguration(
|
||||
"{{{url}}}",
|
||||
"{{{description}}}{{^description}}No description provided{{/description}}",
|
||||
{{#variables}}{{#-first}}QMap<QString, {{prefix}}ServerVariable>{ {{/-first}}
|
||||
{"{{{name}}}", {{prefix}}ServerVariable("{{{description}}}{{^description}}No description provided{{/description}}","{{{defaultValue}}}",
|
||||
QSet<QString>{ {{#enumValues}}{"{{{.}}}"}{{#-last}} })}, {{/-last}}{{^-last}},{{/-last}}{{/enumValues}}{{^enumValues}}{"{{defaultValue}}"} })},{{/enumValues}}{{#-last}} }));{{/-last}}
|
||||
{{/variables}}{{^variables}}QMap<QString, {{prefix}}ServerVariable>()));{{/variables}}
|
||||
{{#-last}}_serverConfigs.insert("{{nickname}}",serverConf);
|
||||
_serverIndices.insert("{{nickname}}",0);{{/-last}}
|
||||
|
||||
{{/servers}}
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* returns 0 on success and -1, -2 or -3 on failure.
|
||||
* -1 when the variable does not exist and -2 if the value is not defined in the enum and -3 if the operation or server index is not found
|
||||
*/
|
||||
int {{classname}}::setDefaultServerValue(int serverIndex, const QString &operation, const QString &variable, const QString &value){
|
||||
auto it = _serverConfigs.find(operation);
|
||||
if(it != _serverConfigs.end() && serverIndex < it.value().size() ){
|
||||
return _serverConfigs[operation][serverIndex].setDefaultValue(variable,value);
|
||||
}
|
||||
return -3;
|
||||
}
|
||||
void {{classname}}::setServerIndex(const QString &operation, int serverIndex){
|
||||
if(_serverIndices.contains(operation) && serverIndex < _serverConfigs.find(operation).value().size() )
|
||||
_serverIndices[operation] = serverIndex;
|
||||
}
|
||||
|
||||
void {{classname}}::setScheme(const QString &scheme) {
|
||||
_scheme = scheme;
|
||||
}
|
||||
@ -85,12 +144,7 @@ void {{classname}}::abortRequests(){
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
void {{classname}}::{{nickname}}({{#allParams}}const {{{dataType}}} &{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) {
|
||||
QString fullPath = QString("%1://%2%3%4%5")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("{{{path}}}");
|
||||
QString fullPath = QString(_serverConfigs["{{nickname}}"][_serverIndices.value("{{nickname}}")].URL()+"{{{path}}}");
|
||||
{{#pathParams}}
|
||||
QString {{paramName}}PathParam("{");
|
||||
{{paramName}}PathParam.append("{{baseName}}").append("}");
|
||||
|
@ -3,6 +3,7 @@
|
||||
#define {{prefix}}_{{classname}}_H
|
||||
|
||||
#include "{{prefix}}HttpRequest.h"
|
||||
#include "{{prefix}}ServerConfiguration.h"
|
||||
|
||||
{{#imports}}{{{import}}}
|
||||
{{/imports}}
|
||||
@ -10,6 +11,7 @@
|
||||
#include <QObject>
|
||||
#include <QByteArray>
|
||||
#include <QStringList>
|
||||
#include <QList>
|
||||
#include <QNetworkAccessManager>
|
||||
|
||||
{{#cppNamespaceDeclarations}}
|
||||
@ -23,6 +25,9 @@ public:
|
||||
{{classname}}(const QString &scheme = "{{scheme}}", const QString &host = "{{serverHost}}", int port = {{#serverPort}}{{serverPort}}{{/serverPort}}{{^serverPort}}0{{/serverPort}}, const QString &basePath = "{{basePathWithoutHost}}", const int timeOut = 0);
|
||||
~{{classname}}();
|
||||
|
||||
void initializeServerConfigs();
|
||||
int setDefaultServerValue(int serverIndex,const QString &operation, const QString &variable,const QString &val);
|
||||
void setServerIndex(const QString &operation, int serverIndex);
|
||||
void setScheme(const QString &scheme);
|
||||
void setHost(const QString &host);
|
||||
void setPort(int port);
|
||||
@ -44,11 +49,13 @@ public:
|
||||
private:
|
||||
QString _scheme, _host;
|
||||
int _port;
|
||||
QString _basePath;
|
||||
QMap<QString,int> _serverIndices;
|
||||
QMap<QString,QList<{{prefix}}ServerConfiguration>> _serverConfigs;
|
||||
QMap<QString, QString> _apiKeys;
|
||||
QString _bearerToken;
|
||||
QString _username;
|
||||
QString _password;
|
||||
QString _basePath;
|
||||
int _timeOut;
|
||||
QString _workingDirectory;
|
||||
QNetworkAccessManager* _manager;
|
||||
|
31
samples/client/petstore/cpp-qt5/.openapi-generator/FILES
Normal file
31
samples/client/petstore/cpp-qt5/.openapi-generator/FILES
Normal file
@ -0,0 +1,31 @@
|
||||
README.md
|
||||
client/CMakeLists.txt
|
||||
client/PFXApiResponse.cpp
|
||||
client/PFXApiResponse.h
|
||||
client/PFXCategory.cpp
|
||||
client/PFXCategory.h
|
||||
client/PFXEnum.h
|
||||
client/PFXHelpers.cpp
|
||||
client/PFXHelpers.h
|
||||
client/PFXHttpFileElement.cpp
|
||||
client/PFXHttpFileElement.h
|
||||
client/PFXHttpRequest.cpp
|
||||
client/PFXHttpRequest.h
|
||||
client/PFXObject.h
|
||||
client/PFXOrder.cpp
|
||||
client/PFXOrder.h
|
||||
client/PFXPet.cpp
|
||||
client/PFXPet.h
|
||||
client/PFXPetApi.cpp
|
||||
client/PFXPetApi.h
|
||||
client/PFXServerConfiguration.h
|
||||
client/PFXServerVariable.h
|
||||
client/PFXStoreApi.cpp
|
||||
client/PFXStoreApi.h
|
||||
client/PFXTag.cpp
|
||||
client/PFXTag.h
|
||||
client/PFXUser.cpp
|
||||
client/PFXUser.h
|
||||
client/PFXUserApi.cpp
|
||||
client/PFXUserApi.h
|
||||
client/PFXclient.pri
|
@ -147,6 +147,58 @@ Class | Method | HTTP request | Description
|
||||
- [PFXUser](PFXUser.md)
|
||||
|
||||
|
||||
## Documentation for Servers
|
||||
|
||||
Parameterized Servers are supported. Define a server in the API for each endpoint with arbitrary numbers of variables:
|
||||
|
||||
```
|
||||
servers:
|
||||
- url: http://{server}:{port}/{basePath}
|
||||
description: Description of the Server
|
||||
variables:
|
||||
server:
|
||||
enum:
|
||||
- 'petstore'
|
||||
- 'qa-petstore'
|
||||
- 'dev-petstore'
|
||||
default: 'petstore'
|
||||
port:
|
||||
enum:
|
||||
- '3000'
|
||||
- '1000'
|
||||
default: '3000'
|
||||
basePath:
|
||||
default: v1
|
||||
```
|
||||
To change the default variable, use this function in each Api:
|
||||
```
|
||||
int setDefaultServerValue(int serverIndex,const QString &operation, const QString &variable,const QString &val);
|
||||
```
|
||||
The parameter "serverIndex" will choose a server from the server list for each endpoint. There is always at least one server with index 0. The Paramter "operation" should be the desired endpoint operationid.
|
||||
Variable is the name of the variable you wish to change and the value is the new default Value.
|
||||
The function will return -1 when the variable does not exists, -2 if value is not defined in the variable enum and -3 if the operation is not found.
|
||||
|
||||
If your endpoint has multiple server objects in the servers array, you can set the server that will be used with this function:
|
||||
```
|
||||
void setServerIndex(const QString &operation, int serverIndex);
|
||||
```
|
||||
Parameter "operation" should be your operationid. "serverIndex" is the index you want to set as your default server. The function will check if there is a server with your index.
|
||||
Here is an example of multiple servers in the servers array. The first server will have index 0 and the second will have index 1.
|
||||
```
|
||||
servers:
|
||||
- url: http://{server}:8080/
|
||||
description: Description of the Server
|
||||
variables:
|
||||
server:
|
||||
enum:
|
||||
- 'petstore'
|
||||
- 'qa-petstore'
|
||||
- 'dev-petstore'
|
||||
default: 'petstore'
|
||||
- url: https://localhost:8080/v1
|
||||
```
|
||||
|
||||
|
||||
## Documentation for Authorization
|
||||
|
||||
Authentication schemes defined for the API:
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
#include "PFXPetApi.h"
|
||||
#include "PFXHelpers.h"
|
||||
|
||||
#include "PFXServerConfiguration.h"
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
|
||||
@ -25,11 +25,66 @@ PFXPetApi::PFXPetApi(const QString &scheme, const QString &host, int port, const
|
||||
_timeOut(timeOut),
|
||||
_manager(nullptr),
|
||||
isResponseCompressionEnabled(false),
|
||||
isRequestCompressionEnabled(false) {}
|
||||
isRequestCompressionEnabled(false) {
|
||||
initializeServerConfigs();
|
||||
}
|
||||
|
||||
PFXPetApi::~PFXPetApi() {
|
||||
}
|
||||
|
||||
void PFXPetApi::initializeServerConfigs(){
|
||||
|
||||
//Default server
|
||||
QList<PFXServerConfiguration> defaultConf = QList<PFXServerConfiguration>();
|
||||
//varying endpoint server
|
||||
QList<PFXServerConfiguration> serverConf = QList<PFXServerConfiguration>();
|
||||
defaultConf.append(PFXServerConfiguration(
|
||||
"http://petstore.swagger.io/v2",
|
||||
"No description provided",
|
||||
QMap<QString, PFXServerVariable>()));
|
||||
_serverConfigs.insert("addPet",defaultConf);
|
||||
_serverIndices.insert("addPet",0);
|
||||
|
||||
_serverConfigs.insert("deletePet",defaultConf);
|
||||
_serverIndices.insert("deletePet",0);
|
||||
|
||||
_serverConfigs.insert("findPetsByStatus",defaultConf);
|
||||
_serverIndices.insert("findPetsByStatus",0);
|
||||
|
||||
_serverConfigs.insert("findPetsByTags",defaultConf);
|
||||
_serverIndices.insert("findPetsByTags",0);
|
||||
|
||||
_serverConfigs.insert("getPetById",defaultConf);
|
||||
_serverIndices.insert("getPetById",0);
|
||||
|
||||
_serverConfigs.insert("updatePet",defaultConf);
|
||||
_serverIndices.insert("updatePet",0);
|
||||
|
||||
_serverConfigs.insert("updatePetWithForm",defaultConf);
|
||||
_serverIndices.insert("updatePetWithForm",0);
|
||||
|
||||
_serverConfigs.insert("uploadFile",defaultConf);
|
||||
_serverIndices.insert("uploadFile",0);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* returns 0 on success and -1, -2 or -3 on failure.
|
||||
* -1 when the variable does not exist and -2 if the value is not defined in the enum and -3 if the operation or server index is not found
|
||||
*/
|
||||
int PFXPetApi::setDefaultServerValue(int serverIndex, const QString &operation, const QString &variable, const QString &value){
|
||||
auto it = _serverConfigs.find(operation);
|
||||
if(it != _serverConfigs.end() && serverIndex < it.value().size() ){
|
||||
return _serverConfigs[operation][serverIndex].setDefaultValue(variable,value);
|
||||
}
|
||||
return -3;
|
||||
}
|
||||
void PFXPetApi::setServerIndex(const QString &operation, int serverIndex){
|
||||
if(_serverIndices.contains(operation) && serverIndex < _serverConfigs.find(operation).value().size() )
|
||||
_serverIndices[operation] = serverIndex;
|
||||
}
|
||||
|
||||
void PFXPetApi::setScheme(const QString &scheme) {
|
||||
_scheme = scheme;
|
||||
}
|
||||
@ -91,12 +146,7 @@ void PFXPetApi::abortRequests(){
|
||||
}
|
||||
|
||||
void PFXPetApi::addPet(const PFXPet &body) {
|
||||
QString fullPath = QString("%1://%2%3%4%5")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/pet");
|
||||
QString fullPath = QString(_serverConfigs["addPet"][_serverIndices.value("addPet")].URL()+"/pet");
|
||||
|
||||
|
||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager);
|
||||
@ -137,12 +187,7 @@ void PFXPetApi::addPetCallback(PFXHttpRequestWorker *worker) {
|
||||
}
|
||||
|
||||
void PFXPetApi::deletePet(const qint64 &pet_id, const QString &api_key) {
|
||||
QString fullPath = QString("%1://%2%3%4%5")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/pet/{petId}");
|
||||
QString fullPath = QString(_serverConfigs["deletePet"][_serverIndices.value("deletePet")].URL()+"/pet/{petId}");
|
||||
QString pet_idPathParam("{");
|
||||
pet_idPathParam.append("petId").append("}");
|
||||
fullPath.replace(pet_idPathParam, QUrl::toPercentEncoding(::test_namespace::toStringValue(pet_id)));
|
||||
@ -187,12 +232,7 @@ void PFXPetApi::deletePetCallback(PFXHttpRequestWorker *worker) {
|
||||
}
|
||||
|
||||
void PFXPetApi::findPetsByStatus(const QList<QString> &status) {
|
||||
QString fullPath = QString("%1://%2%3%4%5")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/pet/findByStatus");
|
||||
QString fullPath = QString(_serverConfigs["findPetsByStatus"][_serverIndices.value("findPetsByStatus")].URL()+"/pet/findByStatus");
|
||||
|
||||
|
||||
if (status.size() > 0) {
|
||||
@ -278,12 +318,7 @@ void PFXPetApi::findPetsByStatusCallback(PFXHttpRequestWorker *worker) {
|
||||
}
|
||||
|
||||
void PFXPetApi::findPetsByTags(const QList<QString> &tags) {
|
||||
QString fullPath = QString("%1://%2%3%4%5")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/pet/findByTags");
|
||||
QString fullPath = QString(_serverConfigs["findPetsByTags"][_serverIndices.value("findPetsByTags")].URL()+"/pet/findByTags");
|
||||
|
||||
|
||||
if (tags.size() > 0) {
|
||||
@ -369,12 +404,7 @@ void PFXPetApi::findPetsByTagsCallback(PFXHttpRequestWorker *worker) {
|
||||
}
|
||||
|
||||
void PFXPetApi::getPetById(const qint64 &pet_id) {
|
||||
QString fullPath = QString("%1://%2%3%4%5")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/pet/{petId}");
|
||||
QString fullPath = QString(_serverConfigs["getPetById"][_serverIndices.value("getPetById")].URL()+"/pet/{petId}");
|
||||
QString pet_idPathParam("{");
|
||||
pet_idPathParam.append("petId").append("}");
|
||||
fullPath.replace(pet_idPathParam, QUrl::toPercentEncoding(::test_namespace::toStringValue(pet_id)));
|
||||
@ -420,12 +450,7 @@ void PFXPetApi::getPetByIdCallback(PFXHttpRequestWorker *worker) {
|
||||
}
|
||||
|
||||
void PFXPetApi::updatePet(const PFXPet &body) {
|
||||
QString fullPath = QString("%1://%2%3%4%5")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/pet");
|
||||
QString fullPath = QString(_serverConfigs["updatePet"][_serverIndices.value("updatePet")].URL()+"/pet");
|
||||
|
||||
|
||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager);
|
||||
@ -466,12 +491,7 @@ void PFXPetApi::updatePetCallback(PFXHttpRequestWorker *worker) {
|
||||
}
|
||||
|
||||
void PFXPetApi::updatePetWithForm(const qint64 &pet_id, const QString &name, const QString &status) {
|
||||
QString fullPath = QString("%1://%2%3%4%5")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/pet/{petId}");
|
||||
QString fullPath = QString(_serverConfigs["updatePetWithForm"][_serverIndices.value("updatePetWithForm")].URL()+"/pet/{petId}");
|
||||
QString pet_idPathParam("{");
|
||||
pet_idPathParam.append("petId").append("}");
|
||||
fullPath.replace(pet_idPathParam, QUrl::toPercentEncoding(::test_namespace::toStringValue(pet_id)));
|
||||
@ -514,12 +534,7 @@ void PFXPetApi::updatePetWithFormCallback(PFXHttpRequestWorker *worker) {
|
||||
}
|
||||
|
||||
void PFXPetApi::uploadFile(const qint64 &pet_id, const QString &additional_metadata, const PFXHttpFileElement &file) {
|
||||
QString fullPath = QString("%1://%2%3%4%5")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/pet/{petId}/uploadImage");
|
||||
QString fullPath = QString(_serverConfigs["uploadFile"][_serverIndices.value("uploadFile")].URL()+"/pet/{petId}/uploadImage");
|
||||
QString pet_idPathParam("{");
|
||||
pet_idPathParam.append("petId").append("}");
|
||||
fullPath.replace(pet_idPathParam, QUrl::toPercentEncoding(::test_namespace::toStringValue(pet_id)));
|
||||
|
@ -13,6 +13,7 @@
|
||||
#define PFX_PFXPetApi_H
|
||||
|
||||
#include "PFXHttpRequest.h"
|
||||
#include "PFXServerConfiguration.h"
|
||||
|
||||
#include "PFXApiResponse.h"
|
||||
#include "PFXHttpFileElement.h"
|
||||
@ -22,6 +23,7 @@
|
||||
#include <QObject>
|
||||
#include <QByteArray>
|
||||
#include <QStringList>
|
||||
#include <QList>
|
||||
#include <QNetworkAccessManager>
|
||||
|
||||
namespace test_namespace {
|
||||
@ -33,6 +35,9 @@ public:
|
||||
PFXPetApi(const QString &scheme = "http", const QString &host = "petstore.swagger.io", int port = 0, const QString &basePath = "/v2", const int timeOut = 0);
|
||||
~PFXPetApi();
|
||||
|
||||
void initializeServerConfigs();
|
||||
int setDefaultServerValue(int serverIndex,const QString &operation, const QString &variable,const QString &val);
|
||||
void setServerIndex(const QString &operation, int serverIndex);
|
||||
void setScheme(const QString &scheme);
|
||||
void setHost(const QString &host);
|
||||
void setPort(int port);
|
||||
@ -61,11 +66,13 @@ public:
|
||||
private:
|
||||
QString _scheme, _host;
|
||||
int _port;
|
||||
QString _basePath;
|
||||
QMap<QString,int> _serverIndices;
|
||||
QMap<QString,QList<PFXServerConfiguration>> _serverConfigs;
|
||||
QMap<QString, QString> _apiKeys;
|
||||
QString _bearerToken;
|
||||
QString _username;
|
||||
QString _password;
|
||||
QString _basePath;
|
||||
int _timeOut;
|
||||
QString _workingDirectory;
|
||||
QNetworkAccessManager* _manager;
|
||||
|
@ -0,0 +1,79 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Representing a Server configuration.
|
||||
*/
|
||||
#ifndef PFX_SERVERVCONFIGURATION_H
|
||||
#define PFX_SERVERVCONFIGURATION_H
|
||||
#include <QString>
|
||||
#include <QMap>
|
||||
#include <QRegularExpression>
|
||||
#include "PFXServerVariable.h"
|
||||
|
||||
namespace test_namespace {
|
||||
|
||||
class PFXServerConfiguration {
|
||||
public:
|
||||
/**
|
||||
* @param URL A URL to the target host.
|
||||
* @param description A description of the host designated by the URL.
|
||||
* @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
|
||||
*/
|
||||
PFXServerConfiguration(const QString& URL, const QString& description, const QMap<QString, PFXServerVariable>& variables)
|
||||
: _description(description),
|
||||
_variables(variables),
|
||||
_URL(URL){}
|
||||
PFXServerConfiguration(){}
|
||||
~PFXServerConfiguration(){}
|
||||
|
||||
/**
|
||||
* Format URL template using given variables.
|
||||
*
|
||||
* @param variables A map between a variable name and its value.
|
||||
* @return Formatted URL.
|
||||
*/
|
||||
QString URL() {
|
||||
QString url = _URL;
|
||||
if(!_variables.empty()){
|
||||
// go through variables and replace placeholders
|
||||
for (auto const& v : _variables.keys()) {
|
||||
QString name = v;
|
||||
PFXServerVariable serverVariable = _variables.value(v);
|
||||
QString value = serverVariable._defaultValue;
|
||||
|
||||
if (!serverVariable._enumValues.empty() && !serverVariable._enumValues.contains(value)) {
|
||||
throw std::runtime_error(QString("The variable " + name + " in the server URL has invalid value " + value + ".").toUtf8());
|
||||
}
|
||||
QRegularExpression regex(QString("\\{" + name + "\\}"));
|
||||
url = url.replace(regex, value);
|
||||
|
||||
}
|
||||
return url;
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
int setDefaultValue(const QString& variable,const QString& value){
|
||||
if(_variables.contains(variable))
|
||||
return _variables[variable].setDefaultValue(value);
|
||||
return -1;
|
||||
}
|
||||
|
||||
QString _description;
|
||||
QMap<QString, PFXServerVariable> _variables;
|
||||
QString _URL;
|
||||
|
||||
};
|
||||
|
||||
} // namespace test_namespace
|
||||
|
||||
#endif // PFX_SERVERVCONFIGURATION_H
|
58
samples/client/petstore/cpp-qt5/client/PFXServerVariable.h
Normal file
58
samples/client/petstore/cpp-qt5/client/PFXServerVariable.h
Normal file
@ -0,0 +1,58 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Representing a Server Variable for server URL template substitution.
|
||||
*/
|
||||
#ifndef PFX_SERVERVARIABLE_H
|
||||
#define PFX_SERVERVARIABLE_H
|
||||
#include <QString>
|
||||
#include <QSet>
|
||||
|
||||
namespace test_namespace {
|
||||
|
||||
class PFXServerVariable {
|
||||
public:
|
||||
|
||||
/**
|
||||
* @param description A description for the server variable.
|
||||
* @param defaultValue The default value to use for substitution.
|
||||
* @param enumValues An enumeration of string values to be used if the substitution options are from a limited set.
|
||||
*/
|
||||
PFXServerVariable(const QString &description, const QString &defaultValue, const QSet<QString> &enumValues)
|
||||
: _defaultValue(defaultValue),
|
||||
_description(description),
|
||||
_enumValues(enumValues){}
|
||||
|
||||
PFXServerVariable(){}
|
||||
~PFXServerVariable(){}
|
||||
|
||||
int setDefaultValue(const QString& value){
|
||||
if( _enumValues.contains(value)){
|
||||
_defaultValue = value;
|
||||
return 0;
|
||||
}
|
||||
return -2;
|
||||
}
|
||||
|
||||
QString getDefaultValue(){return _defaultValue;}
|
||||
QSet<QString> getEnumValues(){return _enumValues;}
|
||||
|
||||
|
||||
QString _defaultValue;
|
||||
QString _description;
|
||||
QSet<QString> _enumValues;
|
||||
|
||||
};
|
||||
|
||||
} // namespace test_namespace
|
||||
|
||||
#endif // PFX_SERVERVARIABLE_H
|
@ -11,7 +11,7 @@
|
||||
|
||||
#include "PFXStoreApi.h"
|
||||
#include "PFXHelpers.h"
|
||||
|
||||
#include "PFXServerConfiguration.h"
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
|
||||
@ -25,11 +25,54 @@ PFXStoreApi::PFXStoreApi(const QString &scheme, const QString &host, int port, c
|
||||
_timeOut(timeOut),
|
||||
_manager(nullptr),
|
||||
isResponseCompressionEnabled(false),
|
||||
isRequestCompressionEnabled(false) {}
|
||||
isRequestCompressionEnabled(false) {
|
||||
initializeServerConfigs();
|
||||
}
|
||||
|
||||
PFXStoreApi::~PFXStoreApi() {
|
||||
}
|
||||
|
||||
void PFXStoreApi::initializeServerConfigs(){
|
||||
|
||||
//Default server
|
||||
QList<PFXServerConfiguration> defaultConf = QList<PFXServerConfiguration>();
|
||||
//varying endpoint server
|
||||
QList<PFXServerConfiguration> serverConf = QList<PFXServerConfiguration>();
|
||||
defaultConf.append(PFXServerConfiguration(
|
||||
"http://petstore.swagger.io/v2",
|
||||
"No description provided",
|
||||
QMap<QString, PFXServerVariable>()));
|
||||
_serverConfigs.insert("deleteOrder",defaultConf);
|
||||
_serverIndices.insert("deleteOrder",0);
|
||||
|
||||
_serverConfigs.insert("getInventory",defaultConf);
|
||||
_serverIndices.insert("getInventory",0);
|
||||
|
||||
_serverConfigs.insert("getOrderById",defaultConf);
|
||||
_serverIndices.insert("getOrderById",0);
|
||||
|
||||
_serverConfigs.insert("placeOrder",defaultConf);
|
||||
_serverIndices.insert("placeOrder",0);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* returns 0 on success and -1, -2 or -3 on failure.
|
||||
* -1 when the variable does not exist and -2 if the value is not defined in the enum and -3 if the operation or server index is not found
|
||||
*/
|
||||
int PFXStoreApi::setDefaultServerValue(int serverIndex, const QString &operation, const QString &variable, const QString &value){
|
||||
auto it = _serverConfigs.find(operation);
|
||||
if(it != _serverConfigs.end() && serverIndex < it.value().size() ){
|
||||
return _serverConfigs[operation][serverIndex].setDefaultValue(variable,value);
|
||||
}
|
||||
return -3;
|
||||
}
|
||||
void PFXStoreApi::setServerIndex(const QString &operation, int serverIndex){
|
||||
if(_serverIndices.contains(operation) && serverIndex < _serverConfigs.find(operation).value().size() )
|
||||
_serverIndices[operation] = serverIndex;
|
||||
}
|
||||
|
||||
void PFXStoreApi::setScheme(const QString &scheme) {
|
||||
_scheme = scheme;
|
||||
}
|
||||
@ -91,12 +134,7 @@ void PFXStoreApi::abortRequests(){
|
||||
}
|
||||
|
||||
void PFXStoreApi::deleteOrder(const QString &order_id) {
|
||||
QString fullPath = QString("%1://%2%3%4%5")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/store/order/{orderId}");
|
||||
QString fullPath = QString(_serverConfigs["deleteOrder"][_serverIndices.value("deleteOrder")].URL()+"/store/order/{orderId}");
|
||||
QString order_idPathParam("{");
|
||||
order_idPathParam.append("orderId").append("}");
|
||||
fullPath.replace(order_idPathParam, QUrl::toPercentEncoding(::test_namespace::toStringValue(order_id)));
|
||||
@ -137,12 +175,7 @@ void PFXStoreApi::deleteOrderCallback(PFXHttpRequestWorker *worker) {
|
||||
}
|
||||
|
||||
void PFXStoreApi::getInventory() {
|
||||
QString fullPath = QString("%1://%2%3%4%5")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/store/inventory");
|
||||
QString fullPath = QString(_serverConfigs["getInventory"][_serverIndices.value("getInventory")].URL()+"/store/inventory");
|
||||
|
||||
if(_apiKeys.contains("api_key")){
|
||||
addHeaders("api_key",_apiKeys.find("api_key").value());
|
||||
@ -194,12 +227,7 @@ void PFXStoreApi::getInventoryCallback(PFXHttpRequestWorker *worker) {
|
||||
}
|
||||
|
||||
void PFXStoreApi::getOrderById(const qint64 &order_id) {
|
||||
QString fullPath = QString("%1://%2%3%4%5")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/store/order/{orderId}");
|
||||
QString fullPath = QString(_serverConfigs["getOrderById"][_serverIndices.value("getOrderById")].URL()+"/store/order/{orderId}");
|
||||
QString order_idPathParam("{");
|
||||
order_idPathParam.append("orderId").append("}");
|
||||
fullPath.replace(order_idPathParam, QUrl::toPercentEncoding(::test_namespace::toStringValue(order_id)));
|
||||
@ -241,12 +269,7 @@ void PFXStoreApi::getOrderByIdCallback(PFXHttpRequestWorker *worker) {
|
||||
}
|
||||
|
||||
void PFXStoreApi::placeOrder(const PFXOrder &body) {
|
||||
QString fullPath = QString("%1://%2%3%4%5")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/store/order");
|
||||
QString fullPath = QString(_serverConfigs["placeOrder"][_serverIndices.value("placeOrder")].URL()+"/store/order");
|
||||
|
||||
|
||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager);
|
||||
|
@ -13,6 +13,7 @@
|
||||
#define PFX_PFXStoreApi_H
|
||||
|
||||
#include "PFXHttpRequest.h"
|
||||
#include "PFXServerConfiguration.h"
|
||||
|
||||
#include "PFXOrder.h"
|
||||
#include <QMap>
|
||||
@ -21,6 +22,7 @@
|
||||
#include <QObject>
|
||||
#include <QByteArray>
|
||||
#include <QStringList>
|
||||
#include <QList>
|
||||
#include <QNetworkAccessManager>
|
||||
|
||||
namespace test_namespace {
|
||||
@ -32,6 +34,9 @@ public:
|
||||
PFXStoreApi(const QString &scheme = "http", const QString &host = "petstore.swagger.io", int port = 0, const QString &basePath = "/v2", const int timeOut = 0);
|
||||
~PFXStoreApi();
|
||||
|
||||
void initializeServerConfigs();
|
||||
int setDefaultServerValue(int serverIndex,const QString &operation, const QString &variable,const QString &val);
|
||||
void setServerIndex(const QString &operation, int serverIndex);
|
||||
void setScheme(const QString &scheme);
|
||||
void setHost(const QString &host);
|
||||
void setPort(int port);
|
||||
@ -56,11 +61,13 @@ public:
|
||||
private:
|
||||
QString _scheme, _host;
|
||||
int _port;
|
||||
QString _basePath;
|
||||
QMap<QString,int> _serverIndices;
|
||||
QMap<QString,QList<PFXServerConfiguration>> _serverConfigs;
|
||||
QMap<QString, QString> _apiKeys;
|
||||
QString _bearerToken;
|
||||
QString _username;
|
||||
QString _password;
|
||||
QString _basePath;
|
||||
int _timeOut;
|
||||
QString _workingDirectory;
|
||||
QNetworkAccessManager* _manager;
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
#include "PFXUserApi.h"
|
||||
#include "PFXHelpers.h"
|
||||
|
||||
#include "PFXServerConfiguration.h"
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
|
||||
@ -25,11 +25,66 @@ PFXUserApi::PFXUserApi(const QString &scheme, const QString &host, int port, con
|
||||
_timeOut(timeOut),
|
||||
_manager(nullptr),
|
||||
isResponseCompressionEnabled(false),
|
||||
isRequestCompressionEnabled(false) {}
|
||||
isRequestCompressionEnabled(false) {
|
||||
initializeServerConfigs();
|
||||
}
|
||||
|
||||
PFXUserApi::~PFXUserApi() {
|
||||
}
|
||||
|
||||
void PFXUserApi::initializeServerConfigs(){
|
||||
|
||||
//Default server
|
||||
QList<PFXServerConfiguration> defaultConf = QList<PFXServerConfiguration>();
|
||||
//varying endpoint server
|
||||
QList<PFXServerConfiguration> serverConf = QList<PFXServerConfiguration>();
|
||||
defaultConf.append(PFXServerConfiguration(
|
||||
"http://petstore.swagger.io/v2",
|
||||
"No description provided",
|
||||
QMap<QString, PFXServerVariable>()));
|
||||
_serverConfigs.insert("createUser",defaultConf);
|
||||
_serverIndices.insert("createUser",0);
|
||||
|
||||
_serverConfigs.insert("createUsersWithArrayInput",defaultConf);
|
||||
_serverIndices.insert("createUsersWithArrayInput",0);
|
||||
|
||||
_serverConfigs.insert("createUsersWithListInput",defaultConf);
|
||||
_serverIndices.insert("createUsersWithListInput",0);
|
||||
|
||||
_serverConfigs.insert("deleteUser",defaultConf);
|
||||
_serverIndices.insert("deleteUser",0);
|
||||
|
||||
_serverConfigs.insert("getUserByName",defaultConf);
|
||||
_serverIndices.insert("getUserByName",0);
|
||||
|
||||
_serverConfigs.insert("loginUser",defaultConf);
|
||||
_serverIndices.insert("loginUser",0);
|
||||
|
||||
_serverConfigs.insert("logoutUser",defaultConf);
|
||||
_serverIndices.insert("logoutUser",0);
|
||||
|
||||
_serverConfigs.insert("updateUser",defaultConf);
|
||||
_serverIndices.insert("updateUser",0);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* returns 0 on success and -1, -2 or -3 on failure.
|
||||
* -1 when the variable does not exist and -2 if the value is not defined in the enum and -3 if the operation or server index is not found
|
||||
*/
|
||||
int PFXUserApi::setDefaultServerValue(int serverIndex, const QString &operation, const QString &variable, const QString &value){
|
||||
auto it = _serverConfigs.find(operation);
|
||||
if(it != _serverConfigs.end() && serverIndex < it.value().size() ){
|
||||
return _serverConfigs[operation][serverIndex].setDefaultValue(variable,value);
|
||||
}
|
||||
return -3;
|
||||
}
|
||||
void PFXUserApi::setServerIndex(const QString &operation, int serverIndex){
|
||||
if(_serverIndices.contains(operation) && serverIndex < _serverConfigs.find(operation).value().size() )
|
||||
_serverIndices[operation] = serverIndex;
|
||||
}
|
||||
|
||||
void PFXUserApi::setScheme(const QString &scheme) {
|
||||
_scheme = scheme;
|
||||
}
|
||||
@ -91,12 +146,7 @@ void PFXUserApi::abortRequests(){
|
||||
}
|
||||
|
||||
void PFXUserApi::createUser(const PFXUser &body) {
|
||||
QString fullPath = QString("%1://%2%3%4%5")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/user");
|
||||
QString fullPath = QString(_serverConfigs["createUser"][_serverIndices.value("createUser")].URL()+"/user");
|
||||
|
||||
|
||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager);
|
||||
@ -137,12 +187,7 @@ void PFXUserApi::createUserCallback(PFXHttpRequestWorker *worker) {
|
||||
}
|
||||
|
||||
void PFXUserApi::createUsersWithArrayInput(const QList<PFXUser> &body) {
|
||||
QString fullPath = QString("%1://%2%3%4%5")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/user/createWithArray");
|
||||
QString fullPath = QString(_serverConfigs["createUsersWithArrayInput"][_serverIndices.value("createUsersWithArrayInput")].URL()+"/user/createWithArray");
|
||||
|
||||
|
||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager);
|
||||
@ -184,12 +229,7 @@ void PFXUserApi::createUsersWithArrayInputCallback(PFXHttpRequestWorker *worker)
|
||||
}
|
||||
|
||||
void PFXUserApi::createUsersWithListInput(const QList<PFXUser> &body) {
|
||||
QString fullPath = QString("%1://%2%3%4%5")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/user/createWithList");
|
||||
QString fullPath = QString(_serverConfigs["createUsersWithListInput"][_serverIndices.value("createUsersWithListInput")].URL()+"/user/createWithList");
|
||||
|
||||
|
||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager);
|
||||
@ -231,12 +271,7 @@ void PFXUserApi::createUsersWithListInputCallback(PFXHttpRequestWorker *worker)
|
||||
}
|
||||
|
||||
void PFXUserApi::deleteUser(const QString &username) {
|
||||
QString fullPath = QString("%1://%2%3%4%5")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/user/{username}");
|
||||
QString fullPath = QString(_serverConfigs["deleteUser"][_serverIndices.value("deleteUser")].URL()+"/user/{username}");
|
||||
QString usernamePathParam("{");
|
||||
usernamePathParam.append("username").append("}");
|
||||
fullPath.replace(usernamePathParam, QUrl::toPercentEncoding(::test_namespace::toStringValue(username)));
|
||||
@ -277,12 +312,7 @@ void PFXUserApi::deleteUserCallback(PFXHttpRequestWorker *worker) {
|
||||
}
|
||||
|
||||
void PFXUserApi::getUserByName(const QString &username) {
|
||||
QString fullPath = QString("%1://%2%3%4%5")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/user/{username}");
|
||||
QString fullPath = QString(_serverConfigs["getUserByName"][_serverIndices.value("getUserByName")].URL()+"/user/{username}");
|
||||
QString usernamePathParam("{");
|
||||
usernamePathParam.append("username").append("}");
|
||||
fullPath.replace(usernamePathParam, QUrl::toPercentEncoding(::test_namespace::toStringValue(username)));
|
||||
@ -324,12 +354,7 @@ void PFXUserApi::getUserByNameCallback(PFXHttpRequestWorker *worker) {
|
||||
}
|
||||
|
||||
void PFXUserApi::loginUser(const QString &username, const QString &password) {
|
||||
QString fullPath = QString("%1://%2%3%4%5")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/user/login");
|
||||
QString fullPath = QString(_serverConfigs["loginUser"][_serverIndices.value("loginUser")].URL()+"/user/login");
|
||||
|
||||
|
||||
if (fullPath.indexOf("?") > 0)
|
||||
@ -381,12 +406,7 @@ void PFXUserApi::loginUserCallback(PFXHttpRequestWorker *worker) {
|
||||
}
|
||||
|
||||
void PFXUserApi::logoutUser() {
|
||||
QString fullPath = QString("%1://%2%3%4%5")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/user/logout");
|
||||
QString fullPath = QString(_serverConfigs["logoutUser"][_serverIndices.value("logoutUser")].URL()+"/user/logout");
|
||||
|
||||
|
||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager);
|
||||
@ -424,12 +444,7 @@ void PFXUserApi::logoutUserCallback(PFXHttpRequestWorker *worker) {
|
||||
}
|
||||
|
||||
void PFXUserApi::updateUser(const QString &username, const PFXUser &body) {
|
||||
QString fullPath = QString("%1://%2%3%4%5")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/user/{username}");
|
||||
QString fullPath = QString(_serverConfigs["updateUser"][_serverIndices.value("updateUser")].URL()+"/user/{username}");
|
||||
QString usernamePathParam("{");
|
||||
usernamePathParam.append("username").append("}");
|
||||
fullPath.replace(usernamePathParam, QUrl::toPercentEncoding(::test_namespace::toStringValue(username)));
|
||||
|
@ -13,6 +13,7 @@
|
||||
#define PFX_PFXUserApi_H
|
||||
|
||||
#include "PFXHttpRequest.h"
|
||||
#include "PFXServerConfiguration.h"
|
||||
|
||||
#include "PFXUser.h"
|
||||
#include <QList>
|
||||
@ -21,6 +22,7 @@
|
||||
#include <QObject>
|
||||
#include <QByteArray>
|
||||
#include <QStringList>
|
||||
#include <QList>
|
||||
#include <QNetworkAccessManager>
|
||||
|
||||
namespace test_namespace {
|
||||
@ -32,6 +34,9 @@ public:
|
||||
PFXUserApi(const QString &scheme = "http", const QString &host = "petstore.swagger.io", int port = 0, const QString &basePath = "/v2", const int timeOut = 0);
|
||||
~PFXUserApi();
|
||||
|
||||
void initializeServerConfigs();
|
||||
int setDefaultServerValue(int serverIndex,const QString &operation, const QString &variable,const QString &val);
|
||||
void setServerIndex(const QString &operation, int serverIndex);
|
||||
void setScheme(const QString &scheme);
|
||||
void setHost(const QString &host);
|
||||
void setPort(int port);
|
||||
@ -60,11 +65,13 @@ public:
|
||||
private:
|
||||
QString _scheme, _host;
|
||||
int _port;
|
||||
QString _basePath;
|
||||
QMap<QString,int> _serverIndices;
|
||||
QMap<QString,QList<PFXServerConfiguration>> _serverConfigs;
|
||||
QMap<QString, QString> _apiKeys;
|
||||
QString _bearerToken;
|
||||
QString _username;
|
||||
QString _password;
|
||||
QString _basePath;
|
||||
int _timeOut;
|
||||
QString _workingDirectory;
|
||||
QNetworkAccessManager* _manager;
|
||||
|
@ -17,7 +17,9 @@ HEADERS += \
|
||||
$${PWD}/PFXHttpRequest.h \
|
||||
$${PWD}/PFXObject.h \
|
||||
$${PWD}/PFXEnum.h \
|
||||
$${PWD}/PFXHttpFileElement.h
|
||||
$${PWD}/PFXHttpFileElement.h \
|
||||
$${PWD}/PFXServerConfiguration.h \
|
||||
$${PWD}/PFXServerVariable.h
|
||||
|
||||
SOURCES += \
|
||||
# Models
|
||||
|
75
samples/client/petstore/cpp-qt5/client/ServerConfiguration.h
Normal file
75
samples/client/petstore/cpp-qt5/client/ServerConfiguration.h
Normal file
@ -0,0 +1,75 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Representing a Server configuration.
|
||||
*/
|
||||
#ifndef SERVERVCONFIGURATION_H
|
||||
#define SERVERVCONFIGURATION_H
|
||||
#include <QString>
|
||||
#include <QMap>
|
||||
#include <stdexcept>
|
||||
#include <QRegularExpression>
|
||||
#include "ServerVariable.h"
|
||||
|
||||
class ServerConfiguration {
|
||||
public:
|
||||
/**
|
||||
* @param URL A URL to the target host.
|
||||
* @param description A description of the host designated by the URL.
|
||||
* @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
|
||||
*/
|
||||
ServerConfiguration(const QString& URL, const QString& description, const QMap<QString, ServerVariable>& variables)
|
||||
: _description(description),
|
||||
_variables(variables),
|
||||
_URL(URL){}
|
||||
ServerConfiguration(){}
|
||||
~ServerConfiguration(){}
|
||||
|
||||
/**
|
||||
* Format URL template using given variables.
|
||||
*
|
||||
* @param variables A map between a variable name and its value.
|
||||
* @return Formatted URL.
|
||||
*/
|
||||
QString URL() {
|
||||
QString url = _URL;
|
||||
if(!_variables.empty()){
|
||||
// go through variables and replace placeholders
|
||||
for (auto const& v : _variables.keys()) {
|
||||
QString name = v;
|
||||
ServerVariable serverVariable = _variables.value(v);
|
||||
QString value = serverVariable._defaultValue;
|
||||
|
||||
if (!serverVariable._enumValues.empty() && !serverVariable._enumValues.contains(value)) {
|
||||
throw std::runtime_error(QString("The variable " + name + " in the server URL has invalid value " + value + ".").toUtf8());
|
||||
}
|
||||
QRegularExpression regex(QString("\\{" + name + "\\}"));
|
||||
url = url.replace(regex, value);
|
||||
|
||||
}
|
||||
return url;
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
int setDefaultValue(const QString& variable,const QString& value){
|
||||
if(_variables.contains(variable))
|
||||
return _variables[variable].setDefaultValue(value);
|
||||
return -1;
|
||||
}
|
||||
|
||||
QString _description;
|
||||
QMap<QString, ServerVariable> _variables;
|
||||
QString _URL;
|
||||
|
||||
};
|
||||
#endif
|
53
samples/client/petstore/cpp-qt5/client/ServerVariable.h
Normal file
53
samples/client/petstore/cpp-qt5/client/ServerVariable.h
Normal file
@ -0,0 +1,53 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
#ifndef SERVERVARIABLE_H
|
||||
#define SERVERVARIABLE_H
|
||||
#include <unordered_set>
|
||||
#include <QString>
|
||||
#include <QSet>
|
||||
/**
|
||||
* Representing a Server Variable for server URL template substitution.
|
||||
*/
|
||||
class ServerVariable {
|
||||
public:
|
||||
|
||||
/**
|
||||
* @param description A description for the server variable.
|
||||
* @param defaultValue The default value to use for substitution.
|
||||
* @param enumValues An enumeration of string values to be used if the substitution options are from a limited set.
|
||||
*/
|
||||
ServerVariable(const QString &description, const QString &defaultValue, const QSet<QString> &enumValues)
|
||||
: _defaultValue(defaultValue),
|
||||
_description(description),
|
||||
_enumValues(enumValues){}
|
||||
|
||||
ServerVariable(){}
|
||||
~ServerVariable(){}
|
||||
|
||||
int setDefaultValue(const QString& value){
|
||||
if( _enumValues.contains(value)){
|
||||
_defaultValue = value;
|
||||
return 0;
|
||||
}
|
||||
return -2;
|
||||
}
|
||||
|
||||
QString getDefaultValue(){return _defaultValue;}
|
||||
QSet<QString> getEnumValues(){return _enumValues;}
|
||||
|
||||
|
||||
QString _defaultValue;
|
||||
QString _description;
|
||||
QSet<QString> _enumValues;
|
||||
|
||||
};
|
||||
#endif
|
29
samples/client/petstore/cpp-tizen/.openapi-generator/FILES
Normal file
29
samples/client/petstore/cpp-tizen/.openapi-generator/FILES
Normal file
@ -0,0 +1,29 @@
|
||||
doc/Doxyfile
|
||||
doc/README.md
|
||||
doc/generateDocumentation.sh
|
||||
src/ApiResponse.cpp
|
||||
src/ApiResponse.h
|
||||
src/Category.cpp
|
||||
src/Category.h
|
||||
src/Error.cpp
|
||||
src/Error.h
|
||||
src/Helpers.cpp
|
||||
src/Helpers.h
|
||||
src/NetClient.cpp
|
||||
src/NetClient.h
|
||||
src/Object.h
|
||||
src/Order.cpp
|
||||
src/Order.h
|
||||
src/Pet.cpp
|
||||
src/Pet.h
|
||||
src/PetManager.cpp
|
||||
src/PetManager.h
|
||||
src/RequestInfo.h
|
||||
src/StoreManager.cpp
|
||||
src/StoreManager.h
|
||||
src/Tag.cpp
|
||||
src/Tag.h
|
||||
src/User.cpp
|
||||
src/User.h
|
||||
src/UserManager.cpp
|
||||
src/UserManager.h
|
@ -1 +1 @@
|
||||
3.2.0-SNAPSHOT
|
||||
5.0.0-SNAPSHOT
|
@ -82,7 +82,7 @@ static bool addPetProcessor(MemoryStruct_s p_chunk, long code, char* errormsg, v
|
||||
}
|
||||
|
||||
static bool addPetHelper(char * accessToken,
|
||||
Pet pet,
|
||||
Pet body,
|
||||
|
||||
void(* handler)(Error, void* ) , void* userData, bool isAsync)
|
||||
{
|
||||
@ -105,10 +105,10 @@ static bool addPetHelper(char * accessToken,
|
||||
JsonArray* json_array;
|
||||
|
||||
if (isprimitive("Pet")) {
|
||||
node = converttoJson(&pet, "Pet", "");
|
||||
node = converttoJson(&body, "Pet", "");
|
||||
}
|
||||
|
||||
char *jsonStr = pet.toJson();
|
||||
char *jsonStr = body.toJson();
|
||||
node = json_from_string(jsonStr, NULL);
|
||||
g_free(static_cast<gpointer>(jsonStr));
|
||||
|
||||
@ -167,22 +167,22 @@ static bool addPetHelper(char * accessToken,
|
||||
|
||||
|
||||
bool PetManager::addPetAsync(char * accessToken,
|
||||
Pet pet,
|
||||
Pet body,
|
||||
|
||||
void(* handler)(Error, void* ) , void* userData)
|
||||
{
|
||||
return addPetHelper(accessToken,
|
||||
pet,
|
||||
body,
|
||||
handler, userData, true);
|
||||
}
|
||||
|
||||
bool PetManager::addPetSync(char * accessToken,
|
||||
Pet pet,
|
||||
Pet body,
|
||||
|
||||
void(* handler)(Error, void* ) , void* userData)
|
||||
{
|
||||
return addPetHelper(accessToken,
|
||||
pet,
|
||||
body,
|
||||
handler, userData, false);
|
||||
}
|
||||
|
||||
@ -796,7 +796,7 @@ static bool updatePetProcessor(MemoryStruct_s p_chunk, long code, char* errormsg
|
||||
}
|
||||
|
||||
static bool updatePetHelper(char * accessToken,
|
||||
Pet pet,
|
||||
Pet body,
|
||||
|
||||
void(* handler)(Error, void* ) , void* userData, bool isAsync)
|
||||
{
|
||||
@ -819,10 +819,10 @@ static bool updatePetHelper(char * accessToken,
|
||||
JsonArray* json_array;
|
||||
|
||||
if (isprimitive("Pet")) {
|
||||
node = converttoJson(&pet, "Pet", "");
|
||||
node = converttoJson(&body, "Pet", "");
|
||||
}
|
||||
|
||||
char *jsonStr = pet.toJson();
|
||||
char *jsonStr = body.toJson();
|
||||
node = json_from_string(jsonStr, NULL);
|
||||
g_free(static_cast<gpointer>(jsonStr));
|
||||
|
||||
@ -881,22 +881,22 @@ static bool updatePetHelper(char * accessToken,
|
||||
|
||||
|
||||
bool PetManager::updatePetAsync(char * accessToken,
|
||||
Pet pet,
|
||||
Pet body,
|
||||
|
||||
void(* handler)(Error, void* ) , void* userData)
|
||||
{
|
||||
return updatePetHelper(accessToken,
|
||||
pet,
|
||||
body,
|
||||
handler, userData, true);
|
||||
}
|
||||
|
||||
bool PetManager::updatePetSync(char * accessToken,
|
||||
Pet pet,
|
||||
Pet body,
|
||||
|
||||
void(* handler)(Error, void* ) , void* userData)
|
||||
{
|
||||
return updatePetHelper(accessToken,
|
||||
pet,
|
||||
body,
|
||||
handler, userData, false);
|
||||
}
|
||||
|
||||
|
@ -28,26 +28,26 @@ public:
|
||||
/*! \brief Add a new pet to the store. *Synchronous*
|
||||
*
|
||||
*
|
||||
* \param pet Pet object that needs to be added to the store *Required*
|
||||
* \param body Pet object that needs to be added to the store *Required*
|
||||
* \param handler The callback function to be invoked on completion. *Required*
|
||||
* \param accessToken The Authorization token. *Required*
|
||||
* \param userData The user data to be passed to the callback function.
|
||||
*/
|
||||
bool addPetSync(char * accessToken,
|
||||
Pet pet,
|
||||
Pet body,
|
||||
|
||||
void(* handler)(Error, void* ) , void* userData);
|
||||
|
||||
/*! \brief Add a new pet to the store. *Asynchronous*
|
||||
*
|
||||
*
|
||||
* \param pet Pet object that needs to be added to the store *Required*
|
||||
* \param body Pet object that needs to be added to the store *Required*
|
||||
* \param handler The callback function to be invoked on completion. *Required*
|
||||
* \param accessToken The Authorization token. *Required*
|
||||
* \param userData The user data to be passed to the callback function.
|
||||
*/
|
||||
bool addPetAsync(char * accessToken,
|
||||
Pet pet,
|
||||
Pet body,
|
||||
|
||||
void(* handler)(Error, void* ) , void* userData);
|
||||
|
||||
@ -165,26 +165,26 @@ bool getPetByIdAsync(char * accessToken,
|
||||
/*! \brief Update an existing pet. *Synchronous*
|
||||
*
|
||||
*
|
||||
* \param pet Pet object that needs to be added to the store *Required*
|
||||
* \param body Pet object that needs to be added to the store *Required*
|
||||
* \param handler The callback function to be invoked on completion. *Required*
|
||||
* \param accessToken The Authorization token. *Required*
|
||||
* \param userData The user data to be passed to the callback function.
|
||||
*/
|
||||
bool updatePetSync(char * accessToken,
|
||||
Pet pet,
|
||||
Pet body,
|
||||
|
||||
void(* handler)(Error, void* ) , void* userData);
|
||||
|
||||
/*! \brief Update an existing pet. *Asynchronous*
|
||||
*
|
||||
*
|
||||
* \param pet Pet object that needs to be added to the store *Required*
|
||||
* \param body Pet object that needs to be added to the store *Required*
|
||||
* \param handler The callback function to be invoked on completion. *Required*
|
||||
* \param accessToken The Authorization token. *Required*
|
||||
* \param userData The user data to be passed to the callback function.
|
||||
*/
|
||||
bool updatePetAsync(char * accessToken,
|
||||
Pet pet,
|
||||
Pet body,
|
||||
|
||||
void(* handler)(Error, void* ) , void* userData);
|
||||
|
||||
|
@ -510,7 +510,7 @@ static bool placeOrderProcessor(MemoryStruct_s p_chunk, long code, char* errorms
|
||||
}
|
||||
|
||||
static bool placeOrderHelper(char * accessToken,
|
||||
Order order,
|
||||
Order body,
|
||||
void(* handler)(Order, Error, void* )
|
||||
, void* userData, bool isAsync)
|
||||
{
|
||||
@ -532,10 +532,10 @@ static bool placeOrderHelper(char * accessToken,
|
||||
JsonArray* json_array;
|
||||
|
||||
if (isprimitive("Order")) {
|
||||
node = converttoJson(&order, "Order", "");
|
||||
node = converttoJson(&body, "Order", "");
|
||||
}
|
||||
|
||||
char *jsonStr = order.toJson();
|
||||
char *jsonStr = body.toJson();
|
||||
node = json_from_string(jsonStr, NULL);
|
||||
g_free(static_cast<gpointer>(jsonStr));
|
||||
|
||||
@ -594,22 +594,22 @@ static bool placeOrderHelper(char * accessToken,
|
||||
|
||||
|
||||
bool StoreManager::placeOrderAsync(char * accessToken,
|
||||
Order order,
|
||||
Order body,
|
||||
void(* handler)(Order, Error, void* )
|
||||
, void* userData)
|
||||
{
|
||||
return placeOrderHelper(accessToken,
|
||||
order,
|
||||
body,
|
||||
handler, userData, true);
|
||||
}
|
||||
|
||||
bool StoreManager::placeOrderSync(char * accessToken,
|
||||
Order order,
|
||||
Order body,
|
||||
void(* handler)(Order, Error, void* )
|
||||
, void* userData)
|
||||
{
|
||||
return placeOrderHelper(accessToken,
|
||||
order,
|
||||
body,
|
||||
handler, userData, false);
|
||||
}
|
||||
|
||||
|
@ -107,26 +107,26 @@ bool getOrderByIdAsync(char * accessToken,
|
||||
/*! \brief Place an order for a pet. *Synchronous*
|
||||
*
|
||||
*
|
||||
* \param order order placed for purchasing the pet *Required*
|
||||
* \param body order placed for purchasing the pet *Required*
|
||||
* \param handler The callback function to be invoked on completion. *Required*
|
||||
* \param accessToken The Authorization token. *Required*
|
||||
* \param userData The user data to be passed to the callback function.
|
||||
*/
|
||||
bool placeOrderSync(char * accessToken,
|
||||
Order order,
|
||||
Order body,
|
||||
void(* handler)(Order, Error, void* )
|
||||
, void* userData);
|
||||
|
||||
/*! \brief Place an order for a pet. *Asynchronous*
|
||||
*
|
||||
*
|
||||
* \param order order placed for purchasing the pet *Required*
|
||||
* \param body order placed for purchasing the pet *Required*
|
||||
* \param handler The callback function to be invoked on completion. *Required*
|
||||
* \param accessToken The Authorization token. *Required*
|
||||
* \param userData The user data to be passed to the callback function.
|
||||
*/
|
||||
bool placeOrderAsync(char * accessToken,
|
||||
Order order,
|
||||
Order body,
|
||||
void(* handler)(Order, Error, void* )
|
||||
, void* userData);
|
||||
|
||||
|
@ -82,7 +82,7 @@ static bool createUserProcessor(MemoryStruct_s p_chunk, long code, char* errorms
|
||||
}
|
||||
|
||||
static bool createUserHelper(char * accessToken,
|
||||
User user,
|
||||
User body,
|
||||
|
||||
void(* handler)(Error, void* ) , void* userData, bool isAsync)
|
||||
{
|
||||
@ -104,10 +104,10 @@ static bool createUserHelper(char * accessToken,
|
||||
JsonArray* json_array;
|
||||
|
||||
if (isprimitive("User")) {
|
||||
node = converttoJson(&user, "User", "");
|
||||
node = converttoJson(&body, "User", "");
|
||||
}
|
||||
|
||||
char *jsonStr = user.toJson();
|
||||
char *jsonStr = body.toJson();
|
||||
node = json_from_string(jsonStr, NULL);
|
||||
g_free(static_cast<gpointer>(jsonStr));
|
||||
|
||||
@ -166,22 +166,22 @@ static bool createUserHelper(char * accessToken,
|
||||
|
||||
|
||||
bool UserManager::createUserAsync(char * accessToken,
|
||||
User user,
|
||||
User body,
|
||||
|
||||
void(* handler)(Error, void* ) , void* userData)
|
||||
{
|
||||
return createUserHelper(accessToken,
|
||||
user,
|
||||
body,
|
||||
handler, userData, true);
|
||||
}
|
||||
|
||||
bool UserManager::createUserSync(char * accessToken,
|
||||
User user,
|
||||
User body,
|
||||
|
||||
void(* handler)(Error, void* ) , void* userData)
|
||||
{
|
||||
return createUserHelper(accessToken,
|
||||
user,
|
||||
body,
|
||||
handler, userData, false);
|
||||
}
|
||||
|
||||
@ -219,7 +219,7 @@ static bool createUsersWithArrayInputProcessor(MemoryStruct_s p_chunk, long code
|
||||
}
|
||||
|
||||
static bool createUsersWithArrayInputHelper(char * accessToken,
|
||||
std::list<std::list> user,
|
||||
std::list<User> body,
|
||||
|
||||
void(* handler)(Error, void* ) , void* userData, bool isAsync)
|
||||
{
|
||||
@ -240,14 +240,14 @@ static bool createUsersWithArrayInputHelper(char * accessToken,
|
||||
JsonNode* node;
|
||||
JsonArray* json_array;
|
||||
//TODO: Map Container
|
||||
if (isprimitive("std::list")) {
|
||||
node = converttoJson(&user, "std::list", "array");
|
||||
if (isprimitive("User")) {
|
||||
node = converttoJson(&body, "User", "array");
|
||||
} else {
|
||||
node = json_node_alloc();
|
||||
json_array = json_array_new();
|
||||
for (std::list
|
||||
<std::list>::iterator bodyIter = user.begin(); bodyIter != user.end(); ++bodyIter) {
|
||||
std::list itemAt = (*bodyIter);
|
||||
<User>::iterator bodyIter = body.begin(); bodyIter != body.end(); ++bodyIter) {
|
||||
User itemAt = (*bodyIter);
|
||||
char *jsonStr = itemAt.toJson();
|
||||
JsonNode *node_temp = json_from_string(jsonStr, NULL);
|
||||
g_free(static_cast<gpointer>(jsonStr));
|
||||
@ -315,22 +315,22 @@ static bool createUsersWithArrayInputHelper(char * accessToken,
|
||||
|
||||
|
||||
bool UserManager::createUsersWithArrayInputAsync(char * accessToken,
|
||||
std::list<std::list> user,
|
||||
std::list<User> body,
|
||||
|
||||
void(* handler)(Error, void* ) , void* userData)
|
||||
{
|
||||
return createUsersWithArrayInputHelper(accessToken,
|
||||
user,
|
||||
body,
|
||||
handler, userData, true);
|
||||
}
|
||||
|
||||
bool UserManager::createUsersWithArrayInputSync(char * accessToken,
|
||||
std::list<std::list> user,
|
||||
std::list<User> body,
|
||||
|
||||
void(* handler)(Error, void* ) , void* userData)
|
||||
{
|
||||
return createUsersWithArrayInputHelper(accessToken,
|
||||
user,
|
||||
body,
|
||||
handler, userData, false);
|
||||
}
|
||||
|
||||
@ -368,7 +368,7 @@ static bool createUsersWithListInputProcessor(MemoryStruct_s p_chunk, long code,
|
||||
}
|
||||
|
||||
static bool createUsersWithListInputHelper(char * accessToken,
|
||||
std::list<std::list> user,
|
||||
std::list<User> body,
|
||||
|
||||
void(* handler)(Error, void* ) , void* userData, bool isAsync)
|
||||
{
|
||||
@ -389,14 +389,14 @@ static bool createUsersWithListInputHelper(char * accessToken,
|
||||
JsonNode* node;
|
||||
JsonArray* json_array;
|
||||
//TODO: Map Container
|
||||
if (isprimitive("std::list")) {
|
||||
node = converttoJson(&user, "std::list", "array");
|
||||
if (isprimitive("User")) {
|
||||
node = converttoJson(&body, "User", "array");
|
||||
} else {
|
||||
node = json_node_alloc();
|
||||
json_array = json_array_new();
|
||||
for (std::list
|
||||
<std::list>::iterator bodyIter = user.begin(); bodyIter != user.end(); ++bodyIter) {
|
||||
std::list itemAt = (*bodyIter);
|
||||
<User>::iterator bodyIter = body.begin(); bodyIter != body.end(); ++bodyIter) {
|
||||
User itemAt = (*bodyIter);
|
||||
char *jsonStr = itemAt.toJson();
|
||||
JsonNode *node_temp = json_from_string(jsonStr, NULL);
|
||||
g_free(static_cast<gpointer>(jsonStr));
|
||||
@ -464,22 +464,22 @@ static bool createUsersWithListInputHelper(char * accessToken,
|
||||
|
||||
|
||||
bool UserManager::createUsersWithListInputAsync(char * accessToken,
|
||||
std::list<std::list> user,
|
||||
std::list<User> body,
|
||||
|
||||
void(* handler)(Error, void* ) , void* userData)
|
||||
{
|
||||
return createUsersWithListInputHelper(accessToken,
|
||||
user,
|
||||
body,
|
||||
handler, userData, true);
|
||||
}
|
||||
|
||||
bool UserManager::createUsersWithListInputSync(char * accessToken,
|
||||
std::list<std::list> user,
|
||||
std::list<User> body,
|
||||
|
||||
void(* handler)(Error, void* ) , void* userData)
|
||||
{
|
||||
return createUsersWithListInputHelper(accessToken,
|
||||
user,
|
||||
body,
|
||||
handler, userData, false);
|
||||
}
|
||||
|
||||
@ -1072,7 +1072,7 @@ static bool updateUserProcessor(MemoryStruct_s p_chunk, long code, char* errorms
|
||||
}
|
||||
|
||||
static bool updateUserHelper(char * accessToken,
|
||||
std::string username, User user,
|
||||
std::string username, User body,
|
||||
|
||||
void(* handler)(Error, void* ) , void* userData, bool isAsync)
|
||||
{
|
||||
@ -1094,10 +1094,10 @@ static bool updateUserHelper(char * accessToken,
|
||||
JsonArray* json_array;
|
||||
|
||||
if (isprimitive("User")) {
|
||||
node = converttoJson(&user, "User", "");
|
||||
node = converttoJson(&body, "User", "");
|
||||
}
|
||||
|
||||
char *jsonStr = user.toJson();
|
||||
char *jsonStr = body.toJson();
|
||||
node = json_from_string(jsonStr, NULL);
|
||||
g_free(static_cast<gpointer>(jsonStr));
|
||||
|
||||
@ -1162,22 +1162,22 @@ static bool updateUserHelper(char * accessToken,
|
||||
|
||||
|
||||
bool UserManager::updateUserAsync(char * accessToken,
|
||||
std::string username, User user,
|
||||
std::string username, User body,
|
||||
|
||||
void(* handler)(Error, void* ) , void* userData)
|
||||
{
|
||||
return updateUserHelper(accessToken,
|
||||
username, user,
|
||||
username, body,
|
||||
handler, userData, true);
|
||||
}
|
||||
|
||||
bool UserManager::updateUserSync(char * accessToken,
|
||||
std::string username, User user,
|
||||
std::string username, User body,
|
||||
|
||||
void(* handler)(Error, void* ) , void* userData)
|
||||
{
|
||||
return updateUserHelper(accessToken,
|
||||
username, user,
|
||||
username, body,
|
||||
handler, userData, false);
|
||||
}
|
||||
|
||||
|
@ -28,26 +28,26 @@ public:
|
||||
/*! \brief Create user. *Synchronous*
|
||||
*
|
||||
* This can only be done by the logged in user.
|
||||
* \param user Created user object *Required*
|
||||
* \param body Created user object *Required*
|
||||
* \param handler The callback function to be invoked on completion. *Required*
|
||||
* \param accessToken The Authorization token. *Required*
|
||||
* \param userData The user data to be passed to the callback function.
|
||||
*/
|
||||
bool createUserSync(char * accessToken,
|
||||
User user,
|
||||
User body,
|
||||
|
||||
void(* handler)(Error, void* ) , void* userData);
|
||||
|
||||
/*! \brief Create user. *Asynchronous*
|
||||
*
|
||||
* This can only be done by the logged in user.
|
||||
* \param user Created user object *Required*
|
||||
* \param body Created user object *Required*
|
||||
* \param handler The callback function to be invoked on completion. *Required*
|
||||
* \param accessToken The Authorization token. *Required*
|
||||
* \param userData The user data to be passed to the callback function.
|
||||
*/
|
||||
bool createUserAsync(char * accessToken,
|
||||
User user,
|
||||
User body,
|
||||
|
||||
void(* handler)(Error, void* ) , void* userData);
|
||||
|
||||
@ -55,26 +55,26 @@ bool createUserAsync(char * accessToken,
|
||||
/*! \brief Creates list of users with given input array. *Synchronous*
|
||||
*
|
||||
*
|
||||
* \param user List of user object *Required*
|
||||
* \param body List of user object *Required*
|
||||
* \param handler The callback function to be invoked on completion. *Required*
|
||||
* \param accessToken The Authorization token. *Required*
|
||||
* \param userData The user data to be passed to the callback function.
|
||||
*/
|
||||
bool createUsersWithArrayInputSync(char * accessToken,
|
||||
std::list<std::list> user,
|
||||
std::list<User> body,
|
||||
|
||||
void(* handler)(Error, void* ) , void* userData);
|
||||
|
||||
/*! \brief Creates list of users with given input array. *Asynchronous*
|
||||
*
|
||||
*
|
||||
* \param user List of user object *Required*
|
||||
* \param body List of user object *Required*
|
||||
* \param handler The callback function to be invoked on completion. *Required*
|
||||
* \param accessToken The Authorization token. *Required*
|
||||
* \param userData The user data to be passed to the callback function.
|
||||
*/
|
||||
bool createUsersWithArrayInputAsync(char * accessToken,
|
||||
std::list<std::list> user,
|
||||
std::list<User> body,
|
||||
|
||||
void(* handler)(Error, void* ) , void* userData);
|
||||
|
||||
@ -82,26 +82,26 @@ bool createUsersWithArrayInputAsync(char * accessToken,
|
||||
/*! \brief Creates list of users with given input array. *Synchronous*
|
||||
*
|
||||
*
|
||||
* \param user List of user object *Required*
|
||||
* \param body List of user object *Required*
|
||||
* \param handler The callback function to be invoked on completion. *Required*
|
||||
* \param accessToken The Authorization token. *Required*
|
||||
* \param userData The user data to be passed to the callback function.
|
||||
*/
|
||||
bool createUsersWithListInputSync(char * accessToken,
|
||||
std::list<std::list> user,
|
||||
std::list<User> body,
|
||||
|
||||
void(* handler)(Error, void* ) , void* userData);
|
||||
|
||||
/*! \brief Creates list of users with given input array. *Asynchronous*
|
||||
*
|
||||
*
|
||||
* \param user List of user object *Required*
|
||||
* \param body List of user object *Required*
|
||||
* \param handler The callback function to be invoked on completion. *Required*
|
||||
* \param accessToken The Authorization token. *Required*
|
||||
* \param userData The user data to be passed to the callback function.
|
||||
*/
|
||||
bool createUsersWithListInputAsync(char * accessToken,
|
||||
std::list<std::list> user,
|
||||
std::list<User> body,
|
||||
|
||||
void(* handler)(Error, void* ) , void* userData);
|
||||
|
||||
@ -218,13 +218,13 @@ bool logoutUserAsync(char * accessToken,
|
||||
*
|
||||
* This can only be done by the logged in user.
|
||||
* \param username name that need to be deleted *Required*
|
||||
* \param user Updated user object *Required*
|
||||
* \param body Updated user object *Required*
|
||||
* \param handler The callback function to be invoked on completion. *Required*
|
||||
* \param accessToken The Authorization token. *Required*
|
||||
* \param userData The user data to be passed to the callback function.
|
||||
*/
|
||||
bool updateUserSync(char * accessToken,
|
||||
std::string username, User user,
|
||||
std::string username, User body,
|
||||
|
||||
void(* handler)(Error, void* ) , void* userData);
|
||||
|
||||
@ -232,13 +232,13 @@ bool updateUserSync(char * accessToken,
|
||||
*
|
||||
* This can only be done by the logged in user.
|
||||
* \param username name that need to be deleted *Required*
|
||||
* \param user Updated user object *Required*
|
||||
* \param body Updated user object *Required*
|
||||
* \param handler The callback function to be invoked on completion. *Required*
|
||||
* \param accessToken The Authorization token. *Required*
|
||||
* \param userData The user data to be passed to the callback function.
|
||||
*/
|
||||
bool updateUserAsync(char * accessToken,
|
||||
std::string username, User user,
|
||||
std::string username, User body,
|
||||
|
||||
void(* handler)(Error, void* ) , void* userData);
|
||||
|
||||
|
@ -65,7 +65,11 @@ void OpenAPIPetApi::HandleResponse(FHttpResponsePtr HttpResponse, bool bSucceede
|
||||
FString ContentType = HttpResponse->GetContentType();
|
||||
FString Content;
|
||||
|
||||
if (ContentType == TEXT("application/json"))
|
||||
if (ContentType.IsEmpty())
|
||||
{
|
||||
return; // Nothing to parse
|
||||
}
|
||||
else if (ContentType.StartsWith(TEXT("application/json")) || ContentType.StartsWith("text/json"))
|
||||
{
|
||||
Content = HttpResponse->GetContentAsString();
|
||||
|
||||
@ -78,7 +82,7 @@ void OpenAPIPetApi::HandleResponse(FHttpResponsePtr HttpResponse, bool bSucceede
|
||||
return; // Successfully parsed
|
||||
}
|
||||
}
|
||||
else if(ContentType == TEXT("text/plain"))
|
||||
else if(ContentType.StartsWith(TEXT("text/plain")))
|
||||
{
|
||||
Content = HttpResponse->GetContentAsString();
|
||||
InOutResponse.SetResponseString(Content);
|
||||
|
@ -65,7 +65,11 @@ void OpenAPIStoreApi::HandleResponse(FHttpResponsePtr HttpResponse, bool bSuccee
|
||||
FString ContentType = HttpResponse->GetContentType();
|
||||
FString Content;
|
||||
|
||||
if (ContentType == TEXT("application/json"))
|
||||
if (ContentType.IsEmpty())
|
||||
{
|
||||
return; // Nothing to parse
|
||||
}
|
||||
else if (ContentType.StartsWith(TEXT("application/json")) || ContentType.StartsWith("text/json"))
|
||||
{
|
||||
Content = HttpResponse->GetContentAsString();
|
||||
|
||||
@ -78,7 +82,7 @@ void OpenAPIStoreApi::HandleResponse(FHttpResponsePtr HttpResponse, bool bSuccee
|
||||
return; // Successfully parsed
|
||||
}
|
||||
}
|
||||
else if(ContentType == TEXT("text/plain"))
|
||||
else if(ContentType.StartsWith(TEXT("text/plain")))
|
||||
{
|
||||
Content = HttpResponse->GetContentAsString();
|
||||
InOutResponse.SetResponseString(Content);
|
||||
|
@ -65,7 +65,11 @@ void OpenAPIUserApi::HandleResponse(FHttpResponsePtr HttpResponse, bool bSucceed
|
||||
FString ContentType = HttpResponse->GetContentType();
|
||||
FString Content;
|
||||
|
||||
if (ContentType == TEXT("application/json"))
|
||||
if (ContentType.IsEmpty())
|
||||
{
|
||||
return; // Nothing to parse
|
||||
}
|
||||
else if (ContentType.StartsWith(TEXT("application/json")) || ContentType.StartsWith("text/json"))
|
||||
{
|
||||
Content = HttpResponse->GetContentAsString();
|
||||
|
||||
@ -78,7 +82,7 @@ void OpenAPIUserApi::HandleResponse(FHttpResponsePtr HttpResponse, bool bSucceed
|
||||
return; // Successfully parsed
|
||||
}
|
||||
}
|
||||
else if(ContentType == TEXT("text/plain"))
|
||||
else if(ContentType.StartsWith(TEXT("text/plain")))
|
||||
{
|
||||
Content = HttpResponse->GetContentAsString();
|
||||
InOutResponse.SetResponseString(Content);
|
||||
|
21
samples/server/petstore/cpp-restbed/.openapi-generator/FILES
Normal file
21
samples/server/petstore/cpp-restbed/.openapi-generator/FILES
Normal file
@ -0,0 +1,21 @@
|
||||
.gitignore
|
||||
README.md
|
||||
api/PetApi.cpp
|
||||
api/PetApi.h
|
||||
api/StoreApi.cpp
|
||||
api/StoreApi.h
|
||||
api/UserApi.cpp
|
||||
api/UserApi.h
|
||||
git_push.sh
|
||||
model/ApiResponse.cpp
|
||||
model/ApiResponse.h
|
||||
model/Category.cpp
|
||||
model/Category.h
|
||||
model/Order.cpp
|
||||
model/Order.h
|
||||
model/Pet.cpp
|
||||
model/Pet.h
|
||||
model/Tag.cpp
|
||||
model/Tag.h
|
||||
model/User.cpp
|
||||
model/User.h
|
Loading…
x
Reference in New Issue
Block a user