Browse Source

improvement: generate default oauth2RedirectUrl based on page location (via #5085)

bubble
kyle 5 years ago
committed by Ron
parent
commit
61b5ed79a0
3 changed files with 12 additions and 2 deletions
  1. +1
    -0
      src/core/index.js
  2. +1
    -2
      swagger-config.yaml
  3. +10
    -0
      test/e2e-cypress/tests/features/dynamic-default-oauth.js

+ 1
- 0
src/core/index.js View File

@@ -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,


+ 1
- 2
swagger-config.yaml View File

@@ -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
- 0
test/e2e-cypress/tests/features/dynamic-default-oauth.js View File

@@ -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" })
})
})

Loading…
Cancel
Save