forked from loafle/openapi-generator-original
Fix missing serverConf variable (#19859)
Previously, if an operation had a 'servers' block, the template would emit code requiring a `serverConf` local variable. Unfortunately, the template would not emit this variable, because it was looking for a `servers` variable in the wrong context. This change makes the template emit an anonymous block containing a unique server configuration for each operation. I did not test this change beyond a simple code inspection, there are other problems with the code generator which prevent it from running on my API definition.
This commit is contained in:
parent
21a8e4e623
commit
c487a6ea18
@ -23,9 +23,6 @@ void {{classname}}::initializeServerConfigs() {
|
||||
//Default server
|
||||
QList<{{prefix}}ServerConfiguration> defaultConf = QList<{{prefix}}ServerConfiguration>();
|
||||
//varying endpoint server
|
||||
{{#servers}}
|
||||
QList<{{prefix}}ServerConfiguration> serverConf = QList<{{prefix}}ServerConfiguration>();
|
||||
{{/servers}}
|
||||
{{#vendorExtensions.x-cpp-global-server-list}}
|
||||
defaultConf.append({{prefix}}ServerConfiguration(
|
||||
QUrl("{{{url}}}"),
|
||||
@ -42,6 +39,8 @@ void {{classname}}::initializeServerConfigs() {
|
||||
_serverIndices.insert("{{nickname}}", 0);
|
||||
{{/servers}}
|
||||
{{#servers}}
|
||||
{
|
||||
QList<{{prefix}}ServerConfiguration> serverConf = QList<{{prefix}}ServerConfiguration>();
|
||||
serverConf.append({{prefix}}ServerConfiguration(
|
||||
QUrl("{{{url}}}"),
|
||||
"{{{description}}}{{^description}}No description provided{{/description}}",
|
||||
@ -51,6 +50,7 @@ void {{classname}}::initializeServerConfigs() {
|
||||
{{/variables}}{{^variables}}QMap<QString, {{prefix}}ServerVariable>()));{{/variables}}
|
||||
{{#-last}}_serverConfigs.insert("{{nickname}}", serverConf);
|
||||
_serverIndices.insert("{{nickname}}", 0);{{/-last}}
|
||||
}
|
||||
{{/servers}}
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user