Skip to content

Commit

Permalink
Update OpenAPI definition
Browse files Browse the repository at this point in the history
- Add `version` support in the querystring, see README.md
  • Loading branch information
paulrutter committed Apr 5, 2024
1 parent a1dd9dc commit df91e0f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,13 @@ This repository contains the OpenAPI specification for the BlueConic REST API v2
# Running the OpenAPI specification on a local machine
* Clone the repository and `cd` to the repository location
* Run `npx http-server`
* Open http://localhost:8080?hostname=localhost
* Open `http://localhost:8080?hostname=localhost`
* CORS configuration of BlueConic needs to be adjusted to the the localhost origin (`http://localhost:8080` by default)

# Specifying BC version
The `version` querystring parameter can be used to specify a specific BlueConic version. Note that parameter is exclusive with the `hostname` parameter, which will always load the version specified by the tenant being connected to.

* https://rest.apidoc.blueconic.com/?version=89 or https://rest.apidoc.blueconic.com/?version=r89 will load version 89
* https://rest.apidoc.blueconic.com/?version=91 or https://rest.apidoc.blueconic.com/?version=r91 will load version 91
* https://rest.apidoc.blueconic.com/?version=current will load latest version published. Behaves the same as not specifying a version at all.

16 changes: 15 additions & 1 deletion scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ const wrapper = document.getElementById("versionSelectWrapper");


let hostname = getQueryStringParam("hostname");
let version = getQueryStringParam("version");

const rapidoc = document.getElementById("doc");
if (hostname) {
if (!hostname.startsWith("http")) {
Expand All @@ -22,7 +24,19 @@ if (hostname) {
rapidoc.setAttribute("spec-url", `${hostname}/rest/v2/openapi.json`);
} else {
// load local OpenAPI spec
rapidoc.setAttribute("spec-url", "./definitions/openapi_latest.json");
if (version && version !== "current") {
// use specific version passed in querystring
if (!version.startsWith("r")) {
version = `r${version}`;
}
rapidoc.setAttribute("spec-url", `./definitions/${version}/openapi.json`);

// set selected version in dropdown
versionSelect.value = `${version}/openapi`;
} else {
// use latest
rapidoc.setAttribute("spec-url", "./definitions/openapi_latest.json");
}
}

if (hostname || versionSelect.options.length == 1) {
Expand Down

0 comments on commit df91e0f

Please sign in to comment.