From a088473830c4acedca85d94f79895e986582fc0f Mon Sep 17 00:00:00 2001 From: GermanBluefox Date: Thu, 19 May 2022 17:14:51 +0200 Subject: [PATCH] * (bluefox) Final release --- gulpfile.js | 2 +- lib/api/swagger/swagger.yaml | 282 +++++++++++++++++------------------ lib/rest-api.js | 6 +- 3 files changed, 147 insertions(+), 143 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 6e62535..9773082 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -289,7 +289,7 @@ ${parameters.join('\n')}`; gulp.task('updateYamlVersion', done => { let yaml = fs.readFileSync(__dirname + '/lib/api/swagger/swagger.yaml').toString('utf8'); - yaml = yaml.replace(/version: "\d+\.\d+.\d+"/, pkg.version); + yaml = yaml.replace(/version: "\d+\.\d+.\d+"/, `version: "${pkg.version}"`); fs.writeFileSync(__dirname + '/lib/api/swagger/swagger.yaml', yaml); done(); }); diff --git a/lib/api/swagger/swagger.yaml b/lib/api/swagger/swagger.yaml index 38ae028..8f312fd 100644 --- a/lib/api/swagger/swagger.yaml +++ b/lib/api/swagger/swagger.yaml @@ -2,7 +2,7 @@ swagger: "2.0" info: description: "This is a REST server for ioBroker." - 0.6.0 + version: "0.6.0" title: "ioBroker Swagger UI" contact: email: "admin@iobroker.net" @@ -942,11 +942,11 @@ paths: - "application/json" parameters: - - name: "pattern" + - name: "pattern" in: "query" description: "" type: "string" - required: true + required: true responses: 200: description: "successful operation" @@ -959,11 +959,11 @@ paths: - "application/json" parameters: - - name: "id" + - name: "id" in: "query" description: "" type: "string" - required: true + required: true responses: 200: description: "successful operation" @@ -976,17 +976,17 @@ paths: - "application/json" parameters: - - name: "id" + - name: "id" in: "query" description: "" type: "string" required: true - - name: "state" + - name: "state" in: "query" description: "" type: "string" - required: true + required: true responses: 200: description: "successful operation" @@ -999,11 +999,11 @@ paths: - "application/json" parameters: - - name: "id" + - name: "id" in: "query" description: "" type: "string" - required: true + required: true responses: 200: description: "successful operation" @@ -1016,17 +1016,17 @@ paths: - "application/json" parameters: - - name: "id" + - name: "id" in: "query" description: "" type: "string" required: true - - name: "base64" + - name: "base64" in: "query" description: "" type: "string" - required: true + required: true responses: 200: description: "successful operation" @@ -1039,11 +1039,11 @@ paths: - "application/json" parameters: - - name: "id" + - name: "id" in: "query" description: "" type: "string" - required: true + required: true responses: 200: description: "successful operation" @@ -1053,7 +1053,7 @@ paths: - "commands" summary: "get all states and rooms. GUI can have problems by visualization of answer." produces: - - "application/json" + - "application/json" responses: 200: description: "successful operation" @@ -1066,23 +1066,23 @@ paths: - "application/json" parameters: - - name: "design" + - name: "design" in: "query" description: "" type: "string" required: true - - name: "search" + - name: "search" in: "query" description: "" type: "string" required: true - - name: "params" + - name: "params" in: "query" description: "JSON object" type: "string" - required: true + required: true responses: 200: description: "successful operation" @@ -1095,17 +1095,17 @@ paths: - "application/json" parameters: - - name: "id" + - name: "id" in: "query" description: "" type: "string" required: true - - name: "obj" + - name: "obj" in: "query" description: "JSON object" type: "string" - required: true + required: true responses: 200: description: "successful operation" @@ -1118,17 +1118,17 @@ paths: - "application/json" parameters: - - name: "id" + - name: "id" in: "query" description: "" type: "string" required: true - - name: "options" + - name: "options" in: "query" description: "JSON object" type: "string" - required: false + required: false responses: 200: description: "successful operation" @@ -1141,17 +1141,17 @@ paths: - "application/json" parameters: - - name: "adapter" + - name: "adapter" in: "query" description: "" type: "string" required: true - - name: "fileName" + - name: "fileName" in: "query" description: "" type: "string" - required: true + required: true responses: 200: description: "successful operation" @@ -1164,17 +1164,17 @@ paths: - "application/json" parameters: - - name: "adapter" + - name: "adapter" in: "query" description: "" type: "string" required: true - - name: "fileName" + - name: "fileName" in: "query" description: "" type: "string" - required: true + required: true responses: 200: description: "successful operation" @@ -1187,29 +1187,29 @@ paths: - "application/json" parameters: - - name: "adapter" + - name: "adapter" in: "query" description: "" type: "string" required: true - - name: "fileName" + - name: "fileName" in: "query" description: "" type: "string" required: true - - name: "data64" + - name: "data64" in: "query" description: "" type: "string" required: true - - name: "options" + - name: "options" in: "query" description: "JSON object" type: "string" - required: false + required: false responses: 200: description: "successful operation" @@ -1222,17 +1222,17 @@ paths: - "application/json" parameters: - - name: "adapter" + - name: "adapter" in: "query" description: "" type: "string" required: true - - name: "name" + - name: "name" in: "query" description: "" type: "string" - required: true + required: true responses: 200: description: "successful operation" @@ -1245,17 +1245,17 @@ paths: - "application/json" parameters: - - name: "adapter" + - name: "adapter" in: "query" description: "" type: "string" required: true - - name: "name" + - name: "name" in: "query" description: "" type: "string" - required: true + required: true responses: 200: description: "successful operation" @@ -1268,17 +1268,17 @@ paths: - "application/json" parameters: - - name: "adapter" + - name: "adapter" in: "query" description: "" type: "string" required: true - - name: "name" + - name: "name" in: "query" description: "" type: "string" - required: true + required: true responses: 200: description: "successful operation" @@ -1291,23 +1291,23 @@ paths: - "application/json" parameters: - - name: "adapter" + - name: "adapter" in: "query" description: "" type: "string" required: true - - name: "oldName" + - name: "oldName" in: "query" description: "" type: "string" required: true - - name: "newName" + - name: "newName" in: "query" description: "" type: "string" - required: true + required: true responses: 200: description: "successful operation" @@ -1320,23 +1320,23 @@ paths: - "application/json" parameters: - - name: "adapter" + - name: "adapter" in: "query" description: "" type: "string" required: true - - name: "oldName" + - name: "oldName" in: "query" description: "" type: "string" required: true - - name: "newName" + - name: "newName" in: "query" description: "" type: "string" - required: true + required: true responses: 200: description: "successful operation" @@ -1349,17 +1349,17 @@ paths: - "application/json" parameters: - - name: "adapter" + - name: "adapter" in: "query" description: "" type: "string" required: true - - name: "dirName" + - name: "dirName" in: "query" description: "" type: "string" - required: true + required: true responses: 200: description: "successful operation" @@ -1372,23 +1372,23 @@ paths: - "application/json" parameters: - - name: "adapter" + - name: "adapter" in: "query" description: "" type: "string" required: true - - name: "dirName" + - name: "dirName" in: "query" description: "" type: "string" required: true - - name: "options" + - name: "options" in: "query" description: "JSON object" type: "string" - required: false + required: false responses: 200: description: "successful operation" @@ -1401,23 +1401,23 @@ paths: - "application/json" parameters: - - name: "adapter" + - name: "adapter" in: "query" description: "" type: "string" required: true - - name: "fileName" + - name: "fileName" in: "query" description: "" type: "string" required: true - - name: "options" + - name: "options" in: "query" description: "JSON object" type: "string" - required: true + required: true responses: 200: description: "successful operation" @@ -1430,23 +1430,23 @@ paths: - "application/json" parameters: - - name: "adapter" + - name: "adapter" in: "query" description: "" type: "string" required: true - - name: "fileName" + - name: "fileName" in: "query" description: "" type: "string" required: true - - name: "options" + - name: "options" in: "query" description: "JSON object" type: "string" - required: true + required: true responses: 200: description: "successful operation" @@ -1459,17 +1459,17 @@ paths: - "application/json" parameters: - - name: "adapter" + - name: "adapter" in: "query" description: "" type: "string" required: true - - name: "fileName" + - name: "fileName" in: "query" description: "" type: "string" - required: true + required: true responses: 200: description: "successful operation" @@ -1483,11 +1483,11 @@ paths: - "application/json" parameters: - - name: "ip" + - name: "ip" in: "query" description: "" type: "string" - required: true + required: true responses: 200: description: "successful operation" @@ -1500,11 +1500,11 @@ paths: - "application/json" parameters: - - name: "host" + - name: "host" in: "query" description: "" type: "string" - required: true + required: true responses: 200: description: "successful operation" @@ -1517,11 +1517,11 @@ paths: - "application/json" parameters: - - name: "id" + - name: "id" in: "query" description: "" type: "string" - required: true + required: true responses: 200: description: "successful operation" @@ -1534,11 +1534,11 @@ paths: - "application/json" parameters: - - name: "update" + - name: "update" in: "query" description: "" type: "boolean" - required: false + required: false responses: 200: description: "successful operation" @@ -1548,7 +1548,7 @@ paths: - "commands" summary: "read adapter namespace (always rest-api.0)" produces: - - "application/json" + - "application/json" responses: 200: description: "successful operation" @@ -1561,12 +1561,12 @@ paths: - "application/json" parameters: - - name: "feature" + - name: "feature" in: "query" description: "" type: "string" required: true - enum: [ALIAS, ALIAS_SEPARATE_READ_WRITE_ID, ADAPTER_GETPORT_BIND, ADAPTER_DEL_OBJECT_RECURSIVE, ADAPTER_SET_OBJECT_SETS_DEFAULT_VALUE, ADAPTER_AUTO_DECRYPT_NATIVE, PLUGINS, CONTROLLER_NPM_AUTO_REBUILD, CONTROLLER_READWRITE_BASE_SETTINGS, CONTROLLER_MULTI_REPO, CONTROLLER_LICENSE_MANAGER, DEL_INSTANCE_CUSTOM] + enum: [ALIAS, ALIAS_SEPARATE_READ_WRITE_ID, ADAPTER_GETPORT_BIND, ADAPTER_DEL_OBJECT_RECURSIVE, ADAPTER_SET_OBJECT_SETS_DEFAULT_VALUE, ADAPTER_AUTO_DECRYPT_NATIVE, PLUGINS, CONTROLLER_NPM_AUTO_REBUILD, CONTROLLER_READWRITE_BASE_SETTINGS, CONTROLLER_MULTI_REPO, CONTROLLER_LICENSE_MANAGER, DEL_INSTANCE_CUSTOM] responses: 200: description: "successful operation" @@ -1579,11 +1579,11 @@ paths: - "application/json" parameters: - - name: "encryptedText" + - name: "encryptedText" in: "query" description: "" type: "string" - required: true + required: true responses: 200: description: "successful operation" @@ -1596,11 +1596,11 @@ paths: - "application/json" parameters: - - name: "plainText" + - name: "plainText" in: "query" description: "" type: "string" - required: true + required: true responses: 200: description: "successful operation" @@ -1613,11 +1613,11 @@ paths: - "application/json" parameters: - - name: "adapterName" + - name: "adapterName" in: "query" description: "" type: "string" - required: false + required: false responses: 200: description: "successful operation" @@ -1630,11 +1630,11 @@ paths: - "application/json" parameters: - - name: "adapterName" + - name: "adapterName" in: "query" description: "" type: "string" - required: false + required: false responses: 200: description: "successful operation" @@ -1647,17 +1647,17 @@ paths: - "application/json" parameters: - - name: "login" + - name: "login" in: "query" description: "" type: "string" required: true - - name: "password" + - name: "password" in: "query" description: "" type: "string" - required: true + required: true responses: 200: description: "successful operation" @@ -1667,7 +1667,7 @@ paths: - "commands" summary: "read list of instances with short information" produces: - - "application/json" + - "application/json" responses: 200: description: "successful operation" @@ -1677,7 +1677,7 @@ paths: - "commands" summary: "read list of installed adapters with short information" produces: - - "application/json" + - "application/json" responses: 200: description: "successful operation" @@ -1690,11 +1690,11 @@ paths: - "application/json" parameters: - - name: "host" + - name: "host" in: "query" description: "" type: "string" - required: true + required: true responses: 200: description: "successful operation" @@ -1704,7 +1704,7 @@ paths: - "commands" summary: "read short system config" produces: - - "application/json" + - "application/json" responses: 200: description: "successful operation" @@ -1717,11 +1717,11 @@ paths: - "application/json" parameters: - - name: "host" + - name: "host" in: "query" description: "" type: "string" - required: true + required: true responses: 200: description: "successful operation" @@ -1731,7 +1731,7 @@ paths: - "commands" summary: "get short information about hosts" produces: - - "application/json" + - "application/json" responses: 200: description: "successful operation" @@ -1744,17 +1744,17 @@ paths: - "application/json" parameters: - - name: "user" + - name: "user" in: "query" description: "" type: "string" required: true - - name: "pass" + - name: "pass" in: "query" description: "" type: "string" - required: true + required: true responses: 200: description: "successful operation" @@ -1767,11 +1767,11 @@ paths: - "application/json" parameters: - - name: "user" + - name: "user" in: "query" description: "" type: "string" - required: true + required: true responses: 200: description: "successful operation" @@ -1784,23 +1784,23 @@ paths: - "application/json" parameters: - - name: "group" + - name: "group" in: "query" description: "" type: "string" required: true - - name: "desc" + - name: "desc" in: "query" description: "" type: "string" required: true - - name: "acl" + - name: "acl" in: "query" description: "" type: "string" - required: true + required: true responses: 200: description: "successful operation" @@ -1813,11 +1813,11 @@ paths: - "application/json" parameters: - - name: "group" + - name: "group" in: "query" description: "" type: "string" - required: true + required: true responses: 200: description: "successful operation" @@ -1830,17 +1830,17 @@ paths: - "application/json" parameters: - - name: "user" + - name: "user" in: "query" description: "" type: "string" required: true - - name: "pass" + - name: "pass" in: "query" description: "" type: "string" - required: true + required: true responses: 200: description: "successful operation" @@ -1850,7 +1850,7 @@ paths: - "commands" summary: "read all objects as list. GUI can have problems by visualization of answer." produces: - - "application/json" + - "application/json" responses: 200: description: "successful operation" @@ -1863,17 +1863,17 @@ paths: - "application/json" parameters: - - name: "id" + - name: "id" in: "query" description: "" type: "string" required: true - - name: "obj" + - name: "obj" in: "query" description: "JSON object" type: "string" - required: true + required: true responses: 200: description: "successful operation" @@ -1886,17 +1886,17 @@ paths: - "application/json" parameters: - - name: "pattern" + - name: "pattern" in: "query" description: "" type: "string" required: true - - name: "type" + - name: "type" in: "query" description: "" type: "string" - required: true + required: true responses: 200: description: "successful operation" @@ -1909,11 +1909,11 @@ paths: - "application/json" parameters: - - name: "pattern" + - name: "pattern" in: "query" description: "" type: "string" - required: true + required: true responses: 200: description: "successful operation" @@ -1927,17 +1927,17 @@ paths: - "application/json" parameters: - - name: "text" + - name: "text" in: "query" description: "" type: "string" required: true - - name: "level" + - name: "level" in: "query" description: "" type: "string" - required: false + required: false responses: 200: description: "successful operation" @@ -1950,17 +1950,17 @@ paths: - "application/json" parameters: - - name: "id" + - name: "id" in: "query" description: "" type: "string" required: true - - name: "options" + - name: "options" in: "query" description: "JSON object" type: "string" - required: false + required: false responses: 200: description: "successful operation" @@ -1973,11 +1973,11 @@ paths: - "application/json" parameters: - - name: "url" + - name: "url" in: "query" description: "" type: "string" - required: true + required: true responses: 200: description: "successful operation" @@ -1990,23 +1990,23 @@ paths: - "application/json" parameters: - - name: "adapterInstance" + - name: "adapterInstance" in: "query" description: "" type: "string" required: true - - name: "command" + - name: "command" in: "query" description: "" type: "string" required: true - - name: "message" + - name: "message" in: "query" description: "JSON object" type: "string" - required: true + required: true responses: 200: description: "successful operation" @@ -2016,7 +2016,7 @@ paths: - "commands" summary: "read static information with function permissions" produces: - - "application/json" + - "application/json" responses: 200: description: "successful operation" @@ -2026,7 +2026,7 @@ paths: - "commands" summary: "read object with user permissions" produces: - - "application/json" + - "application/json" responses: 200: description: "successful operation" @@ -2036,7 +2036,7 @@ paths: - "commands" summary: "read adapter name and version" produces: - - "application/json" + - "application/json" responses: 200: description: "successful operation" @@ -2046,7 +2046,7 @@ paths: - "commands" summary: "read adapter name (always rest-api)" produces: - - "application/json" + - "application/json" responses: 200: description: "successful operation" diff --git a/lib/rest-api.js b/lib/rest-api.js index bf5c54e..8b165fb 100644 --- a/lib/rest-api.js +++ b/lib/rest-api.js @@ -303,8 +303,12 @@ function SwaggerUI(_ignore, webSettings, adapter, instanceSettings, app, callbac if (!this.config.noUI) { this.app.get(this.routerPrefix + 'api-docs/swagger.json', (req, res) => res.json(swaggerDocument)); + + const options = { + customCss: '.swagger-ui .topbar { background-color: #4dabf5; }', + }; // show WEB CSS and so on - this.app.use(this.routerPrefix + 'api-doc/', swaggerUi.serve, swaggerUi.setup(swaggerDocument)); + this.app.use(this.routerPrefix + 'api-doc/', swaggerUi.serve, swaggerUi.setup(swaggerDocument, options)); this.app.get(this.routerPrefix, (req, res) => res.redirect(this.routerPrefix + 'api-doc/')); }