Skip to content
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
4 changes: 2 additions & 2 deletions src/core/plugins/oas3/components/servers.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ export default class Servers extends React.Component {
servers,
setServerVariableValue,
getServerVariable
} = this.props
} = nextProps

if(this.props.currentServer !== nextProps.currentServer) {
if (this.props.currentServer !== nextProps.currentServer || this.props.servers !== nextProps.servers) {
// Server has changed, we may need to set default values
let currentServerDefinition = servers
.find(v => v.get("url") === nextProps.currentServer)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
openapi: 3.0.2
servers:
- url: /test-url-switch-1
- url: /test-url-switch-2
info:
title: multi-server test, switch
version: 0.0.1
description: |-
a simple test to select different servers
paths:
/:
get:
summary: an operation
responses:
"200":
description: OK
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
openapi: 3.0.2
servers:
- url: /test-url-1
- url: /test-url-2
info:
title: multi-server test
version: 0.0.1
description: |-
a simple test to select different servers
paths:
/:
get:
summary: an operation
responses:
"200":
description: OK
82 changes: 82 additions & 0 deletions test/e2e-cypress/tests/features/oas3-multiple-servers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/**
* @prettier
*/

describe("OpenAPI 3.0 Multiple Servers", () => {
it("should render and execute for server '/test-url-1'", () => {
cy.visit(
"/?url=/documents/features/oas3-multiple-servers.yaml"
)
.get(".scheme-container .schemes .servers label > select")
.select("/test-url-1")
.get("#operations-default-get_")
.click()
// Expand Try It Out
.get(".try-out__btn")
.click()
// Execute
.get(".execute.opblock-control__btn")
.click()
.get(".responses-wrapper .request-url")
.should("contains.text", "/test-url-1")
})
it("should render and execute for server '/test-url-2'", () => {
cy.visit(
"/?url=/documents/features/oas3-multiple-servers.yaml"
)
.get(".scheme-container .schemes .servers label > select")
.select("/test-url-2")
.get("#operations-default-get_")
.click()
// Expand Try It Out
.get(".try-out__btn")
.click()
// Execute
.get(".execute.opblock-control__btn")
.click()
.get(".responses-wrapper .request-url")
.should("contains.text", "/test-url-2")
})
it("should render and execute for server '/test-url-1' after sequence: select '/test-url-2' -> Try-It-Out -> select '/test-url-1'", () => {
cy.visit(
"/?url=/documents/features/oas3-multiple-servers.yaml"
)
.get(".scheme-container .schemes .servers label > select")
.select("/test-url-2")
.get("#operations-default-get_")
.click()
// Expand Try It Out
.get(".try-out__btn")
.click()
// Select a different server
.get(".scheme-container .schemes .servers label > select")
.select("/test-url-1")
// Execute
.get(".execute.opblock-control__btn")
.click()
.get(".responses-wrapper .request-url")
.should("contains.text", "/test-url-1")
})
it("should render and execute for server '/test-url-switch-1' after changing api defintion", () => {
cy.visit(
"/?url=/documents/features/oas3-multiple-servers.yaml"
)
.get(".scheme-container .schemes .servers label > select")
.select("/test-url-2")
cy.visit(
"/?url=/documents/features/oas3-multiple-servers-switch.yaml"
)
.get(".scheme-container .schemes .servers label > select")
.select("/test-url-switch-2")
.get("#operations-default-get_")
.click()
// Expand Try It Out
.get(".try-out__btn")
.click()
// Execute
.get(".execute.opblock-control__btn")
.click()
.get(".responses-wrapper .request-url")
.should("contains.text", "/test-url-switch-2")
})
})