Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions App/Server/OpenAPIGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
9 changes: 9 additions & 0 deletions App/Server/ServerConfigs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ tmplConfigurable<QString> ServerConfigs::Version(
"VERSION",
"version",
enuConfigSource::Arg | enuConfigSource::File);
tmplConfigurable<QString> ServerConfigs::ContactEmail(
ServerConfigs::makeConfig("ContactEmail"),
"Contact Email",
"info@sample.dom",
ReturnTrueCrossValidator(),
"",
"EMAIL",
"contact-email",
enuConfigSource::Arg | enuConfigSource::File);

tmplConfigurable<bool> ServerConfigs::JustLocal(
ServerConfigs::makeConfig("JustLocal"),
Expand Down
1 change: 1 addition & 0 deletions App/Server/ServerConfigs.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ struct ServerConfigs

static Targoman::Common::Configuration::tmplConfigurable<QString> BasePath;
static Targoman::Common::Configuration::tmplConfigurable<QString> Version;
static Targoman::Common::Configuration::tmplConfigurable<QString> ContactEmail;
static Targoman::Common::Configuration::tmplConfigurable<bool> JustLocal;
static Targoman::Common::Configuration::tmplRangedConfigurable<quint16> ListenPort;
static Targoman::Common::Configuration::tmplConfigurable<bool> IndentedJson;
Expand Down
6 changes: 5 additions & 1 deletion App/Server/clsRequestHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
46 changes: 26 additions & 20 deletions SwaggerUI/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,31 @@
<script src="./swagger-ui-bundle.js" charset="UTF-8"> </script>
<script src="./swagger-ui-standalone-preset.js" charset="UTF-8"> </script>
<script>
window.onload = function() {
// Begin Swagger UI call region
const ui = SwaggerUIBundle({
url: "../openAPI.json", //"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;
};
</script>
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;
};
</script>
</body>
</html>