Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improvement: generate default oauth2RedirectUrl based on page location #5085

Merged
merged 2 commits into from
Dec 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ module.exports = function SwaggerUI(opts) {
maxDisplayedTags: null,
filter: null,
validatorUrl: "https://online.swagger.io/validator",
oauth2RedirectUrl: `${window.location.protocol}//${window.location.host}/oauth2-redirect.html`,
configs: {},
custom: {},
displayOperationId: false,
Expand Down
3 changes: 1 addition & 2 deletions swagger-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
url: "https://petstore.swagger.io/v2/swagger.json"
dom_id: "#swagger-ui"
validatorUrl: "https://online.swagger.io/validator"
oauth2RedirectUrl: "http://localhost:3200/oauth2-redirect.html"
validatorUrl: "https://online.swagger.io/validator"
10 changes: 10 additions & 0 deletions test/e2e-cypress/tests/features/dynamic-default-oauth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
describe("dynamic default oauth2RedirectUrl", () => {
it("should render the OAS3 badge correctly", () => {
// This is a sanity check to make sure the badge is present.
// If this is failing, it's probably not related to #4865.
cy.visit("/")
.window()
.then(win => win.ui.getConfigs())
.should("include", { oauth2RedirectUrl: "http://localhost:3230/oauth2-redirect.html" })
})
})