forked from apache/pulsar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[website][upgrade] feat: rest api pages (apache#13597)
- Loading branch information
1 parent
1b36f32
commit a178b67
Showing
24 changed files
with
1,388 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,4 +20,5 @@ yarn-debug.log* | |
yarn-error.log* | ||
|
||
bak/ | ||
migration-scripts/ | ||
migration-scripts/ | ||
swagger/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
const React = require("react"); | ||
import Layout from "@theme/Layout"; | ||
class RestApi extends React.Component { | ||
componentDidMount() { | ||
var params = window.location.search; | ||
var pathName = window.location.pathname; | ||
params = params.replace("?", ""); | ||
const paramsList = params.split("&"); | ||
var version = "master"; | ||
var apiversion = ""; | ||
for (var i in paramsList) { | ||
var param = paramsList[i].split("="); | ||
if (param[0] === "version") { | ||
version = param[1]; | ||
} | ||
if (param[0] === "apiversion") { | ||
apiversion = param[1]; | ||
} | ||
} | ||
|
||
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(".container"); | ||
const redoc = document.createElement("redoc"); | ||
|
||
if (pathName.indexOf("admin-rest-api") >= 0) { | ||
redoc.setAttribute( | ||
"spec-url", | ||
"/swagger/" + version + "/" + apiversion + "/swagger.json" | ||
); | ||
} else if (pathName.indexOf("functions-rest-api") >= 0) { | ||
redoc.setAttribute( | ||
"spec-url", | ||
"/swagger/" + version + "/" + apiversion + "/swaggerfunctions.json" | ||
); | ||
} else if (pathName.indexOf("source-rest-api") >= 0) { | ||
redoc.setAttribute( | ||
"spec-url", | ||
"/swagger/" + version + "/" + apiversion + "/swaggersource.json" | ||
); | ||
} else if (pathName.indexOf("sink-rest-api") >= 0) { | ||
redoc.setAttribute( | ||
"spec-url", | ||
"/swagger/" + version + "/" + apiversion + "/swaggersink.json" | ||
); | ||
} else if (pathName.indexOf("packages-rest-api" >= 0)) { | ||
redoc.setAttribute( | ||
"spec-url", | ||
"/swagger/" + version + "/" + apiversion + "/swaggerpackages.json" | ||
); | ||
} | ||
redoc.setAttribute("lazy-rendering", "true"); | ||
const redocLink = document.createElement("script"); | ||
redocLink.setAttribute( | ||
"src", | ||
"https://rebilly.github.io/ReDoc/releases/latest/redoc.min.js" | ||
); | ||
const script = document.querySelector(".container script"); | ||
console.log( | ||
"script: ", | ||
script, | ||
"/swagger/" + version + "/" + apiversion + "/swagger.json" | ||
); | ||
wrapper.insertBefore(redoc, script); | ||
wrapper.insertBefore(redocLink, script); | ||
} | ||
|
||
render() { | ||
return ( | ||
<Layout> | ||
<div className="tailwind"> | ||
<div className="my-12 container"></div> | ||
</div> | ||
</Layout> | ||
); | ||
} | ||
} | ||
|
||
export default RestApi; |
Oops, something went wrong.