Commit 294ca40d by Nikhil Bonte

ATLAS-3913 Swagger documentation for APIs

parent 420983d5
# The MIT License (MIT)
Copyright © Nicolas Gallagher and Jonathan Neal
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
\ No newline at end of file
......@@ -16,7 +16,7 @@
~ limitations under the License.
-->
<enunciate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://enunciate.webcohesion.com/schemas/enunciate-2.11.0.xsd">
<enunciate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://enunciate.webcohesion.com/schemas/enunciate-2.13.0.xsd">
<title>Atlas REST API</title>
<description> Atlas exposes a variety of REST endpoints to work with types, entities, lineage and data discovery.</description>
<api-classes>
......@@ -25,7 +25,10 @@
</api-classes>
<modules>
<swagger host="localhost:21000" basePath="/api/atlas/"/>
<swagger
base="${project.parent.basedir}/build-tools/src/main/resources/ui-dist"
basePath="/api/atlas/"
/>
<jackson datatype-detection="aggressive" propertiesAlphabetical="true" honorJaxb="false"/>
<jaxrs datatype-detection="aggressive"/>
<jackson1 disabled="true"/>
......
<!DOCTYPE html>
<!--
* 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>Atlas - Rest API</title>
<link rel="stylesheet" type="text/css" href="./swagger-ui.css" >
<link rel="icon" href="../img/favicon.ico" type="image/x-icon" >
<style>
html
{
box-sizing: border-box;
overflow: -moz-scrollbars-vertical;
overflow-y: scroll;
}
*,
*:before,
*:after
{
box-sizing: inherit;
}
body
{
margin:0;
background: #fafafa;
}
</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 src="./index.js" charset="UTF-8"> </script>
</body>
</html>
/**
* 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.
*/
var gatewayUrl;
window.onload = function() {
const ui = SwaggerUIBundle({
url: getSwaggerBaseUrl(window.location.pathname) + "/swagger.json",
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout",
requestInterceptor: function(request) {
if (!request.url.includes("swagger.json")) {
request.url = getAPIUrl(request.url);
}
request.headers['X-XSRF-HEADER'] = "valid";
return request;
},
docExpansion: 'none',
validatorUrl: 'none'
})
window.ui = ui;
document.getElementById("swagger-ui").getElementsByClassName("topbar-wrapper")[0].getElementsByTagName("img")[0].src = gatewayUrl + "/img/atlas_logo.svg";
}
function getSwaggerBaseUrl(url) {
var path = url.replace(/\/[\w-]+.(jsp|html)|\/+$/ig, '');
splitPath = path.split("/");
splitPath.pop();
gatewayUrl = splitPath.join("/");
return window.location.origin + path;
};
function getAPIUrl(url) {
url = new URL(url);
var path = url.origin + gatewayUrl + url.pathname + url.search;
return path;
};
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -64,6 +64,7 @@
<a tabindex="-1" href="javascript:void(0)">Help</span></a>
<ul class="dropdown-menu">
<li><a target="_blank" href="http://atlas.apache.org/">Documentation</a></li>
<li><a target="_blank" href="{{apiDocUrl}}">API Documentation</a></li>
<li class="aboutAtlas"><a href="javascript:void(0)">About</a></li>
</ul>
</li>
......
......@@ -208,6 +208,9 @@ define(['require', 'utils/Enums', 'utils/Utils', 'underscore'], function(require
businessMetadataImportUrl: function() {
return this.entitiesApiUrl() + '/businessmetadata/import';
},
apiDocUrl: function() {
return this.apiBaseUrl + '/apidocs/index.html';
},
categoryApiUrl: function(options) {
var guid = options && options.guid,
list = options && options.list,
......
......@@ -32,7 +32,8 @@ define(['require',
templateHelpers: function() {
return {
glossaryImportTempUrl: UrlLinks.glossaryImportTempUrl(),
businessMetadataImportTempUrl: UrlLinks.businessMetadataImportTempUrl()
businessMetadataImportTempUrl: UrlLinks.businessMetadataImportTempUrl(),
apiDocUrl: UrlLinks.apiDocUrl(),
};
},
ui: {
......
......@@ -47,6 +47,7 @@
<a tabindex="-1" href="javascript:void(0)">Help</span></a>
<ul class="dropdown-menu">
<li><a target="_blank" href="http://atlas.apache.org/">Documentation</a></li>
<li><a target="_blank" href="{{apiDocUrl}}">API Documentation</a></li>
<li class="aboutAtlas"><a href="javascript:void(0)">About</a></li>
</ul>
</li>
......
......@@ -197,6 +197,9 @@ define(['require', 'utils/Enums', 'utils/Utils', 'underscore'], function(require
businessMetadataImportUrl: function() {
return this.entitiesApiUrl() + '/businessmetadata/import';
},
apiDocUrl: function() {
return this.apiBaseUrl + '/apidocs/index.html';
},
categoryApiUrl: function(options) {
var guid = options && options.guid,
list = options && options.list,
......
......@@ -31,6 +31,11 @@ define(['require',
RGlobalSearchLayoutView: "#r_globalSearchLayoutView",
RFilterBrowserLayoutView: "#r_filterBrowserLayoutView"
},
templateHelpers: function() {
return {
apiDocUrl: UrlLinks.apiDocUrl(),
};
},
ui: {
backButton: "[data-id='backButton']",
menuHamburger: "[data-id='menuHamburger']",
......
......@@ -677,7 +677,7 @@
<dropwizard-metrics>3.2.2</dropwizard-metrics>
<elasticsearch.version>6.6.0</elasticsearch.version>
<entity.repository.impl>org.apache.atlas.repository.audit.InMemoryEntityAuditRepository</entity.repository.impl>
<enunciate-maven-plugin.version>2.11.1</enunciate-maven-plugin.version>
<enunciate-maven-plugin.version>2.13.2</enunciate-maven-plugin.version>
<failsafe.version>2.18.1</failsafe.version>
<falcon.version>0.8</falcon.version>
<fastutil.version>6.5.16</fastutil.version>
......
......@@ -547,6 +547,14 @@
<!-- empty groupId/artifactId represents the current build -->
</overlay>
</overlays>
<webResources>
<resource>
<directory>${project.build.directory}/api/v2/apidocs/ui</directory>
<targetPath>apidocs</targetPath>
</resource>
</webResources>
<archive>
<manifest>
<addClasspath>true</addClasspath>
......@@ -810,6 +818,12 @@
<groupId>com.webcohesion.enunciate</groupId>
<artifactId>enunciate-maven-plugin</artifactId>
<version>${enunciate-maven-plugin.version}</version>
<!-- to allow target/api/v2/apidocs/ui to be created before building maven-war-plugin)-->
<executions>
<execution>
<phase>generate-resources</phase>
</execution>
</executions>
<configuration>
<configFile>${project.parent.basedir}/build-tools/src/main/resources/enunciate.xml</configFile>
<enunciateArtifactId/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment