Skip to content

Commit 61b5ed7

Browse files
shockeyRon
authored andcommitted
improvement: generate default oauth2RedirectUrl based on page location (via #5085)
1 parent 9658aca commit 61b5ed7

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

src/core/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ module.exports = function SwaggerUI(opts) {
3737
maxDisplayedTags: null,
3838
filter: null,
3939
validatorUrl: "https://online.swagger.io/validator",
40+
oauth2RedirectUrl: `${window.location.protocol}//${window.location.host}/oauth2-redirect.html`,
4041
configs: {},
4142
custom: {},
4243
displayOperationId: false,

swagger-config.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
---
22
url: "https://petstore.swagger.io/v2/swagger.json"
33
dom_id: "#swagger-ui"
4-
validatorUrl: "https://online.swagger.io/validator"
5-
oauth2RedirectUrl: "http://localhost:3200/oauth2-redirect.html"
4+
validatorUrl: "https://online.swagger.io/validator"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
describe("dynamic default oauth2RedirectUrl", () => {
2+
it("should render the OAS3 badge correctly", () => {
3+
// This is a sanity check to make sure the badge is present.
4+
// If this is failing, it's probably not related to #4865.
5+
cy.visit("/")
6+
.window()
7+
.then(win => win.ui.getConfigs())
8+
.should("include", { oauth2RedirectUrl: "http://localhost:3230/oauth2-redirect.html" })
9+
})
10+
})

0 commit comments

Comments
 (0)