forked from loafle/openapi-generator-original
[Qt5] rename the extension (#8236)
* rename extension, move config * purge folder, regenerate samples
This commit is contained in:
parent
b127cc7b70
commit
79a18b0440
@ -369,7 +369,7 @@ abstract public class AbstractCppCodegen extends DefaultCodegen implements Codeg
|
|||||||
}
|
}
|
||||||
CodegenServerList.add(s);
|
CodegenServerList.add(s);
|
||||||
}
|
}
|
||||||
this.vendorExtensions.put("x-codegen-globalServerList", CodegenServerList);
|
this.vendorExtensions.put("x-cpp-global-server-list", CodegenServerList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,8 +30,7 @@ void {{classname}}::initializeServerConfigs(){
|
|||||||
QList<{{prefix}}ServerConfiguration> defaultConf = QList<{{prefix}}ServerConfiguration>();
|
QList<{{prefix}}ServerConfiguration> defaultConf = QList<{{prefix}}ServerConfiguration>();
|
||||||
//varying endpoint server
|
//varying endpoint server
|
||||||
QList<{{prefix}}ServerConfiguration> serverConf = QList<{{prefix}}ServerConfiguration>();
|
QList<{{prefix}}ServerConfiguration> serverConf = QList<{{prefix}}ServerConfiguration>();
|
||||||
{{#vendorExtensions}}
|
{{#vendorExtensions.x-cpp-global-server-list}}
|
||||||
{{#x-codegen-globalServerList}}
|
|
||||||
defaultConf.append({{prefix}}ServerConfiguration(
|
defaultConf.append({{prefix}}ServerConfiguration(
|
||||||
"{{{url}}}",
|
"{{{url}}}",
|
||||||
"{{{description}}}{{^description}}No description provided{{/description}}",
|
"{{{description}}}{{^description}}No description provided{{/description}}",
|
||||||
@ -39,8 +38,7 @@ defaultConf.append({{prefix}}ServerConfiguration(
|
|||||||
{"{{{name}}}", {{prefix}}ServerVariable("{{{description}}}{{^description}}No description provided{{/description}}","{{{defaultValue}}}",
|
{"{{{name}}}", {{prefix}}ServerVariable("{{{description}}}{{^description}}No description provided{{/description}}","{{{defaultValue}}}",
|
||||||
QSet<QString>{ {{#enumValues}}{"{{{.}}}"}{{#-last}} })},{{/-last}}{{^-last}},{{/-last}}{{/enumValues}}{{^enumValues}}{"{{defaultValue}}"} })},{{/enumValues}}{{#-last}} }));{{/-last}}
|
QSet<QString>{ {{#enumValues}}{"{{{.}}}"}{{#-last}} })},{{/-last}}{{^-last}},{{/-last}}{{/enumValues}}{{^enumValues}}{"{{defaultValue}}"} })},{{/enumValues}}{{#-last}} }));{{/-last}}
|
||||||
{{/variables}}{{^variables}}QMap<QString, {{prefix}}ServerVariable>()));{{/variables}}
|
{{/variables}}{{^variables}}QMap<QString, {{prefix}}ServerVariable>()));{{/variables}}
|
||||||
{{/x-codegen-globalServerList}}
|
{{/vendorExtensions.x-cpp-global-server-list}}
|
||||||
{{/vendorExtensions}}
|
|
||||||
{{#operations}}
|
{{#operations}}
|
||||||
{{#operation}}
|
{{#operation}}
|
||||||
{{^servers}}
|
{{^servers}}
|
||||||
|
@ -1,75 +0,0 @@
|
|||||||
/**
|
|
||||||
* 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
|
|
@ -1,53 +0,0 @@
|
|||||||
/**
|
|
||||||
* 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
|
|
Loading…
x
Reference in New Issue
Block a user