Skip to content

Commit

Permalink
[website]Fix rest api (apache#5107)
Browse files Browse the repository at this point in the history
### Motivation
Currently, there are some problems with the display of rest API for function, source, and sink. 2.4.1 does not generate a new swagger file.

### Modifications
* Create directory master
* Generate swagger json file for 2.4.1
* Fix swagger function, source and sink display
  • Loading branch information
tuteng authored and sijie committed Sep 6, 2019
1 parent 79ef292 commit fbb906f
Show file tree
Hide file tree
Showing 6 changed files with 13,090 additions and 2 deletions.
31 changes: 30 additions & 1 deletion site2/website/static/js/getSwaggerByVersion.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
function getSwaggerByVersion(){
var params = window.location.search
var pathName = window.location.pathname
params = params.replace('?', '')
const paramsList = params.split('&')
var version = 'master'
Expand All @@ -9,9 +10,37 @@ function getSwaggerByVersion(){
version = param[1]
}
}
var href = document.querySelector('a[href="/en/versions"]');
href.innerHTML = '<h3>' + version + '</h3>'
var restApiHref = document.querySelectorAll("#restapis-dropdown-items a")
for (var i = 0; i < restApiHref.length; i++) {
var tempHref = restApiHref[i].href
var path = tempHref.split('version')
var newVersionPath = path[0] + 'version=' + version
restApiHref[i].href = newVersionPath
}

if (version !== 'master') {
var versions = version.split('.')
var majorVersion = parseInt(versions[0])
var minorVersion = parseInt(versions[1])
if (majorVersion < 2) {
version = '2.3.0'
} else if (minorVersion < 3) {
version = '2.3.0'
}
}
const wrapper = document.querySelector('.pageContainer .wrapper')
const redoc = document.createElement('redoc');
redoc.setAttribute('spec-url', '/swagger/' + version + '/swagger.json')
if (pathName.indexOf('admin-rest-api') >= 0) {
redoc.setAttribute('spec-url', '/swagger/' + version + '/swagger.json')
} else if (pathName.indexOf('functions-rest-api') >= 0) {
redoc.setAttribute('spec-url', '/swagger/' + version + '/swaggerfunctions.json')
} else if (pathName.indexOf('source-rest-api') >= 0) {
redoc.setAttribute('spec-url', '/swagger/' + version + '/swaggersource.json')
} else if (pathName.indexOf('sink-rest-api') >= 0) {
redoc.setAttribute('spec-url', '/swagger/' + version + '/swaggersink.json')
}
redoc.setAttribute('lazy-rendering', 'true')
const redocLink = document.createElement('script');
redocLink.setAttribute('src', 'https://rebilly.github.io/ReDoc/releases/latest/redoc.min.js')
Expand Down
Loading

0 comments on commit fbb906f

Please sign in to comment.