This is an automated email from the ASF dual-hosted git repository.
smolnar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/knox.git
The following commit(s) were added to refs/heads/master by this push:
new 33ad107 KNOX-2509 - Added OpenAPI UI (v3.36.2) for documenting Knox's
REST API endpoints and models (#393)
33ad107 is described below
commit 33ad107166c8eec8a02805c5e63a864551a54f84
Author: Sandor Molnar <[email protected]>
AuthorDate: Wed Dec 16 11:15:52 2020 +0100
KNOX-2509 - Added OpenAPI UI (v3.36.2) for documenting Knox's REST API
endpoints and models (#393)
---
gateway-applications/pom.xml | 12 +++
gateway-discovery-cm/pom.xml | 6 ++
gateway-openapi-ui/pom.xml | 90 +++++++++++++++++++++
.../src/main/resources/swagger/absolute-path.js | 31 +++++++
.../src/main/resources/swagger/favicon-16x16.png | Bin 0 -> 665 bytes
.../src/main/resources/swagger/favicon-32x32.png | Bin 0 -> 628 bytes
.../src/main/resources/swagger/index.html | 70 ++++++++++++++++
.../src/main/resources/swagger/index.js | 34 ++++++++
.../src/main/resources/swagger/index_admin.html | 52 ++++++++++++
.../src/main/resources/swagger/index_metadata.html | 58 +++++++++++++
.../main/resources/swagger/oauth2-redirect.html | 88 ++++++++++++++++++++
.../main/resources/swagger/swagger-ui-bundle.js | 19 +++++
.../resources/swagger/swagger-ui-es-bundle-core.js | 19 +++++
.../main/resources/swagger/swagger-ui-es-bundle.js | 19 +++++
.../swagger/swagger-ui-standalone-preset.js | 19 +++++
.../src/main/resources/swagger/swagger-ui.css | 21 +++++
.../src/main/resources/swagger/swagger-ui.js | 19 +++++
gateway-release/home/conf/topologies/homepage.xml | 8 ++
gateway-release/pom.xml | 4 +
gateway-service-admin/pom.xml | 4 +
.../knox/gateway/service/admin/AliasResource.java | 4 +
.../service/admin/ServiceDefinitionsResource.java | 3 +
.../service/admin/ServiceDiscoveryResource.java | 5 ++
.../gateway/service/admin/TopologiesResource.java | 7 +-
.../gateway/service/admin/VersionResource.java | 4 +
gateway-service-metadata/pom.xml | 4 +
.../service/metadata/GeneralProxyInformation.java | 7 ++
.../service/metadata/KnoxMetadataResource.java | 5 ++
pom.xml | 14 +++-
29 files changed, 624 insertions(+), 2 deletions(-)
diff --git a/gateway-applications/pom.xml b/gateway-applications/pom.xml
index c8d6e86..8c46ac1 100644
--- a/gateway-applications/pom.xml
+++ b/gateway-applications/pom.xml
@@ -38,6 +38,10 @@
<groupId>org.apache.knox</groupId>
<artifactId>knox-homepage-ui</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.knox</groupId>
+ <artifactId>gateway-openapi-ui</artifactId>
+ </dependency>
</dependencies>
<build>
@@ -70,6 +74,14 @@
<outputDirectory>${project.build.outputDirectory}/applications</outputDirectory>
<includes>home/**</includes>
</artifactItem>
+ <artifactItem>
+ <groupId>org.apache.knox</groupId>
+ <artifactId>gateway-openapi-ui</artifactId>
+ <type>jar</type>
+ <overWrite>true</overWrite>
+
<outputDirectory>${project.build.outputDirectory}/applications/home/app</outputDirectory>
+ <includes>swagger/**</includes>
+ </artifactItem>
</artifactItems>
</configuration>
</execution>
diff --git a/gateway-discovery-cm/pom.xml b/gateway-discovery-cm/pom.xml
index 8b8d596..41eacc1 100644
--- a/gateway-discovery-cm/pom.xml
+++ b/gateway-discovery-cm/pom.xml
@@ -66,6 +66,12 @@
<dependency>
<groupId>com.cloudera.api.swagger</groupId>
<artifactId>cloudera-manager-api-swagger</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>io.swagger</groupId>
+ <artifactId>swagger-annotations</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>com.squareup.okhttp</groupId>
diff --git a/gateway-openapi-ui/pom.xml b/gateway-openapi-ui/pom.xml
new file mode 100644
index 0000000..fd2fa75
--- /dev/null
+++ b/gateway-openapi-ui/pom.xml
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.knox</groupId>
+ <artifactId>gateway</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>gateway-openapi-ui</artifactId>
+ <name>gateway-openapi-ui</name>
+ <packaging>jar</packaging>
+ <description>Generating Open API (aka. Swagger) UI</description>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.github.kongchen</groupId>
+ <artifactId>swagger-maven-plugin</artifactId>
+ <version>${swagger-maven-plugin.version}</version>
+ <configuration>
+ <apiSources>
+ <apiSource>
+ <locations>
+
<location>org.apache.knox.gateway.service.admin</location>
+ </locations>
+
<swaggerDirectory>${project.build.outputDirectory}/swagger</swaggerDirectory>
+ <swaggerFileName>admin</swaggerFileName>
+ <basePath>/gateway/admin</basePath>
+ <info>
+ <title>The Apache Knox Admin REST API</title>
+ <version>${project.version}</version>
+ <description>Swagger UI for Apache Knox Admin
REST API</description>
+ </info>
+ </apiSource>
+ <apiSource>
+ <locations>
+
<location>org.apache.knox.gateway.service.metadata</location>
+ </locations>
+
<swaggerDirectory>${project.build.outputDirectory}/swagger</swaggerDirectory>
+ <swaggerFileName>metadata</swaggerFileName>
+ <basePath>/gateway/metadata</basePath>
+ <info>
+ <title>The Apache Knox Metadata REST
API</title>
+ <version>${project.version}</version>
+ <description>Swagger UI for Apache Knox
Metadata REST API</description>
+ </info>
+ </apiSource>
+ </apiSources>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>compile</phase>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.knox</groupId>
+ <artifactId>gateway-service-admin</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.knox</groupId>
+ <artifactId>gateway-service-metadata</artifactId>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/gateway-openapi-ui/src/main/resources/swagger/absolute-path.js
b/gateway-openapi-ui/src/main/resources/swagger/absolute-path.js
new file mode 100644
index 0000000..e36b259
--- /dev/null
+++ b/gateway-openapi-ui/src/main/resources/swagger/absolute-path.js
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * getAbsoluteFSPath
+ * @return {string} When run in NodeJS env, returns the absolute path to the
current directory
+ * When run outside of NodeJS, will return an error message
+ */
+const getAbsoluteFSPath = function () {
+ // detect whether we are running in a browser or nodejs
+ if (typeof module !== "undefined" && module.exports) {
+ return require("path").resolve(__dirname)
+ }
+ throw new Error('getAbsoluteFSPath can only be called within a Nodejs
environment');
+}
+
+module.exports = getAbsoluteFSPath
diff --git a/gateway-openapi-ui/src/main/resources/swagger/favicon-16x16.png
b/gateway-openapi-ui/src/main/resources/swagger/favicon-16x16.png
new file mode 100644
index 0000000..8b194e6
Binary files /dev/null and
b/gateway-openapi-ui/src/main/resources/swagger/favicon-16x16.png differ
diff --git a/gateway-openapi-ui/src/main/resources/swagger/favicon-32x32.png
b/gateway-openapi-ui/src/main/resources/swagger/favicon-32x32.png
new file mode 100644
index 0000000..249737f
Binary files /dev/null and
b/gateway-openapi-ui/src/main/resources/swagger/favicon-32x32.png differ
diff --git a/gateway-openapi-ui/src/main/resources/swagger/index.html
b/gateway-openapi-ui/src/main/resources/swagger/index.html
new file mode 100644
index 0000000..2ee5c63
--- /dev/null
+++ b/gateway-openapi-ui/src/main/resources/swagger/index.html
@@ -0,0 +1,70 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+ http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<html lang="en">
+ <head>
+ <meta charset="UTF-8">
+ <title>The Apache Knox REST API</title>
+ <link rel="stylesheet" type="text/css" href="./swagger-ui.css" >
+ <link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32"
/>
+ <link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16"
/>
+ <style>
+ html, body, iframe { height: 100%; }
+ #content {height:100%;}
+
+ /* Add a black background color to the top navigation */
+ .topnav {
+ background-color: #333;
+ overflow: hidden;
+ }
+
+ /* Style the links inside the navigation bar */
+ .topnav a {
+ float: left;
+ color: #f2f2f2;
+ text-align: center;
+ padding: 14px 16px;
+ text-decoration: none;
+ font-size: 17px;
+ }
+
+ /* Change the color of links on hover */
+ .topnav a:hover {
+ background-color: #ddd;
+ color: black;
+ }
+
+ /* Add a color to the active/current link */
+ .topnav a.active {
+ background-color: #4CAF50;
+ color: white;
+ }
+
+ </style>
+ </head>
+
+ <body>
+
+ <div class="topnav">
+ <a class="active" href="#home">The Apache Knox REST API</a>
+ <a href="./index_admin.html" target="content"> Admin API </a>
+ <a href="./index_metadata.html" target="content"> Metadata API </a>
+ </div>
+
+ <div id="content"><iframe name="content" src="./index_admin.html"
width="100%" height="100%"/></div>
+
+ </body>
+
+</html>
diff --git a/gateway-openapi-ui/src/main/resources/swagger/index.js
b/gateway-openapi-ui/src/main/resources/swagger/index.js
new file mode 100644
index 0000000..e49939c
--- /dev/null
+++ b/gateway-openapi-ui/src/main/resources/swagger/index.js
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+try {
+ module.exports.SwaggerUIBundle = require("./swagger-ui-bundle.js")
+ module.exports.SwaggerUIStandalonePreset =
require("./swagger-ui-standalone-preset.js")
+} catch(e) {
+ // swallow the error if there's a problem loading the assets.
+ // allows this module to support providing the assets for browserish
contexts,
+ // without exploding in a Node context.
+ //
+ // see
https://github.com/swagger-api/swagger-ui/issues/3291#issuecomment-311195388
+ // for more information.
+}
+
+// `absolutePath` and `getAbsoluteFSPath` are both here because at one point,
+// we documented having one and actually implemented the other.
+// They were both retained so we don't break anyone's code.
+module.exports.absolutePath = require("./absolute-path.js")
+module.exports.getAbsoluteFSPath = require("./absolute-path.js")
diff --git a/gateway-openapi-ui/src/main/resources/swagger/index_admin.html
b/gateway-openapi-ui/src/main/resources/swagger/index_admin.html
new file mode 100644
index 0000000..a0186ad
--- /dev/null
+++ b/gateway-openapi-ui/src/main/resources/swagger/index_admin.html
@@ -0,0 +1,52 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+ http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<html lang="en">
+ <head>
+ <meta charset="UTF-8">
+ <title>The Apache Knox REST API</title>
+ <link rel="stylesheet" type="text/css" href="./swagger-ui.css" >
+ <link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32"
/>
+ <link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16"
/>
+ </head>
+
+ <body>
+ <div id="swagger-ui"></div>
+
+ <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: window.location.protocol + '//' + window.location.host +
'/gateway/homepage/home/swagger/admin.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>
diff --git a/gateway-openapi-ui/src/main/resources/swagger/index_metadata.html
b/gateway-openapi-ui/src/main/resources/swagger/index_metadata.html
new file mode 100644
index 0000000..61af104
--- /dev/null
+++ b/gateway-openapi-ui/src/main/resources/swagger/index_metadata.html
@@ -0,0 +1,58 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+ http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<html lang="en">
+ <head>
+ <meta charset="UTF-8">
+ <title>The Apache Knox REST API</title>
+ <link rel="stylesheet" type="text/css" href="./swagger-ui.css" >
+ <link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32"
/>
+ <link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16"
/>
+ <style>
+html, body, iframe { height: 100%; }
+ #content {
+ height:100%;
+}
+ </style>
+ </head>
+
+ <body>
+ <div id="swagger-ui"></div>
+
+ <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: window.location.protocol + '//' + window.location.host +
'/gateway/homepage/home/swagger/metadata.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>
diff --git a/gateway-openapi-ui/src/main/resources/swagger/oauth2-redirect.html
b/gateway-openapi-ui/src/main/resources/swagger/oauth2-redirect.html
new file mode 100644
index 0000000..2d7a380
--- /dev/null
+++ b/gateway-openapi-ui/src/main/resources/swagger/oauth2-redirect.html
@@ -0,0 +1,88 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+ http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!doctype html>
+<html lang="en-US">
+<head>
+ <title>Swagger UI: OAuth2 Redirect</title>
+</head>
+<body>
+</body>
+</html>
+<script>
+ 'use strict';
+ function run () {
+ var oauth2 = window.opener.swaggerUIRedirectOauth2;
+ var sentState = oauth2.state;
+ var redirectUrl = oauth2.redirectUrl;
+ var isValid, qp, arr;
+
+ if (/code|token|error/.test(window.location.hash)) {
+ qp = window.location.hash.substring(1);
+ } else {
+ qp = location.search.substring(1);
+ }
+
+ arr = qp.split("&")
+ arr.forEach(function (v,i,_arr) { _arr[i] = '"' + v.replace('=',
'":"') + '"';})
+ qp = qp ? JSON.parse('{' + arr.join() + '}',
+ function (key, value) {
+ return key === "" ? value : decodeURIComponent(value)
+ }
+ ) : {}
+
+ isValid = qp.state === sentState
+
+ if ((
+ oauth2.auth.schema.get("flow") === "accessCode"||
+ oauth2.auth.schema.get("flow") === "authorizationCode"
+ ) && !oauth2.auth.code) {
+ if (!isValid) {
+ oauth2.errCb({
+ authId: oauth2.auth.name,
+ source: "auth",
+ level: "warning",
+ message: "Authorization may be unsafe, passed state was
changed in server Passed state wasn't returned from auth server"
+ });
+ }
+
+ if (qp.code) {
+ delete oauth2.state;
+ oauth2.auth.code = qp.code;
+ oauth2.callback({auth: oauth2.auth, redirectUrl: redirectUrl});
+ } else {
+ let oauthErrorMsg
+ if (qp.error) {
+ oauthErrorMsg = "["+qp.error+"]: " +
+ (qp.error_description ? qp.error_description+ ". " :
"no accessCode received from the server. ") +
+ (qp.error_uri ? "More info: "+qp.error_uri : "");
+ }
+
+ oauth2.errCb({
+ authId: oauth2.auth.name,
+ source: "auth",
+ level: "error",
+ message: oauthErrorMsg || "[Authorization failed]: no
accessCode received from the server"
+ });
+ }
+ } else {
+ oauth2.callback({auth: oauth2.auth, token: qp, isValid: isValid,
redirectUrl: redirectUrl});
+ }
+ window.close();
+ }
+
+ window.addEventListener('DOMContentLoaded', function () {
+ run();
+ });
+</script>
diff --git a/gateway-openapi-ui/src/main/resources/swagger/swagger-ui-bundle.js
b/gateway-openapi-ui/src/main/resources/swagger/swagger-ui-bundle.js
new file mode 100644
index 0000000..efcc0b9
--- /dev/null
+++ b/gateway-openapi-ui/src/main/resources/swagger/swagger-ui-bundle.js
@@ -0,0 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+!function(e,t){"object"==typeof exports&&"object"==typeof
module?module.exports=t(function(){try{return
require("esprima")}catch(e){}}()):"function"==typeof
define&&define.amd?define(["esprima"],t):"object"==typeof
exports?exports.SwaggerUIBundle=t(function(){try{return
require("esprima")}catch(e){}}()):e.SwaggerUIBundle=t(e.esprima)}(this,(function(e){return
function(e){var t={};function n(r){if(t[r])return t[r].exports;var
o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exp [...]
+//# sourceMappingURL=swagger-ui-bundle.js.map
\ No newline at end of file
diff --git
a/gateway-openapi-ui/src/main/resources/swagger/swagger-ui-es-bundle-core.js
b/gateway-openapi-ui/src/main/resources/swagger/swagger-ui-es-bundle-core.js
new file mode 100644
index 0000000..00ffc2f
--- /dev/null
+++ b/gateway-openapi-ui/src/main/resources/swagger/swagger-ui-es-bundle-core.js
@@ -0,0 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+module.exports=function(e){var t={};function n(r){if(t[r])return
t[r].exports;var a=t[r]={i:r,l:!1,exports:{}};return
e[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return
n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof
Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return
e; [...]
+//# sourceMappingURL=swagger-ui-es-bundle-core.js.map
\ No newline at end of file
diff --git
a/gateway-openapi-ui/src/main/resources/swagger/swagger-ui-es-bundle.js
b/gateway-openapi-ui/src/main/resources/swagger/swagger-ui-es-bundle.js
new file mode 100644
index 0000000..14c1349
--- /dev/null
+++ b/gateway-openapi-ui/src/main/resources/swagger/swagger-ui-es-bundle.js
@@ -0,0 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+module.exports=function(e){var t={};function n(r){if(t[r])return
t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return
e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return
n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof
Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return
e; [...]
+//# sourceMappingURL=swagger-ui-es-bundle.js.map
\ No newline at end of file
diff --git
a/gateway-openapi-ui/src/main/resources/swagger/swagger-ui-standalone-preset.js
b/gateway-openapi-ui/src/main/resources/swagger/swagger-ui-standalone-preset.js
new file mode 100644
index 0000000..e12f9ee
--- /dev/null
+++
b/gateway-openapi-ui/src/main/resources/swagger/swagger-ui-standalone-preset.js
@@ -0,0 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+!function(t,e){"object"==typeof exports&&"object"==typeof
module?module.exports=e(function(){try{return
require("esprima")}catch(t){}}()):"function"==typeof
define&&define.amd?define(["esprima"],e):"object"==typeof
exports?exports.SwaggerUIStandalonePreset=e(function(){try{return
require("esprima")}catch(t){}}()):t.SwaggerUIStandalonePreset=e(t.esprima)}(this,(function(t){return
function(t){var e={};function n(r){if(e[r])return e[r].exports;var
i=e[r]={i:r,l:!1,exports:{}};return t[r].ca [...]
+//# sourceMappingURL=swagger-ui-standalone-preset.js.map
\ No newline at end of file
diff --git a/gateway-openapi-ui/src/main/resources/swagger/swagger-ui.css
b/gateway-openapi-ui/src/main/resources/swagger/swagger-ui.css
new file mode 100644
index 0000000..34bf24a
--- /dev/null
+++ b/gateway-openapi-ui/src/main/resources/swagger/swagger-ui.css
@@ -0,0 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+.swagger-ui{
+ /*! normalize.css v7.0.0 | MIT License | github.com/necolas/normalize.css
*/font-family:sans-serif;color:#3b4151}.swagger-ui
html{line-height:1.15;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}.swagger-ui
body{margin:0}.swagger-ui article,.swagger-ui aside,.swagger-ui
footer,.swagger-ui header,.swagger-ui nav,.swagger-ui
section{display:block}.swagger-ui h1{font-size:2em;margin:.67em 0}.swagger-ui
figcaption,.swagger-ui figure,.swagger-ui main{display:block}.swagger-ui figure
[...]
+
+/*# sourceMappingURL=swagger-ui.css.map*/
\ No newline at end of file
diff --git a/gateway-openapi-ui/src/main/resources/swagger/swagger-ui.js
b/gateway-openapi-ui/src/main/resources/swagger/swagger-ui.js
new file mode 100644
index 0000000..5b326d2
--- /dev/null
+++ b/gateway-openapi-ui/src/main/resources/swagger/swagger-ui.js
@@ -0,0 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+!function(e,t){"object"==typeof exports&&"object"==typeof
module?module.exports=t():"function"==typeof
define&&define.amd?define([],t):"object"==typeof
exports?exports.SwaggerUICore=t():e.SwaggerUICore=t()}(this,(function(){return
function(e){var t={};function n(r){if(t[r])return t[r].exports;var
a=t[r]={i:r,l:!1,exports:{}};return
e[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return
n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=fun
[...]
+//# sourceMappingURL=swagger-ui.js.map
\ No newline at end of file
diff --git a/gateway-release/home/conf/topologies/homepage.xml
b/gateway-release/home/conf/topologies/homepage.xml
index edf463e..27458f9 100644
--- a/gateway-release/home/conf/topologies/homepage.xml
+++ b/gateway-release/home/conf/topologies/homepage.xml
@@ -46,6 +46,14 @@
<name>strict.transport.enabled</name>
<value>false</value>
</param>
+ <param>
+ <name>xframe.options.enabled</name>
+ <value>true</value>
+ </param>
+ <param>
+ <name>xframe.options</name>
+ <value>SAMEORIGIN</value>
+ </param>
</provider>
<provider>
<role>federation</role>
diff --git a/gateway-release/pom.xml b/gateway-release/pom.xml
index 73b6920..b0818b2 100644
--- a/gateway-release/pom.xml
+++ b/gateway-release/pom.xml
@@ -451,6 +451,10 @@
</dependency>
<dependency>
<groupId>org.apache.knox</groupId>
+ <artifactId>gateway-openapi-ui</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.knox</groupId>
<artifactId>gateway-service-session</artifactId>
</dependency>
</dependencies>
diff --git a/gateway-service-admin/pom.xml b/gateway-service-admin/pom.xml
index 93b8acf..9a46cb3 100644
--- a/gateway-service-admin/pom.xml
+++ b/gateway-service-admin/pom.xml
@@ -104,6 +104,10 @@
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
+ <dependency>
+ <groupId>io.swagger</groupId>
+ <artifactId>swagger-annotations</artifactId>
+ </dependency>
<dependency>
<groupId>org.apache.knox</groupId>
diff --git
a/gateway-service-admin/src/main/java/org/apache/knox/gateway/service/admin/AliasResource.java
b/gateway-service-admin/src/main/java/org/apache/knox/gateway/service/admin/AliasResource.java
index 18eb0c9..bbbc3bf 100644
---
a/gateway-service-admin/src/main/java/org/apache/knox/gateway/service/admin/AliasResource.java
+++
b/gateway-service-admin/src/main/java/org/apache/knox/gateway/service/admin/AliasResource.java
@@ -18,6 +18,9 @@
package org.apache.knox.gateway.service.admin;
import com.fasterxml.jackson.databind.ObjectMapper;
+
+import io.swagger.annotations.Api;
+
import org.apache.knox.gateway.services.ServiceType;
import org.apache.knox.gateway.services.GatewayServices;
import org.apache.knox.gateway.services.security.AliasService;
@@ -50,6 +53,7 @@ import static javax.ws.rs.core.Response.status;
* Rest API for Knox Alias Service
* @since 1.3.0
*/
+@Api(value = "alias", description = "The Knox Admin API to interact with
aliases.")
@Path("/api/v1")
public class AliasResource {
private static final String ALIASES_API_PATH = "aliases";
diff --git
a/gateway-service-admin/src/main/java/org/apache/knox/gateway/service/admin/ServiceDefinitionsResource.java
b/gateway-service-admin/src/main/java/org/apache/knox/gateway/service/admin/ServiceDefinitionsResource.java
index e6d669f..15bb6a7 100644
---
a/gateway-service-admin/src/main/java/org/apache/knox/gateway/service/admin/ServiceDefinitionsResource.java
+++
b/gateway-service-admin/src/main/java/org/apache/knox/gateway/service/admin/ServiceDefinitionsResource.java
@@ -56,6 +56,9 @@ import org.apache.knox.gateway.services.ServiceType;
import org.apache.knox.gateway.services.registry.ServiceDefinitionRegistry;
import
org.apache.knox.gateway.services.registry.ServiceDefinitionRegistryException;
+import io.swagger.annotations.Api;
+
+@Api(value = "serviceDefinition", description = "The Knox Admin API to
interact with service definition information.")
@Path("/api/v1")
@Singleton
public class ServiceDefinitionsResource {
diff --git
a/gateway-service-admin/src/main/java/org/apache/knox/gateway/service/admin/ServiceDiscoveryResource.java
b/gateway-service-admin/src/main/java/org/apache/knox/gateway/service/admin/ServiceDiscoveryResource.java
index 2845191..dea9bd6 100644
---
a/gateway-service-admin/src/main/java/org/apache/knox/gateway/service/admin/ServiceDiscoveryResource.java
+++
b/gateway-service-admin/src/main/java/org/apache/knox/gateway/service/admin/ServiceDiscoveryResource.java
@@ -36,9 +36,14 @@ import javax.xml.bind.annotation.XmlElementWrapper;
import org.apache.knox.gateway.topology.discovery.ServiceDiscovery;
import org.apache.knox.gateway.topology.discovery.ServiceDiscoveryFactory;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+@Api(value = "serviceDiscovery", description = "The Knox Admin API to
interact with service discovery information.")
@Path("/api/v1")
public class ServiceDiscoveryResource {
+ @ApiOperation(value="Get available service discoveries", notes="Get
available service discoveriy types (Ambari, ClouderaManager, etc...) and their
implementation classes", response=ServiceDiscoveryWrapper.class)
@GET
@Produces({ APPLICATION_JSON, APPLICATION_XML })
@Path("servicediscoveries")
diff --git
a/gateway-service-admin/src/main/java/org/apache/knox/gateway/service/admin/TopologiesResource.java
b/gateway-service-admin/src/main/java/org/apache/knox/gateway/service/admin/TopologiesResource.java
index 00e4e28..eb3f1d4 100644
---
a/gateway-service-admin/src/main/java/org/apache/knox/gateway/service/admin/TopologiesResource.java
+++
b/gateway-service-admin/src/main/java/org/apache/knox/gateway/service/admin/TopologiesResource.java
@@ -18,6 +18,10 @@
package org.apache.knox.gateway.service.admin;
import com.fasterxml.jackson.annotation.JsonProperty;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.knox.gateway.i18n.GatewaySpiMessages;
@@ -70,7 +74,7 @@ import static javax.ws.rs.core.Response.created;
import static javax.ws.rs.core.Response.notModified;
import static javax.ws.rs.core.Response.status;
-
+@Api(value = "topology", description = "The Knox Admin API to interact with
topologies.")
@Path("/api/v1")
public class TopologiesResource {
@@ -136,6 +140,7 @@ public class TopologiesResource {
return null;
}
+ @ApiOperation(value="Get ALL topologies", notes="Get ALL topologies that are
available within this Knox Gateway", response=SimpleTopologyWrapper.class)
@GET
@Produces({APPLICATION_JSON, APPLICATION_XML})
@Path(TOPOLOGIES_API_PATH)
diff --git
a/gateway-service-admin/src/main/java/org/apache/knox/gateway/service/admin/VersionResource.java
b/gateway-service-admin/src/main/java/org/apache/knox/gateway/service/admin/VersionResource.java
index c6769ed..38972a5 100644
---
a/gateway-service-admin/src/main/java/org/apache/knox/gateway/service/admin/VersionResource.java
+++
b/gateway-service-admin/src/main/java/org/apache/knox/gateway/service/admin/VersionResource.java
@@ -27,6 +27,9 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.apache.knox.gateway.services.ServiceType;
+
+import io.swagger.annotations.Api;
+
import org.apache.knox.gateway.services.GatewayServices;
import org.apache.knox.gateway.services.ServerInfoService;
@@ -34,6 +37,7 @@ import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static javax.ws.rs.core.MediaType.APPLICATION_XML;
import static javax.ws.rs.core.Response.ok;
+@Api(value = "version", description = "The Knox Admin API to interact with
versioning information.")
@Path( "/api/v1" )
public class VersionResource {
@Context
diff --git a/gateway-service-metadata/pom.xml b/gateway-service-metadata/pom.xml
index fe05084..b08dc0c 100644
--- a/gateway-service-metadata/pom.xml
+++ b/gateway-service-metadata/pom.xml
@@ -74,5 +74,9 @@
<groupId>org.glassfish.hk2.external</groupId>
<artifactId>javax.inject</artifactId>
</dependency>
+ <dependency>
+ <groupId>io.swagger</groupId>
+ <artifactId>swagger-annotations</artifactId>
+ </dependency>
</dependencies>
</project>
diff --git
a/gateway-service-metadata/src/main/java/org/apache/knox/gateway/service/metadata/GeneralProxyInformation.java
b/gateway-service-metadata/src/main/java/org/apache/knox/gateway/service/metadata/GeneralProxyInformation.java
index 5438c41..8443bc8 100644
---
a/gateway-service-metadata/src/main/java/org/apache/knox/gateway/service/metadata/GeneralProxyInformation.java
+++
b/gateway-service-metadata/src/main/java/org/apache/knox/gateway/service/metadata/GeneralProxyInformation.java
@@ -20,16 +20,23 @@ package org.apache.knox.gateway.service.metadata;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
@XmlRootElement(name = "generalProxyInfo")
+@ApiModel(value = "generalProxyInfo", description = "General proxy information
holder")
public class GeneralProxyInformation {
@XmlElement
+ @ApiModelProperty(value = "The version of this Knox Gateway")
private String version;
@XmlElement
+ @ApiModelProperty(value = "The Admin UI URL")
private String adminUiUrl;
@XmlElement
+ @ApiModelProperty(value = "The URL referencing the Admin API book in Knox's
user guide")
private String adminApiBookUrl;
public String getVersion() {
diff --git
a/gateway-service-metadata/src/main/java/org/apache/knox/gateway/service/metadata/KnoxMetadataResource.java
b/gateway-service-metadata/src/main/java/org/apache/knox/gateway/service/metadata/KnoxMetadataResource.java
index 55ed0ae..9522ae2 100644
---
a/gateway-service-metadata/src/main/java/org/apache/knox/gateway/service/metadata/KnoxMetadataResource.java
+++
b/gateway-service-metadata/src/main/java/org/apache/knox/gateway/service/metadata/KnoxMetadataResource.java
@@ -64,6 +64,10 @@ import org.apache.knox.gateway.topology.Service;
import org.apache.knox.gateway.topology.Topology;
import org.apache.knox.gateway.util.X509CertificateUtil;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+@Api(value = "metadata", description = "RESTful API to interact with
metadata.")
@Singleton
@Path("/api/v1/metadata")
public class KnoxMetadataResource {
@@ -78,6 +82,7 @@ public class KnoxMetadataResource {
@Context
private HttpServletRequest request;
+ @ApiOperation(value="Get general proxy information", notes="Get general
proxy information such as TLS Public Certificate, Knox Admin UI Url, etc...",
response=GeneralProxyInformation.class)
@GET
@Produces({ APPLICATION_JSON, APPLICATION_XML })
@Path("info")
diff --git a/pom.xml b/pom.xml
index 9259860..9823680 100644
--- a/pom.xml
+++ b/pom.xml
@@ -143,6 +143,7 @@
<module>gateway-service-metadata</module>
<module>gateway-service-session</module>
<module>knox-homepage-ui</module>
+ <module>gateway-openapi-ui</module>
</modules>
<properties>
@@ -261,6 +262,8 @@
<spring-vault.version>2.2.3.RELEASE</spring-vault.version>
<stax-ex.version>1.8.3</stax-ex.version>
<stax2-api.version>4.2</stax2-api.version>
+ <swagger-annotations.version>1.6.2</swagger-annotations.version>
+ <swagger-maven-plugin.version>3.1.7</swagger-maven-plugin.version>
<taglibs-standard.version>1.2.5</taglibs-standard.version>
<testcontainers.version>1.15.1</testcontainers.version>
<txw2.version>2.4.0-b180830.0438</txw2.version>
@@ -1208,7 +1211,11 @@
<artifactId>knox-homepage-ui</artifactId>
<version>${project.version}</version>
</dependency>
-
+ <dependency>
+ <groupId>org.apache.knox</groupId>
+ <artifactId>gateway-openapi-ui</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
@@ -2029,6 +2036,11 @@
<artifactId>metrics-jvm</artifactId>
<version>${metrics.version}</version>
</dependency>
+ <dependency>
+ <groupId>io.swagger</groupId>
+ <artifactId>swagger-annotations</artifactId>
+ <version>${swagger-annotations.version}</version>
+ </dependency>
<!-- pac4j Dependencies -->
<dependency>