diff --git a/App/Server/OpenAPIGenerator.cpp b/App/Server/OpenAPIGenerator.cpp index 34276e25..94f8264a 100644 --- a/App/Server/OpenAPIGenerator.cpp +++ b/App/Server/OpenAPIGenerator.cpp @@ -54,12 +54,12 @@ QJsonObject initializeObject(const QString &_host = "127.0.0.1", const quint16 _ HostPort = QString("%1:%2").arg(_host).arg(_port); return QJsonObject({ - { "swagger","2.0" }, + { "swagger", "2.0" }, { "info",QJsonObject({ { "version", ServerConfigs::Version.value() }, { "title", "Targoman API" }, { "description", "" }, - { "contact", QJsonObject({{"email", "sample@example.com"}}) } + { "contact", QJsonObject({ { "email", ServerConfigs::ContactEmail.value() } }) } }) }, { "host", HostPort }, { "securityDefinitions", QJsonObject({ diff --git a/App/Server/ServerConfigs.cpp b/App/Server/ServerConfigs.cpp index d75cef6b..93486f28 100644 --- a/App/Server/ServerConfigs.cpp +++ b/App/Server/ServerConfigs.cpp @@ -52,6 +52,15 @@ tmplConfigurable ServerConfigs::Version( "VERSION", "version", enuConfigSource::Arg | enuConfigSource::File); +tmplConfigurable ServerConfigs::ContactEmail( + ServerConfigs::makeConfig("ContactEmail"), + "Contact Email", + "info@sample.dom", + ReturnTrueCrossValidator(), + "", + "EMAIL", + "contact-email", + enuConfigSource::Arg | enuConfigSource::File); tmplConfigurable ServerConfigs::JustLocal( ServerConfigs::makeConfig("JustLocal"), diff --git a/App/Server/ServerConfigs.h b/App/Server/ServerConfigs.h index fe90320f..8da448c1 100644 --- a/App/Server/ServerConfigs.h +++ b/App/Server/ServerConfigs.h @@ -42,6 +42,7 @@ struct ServerConfigs static Targoman::Common::Configuration::tmplConfigurable BasePath; static Targoman::Common::Configuration::tmplConfigurable Version; + static Targoman::Common::Configuration::tmplConfigurable ContactEmail; static Targoman::Common::Configuration::tmplConfigurable JustLocal; static Targoman::Common::Configuration::tmplRangedConfigurable ListenPort; static Targoman::Common::Configuration::tmplConfigurable IndentedJson; diff --git a/App/Server/clsRequestHandler.cpp b/App/Server/clsRequestHandler.cpp index 54d717c8..56a21a6c 100644 --- a/App/Server/clsRequestHandler.cpp +++ b/App/Server/clsRequestHandler.cpp @@ -406,7 +406,11 @@ bool clsRequestHandler::callStaticAPI(QString _api) if (_api == "/openAPI.json") { gServerStats.Success.inc(); - this->sendResponseBase(qhttp::ESTATUS_OK, OpenAPIGenerator::retrieveJson(/*this->host()*/ "127.0.0.1", this->port())); + this->sendResponseBase(qhttp::ESTATUS_OK, OpenAPIGenerator::retrieveJson( + this->host() +// "127.0.0.1" + , this->port()) + ); return true; } diff --git a/SwaggerUI/index.html b/SwaggerUI/index.html index 48cd173a..64979d11 100644 --- a/SwaggerUI/index.html +++ b/SwaggerUI/index.html @@ -38,25 +38,31 @@ + curPath = document.location.pathname; + if (curPath.endsWith('/')) + curPath = curPath.slice(0, -1); + curPath = curPath.substring(0, curPath.lastIndexOf('/')); + curUrl = document.location.origin + curPath + "/openAPI.json"; + + window.onload = function() { + // Begin Swagger UI call region + const ui = SwaggerUIBundle({ + url: curUrl, //"https://petstore.swagger.io/v2/swagger.json", + dom_id: '#swagger-ui', + deepLinking: true, + presets: [ + SwaggerUIBundle.presets.apis, + SwaggerUIStandalonePreset + ], + plugins: [ + SwaggerUIBundle.plugins.DownloadUrl + ], + //layout: "StandaloneLayout" + }); + // End Swagger UI call region + + window.ui = ui; + }; +