Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
11 changes: 10 additions & 1 deletion src/core/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,16 @@ export const parseSearch = () => {
continue
}
i = params[i].split("=")
map[decodeURIComponent(i[0])] = (i[1] && decodeURIComponent(i[1])) || ""

let value = i[1] ? decodeURIComponent(i[1]) : ""

if (value === "true") {
value = true
} else if (value === "false") {
value = false
}

map[decodeURIComponent(i[0])] = value
}
}

Expand Down
44 changes: 34 additions & 10 deletions test/e2e-cypress/e2e/features/syntax-highlighting-json.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,29 @@ describe("Syntax Highlighting for JSON value cases", () => {
describe("OAS 2", () => {
it("should render full syntax highlighted string in Request (param body) example", () => {
cy.visit("/?url=/documents/features/syntax-highlighting-json-oas2.yaml")
.get("#operations-default-post_setServices")
.click()
.get(".body-param__example > .language-json > :nth-child(10)")
.should("have.text", "\"79daf5b4-aa4b-1452-eae5-42c231477ba7\"")
.get("#operations-default-post_setServices")
.click()
.get(".body-param__example > .language-json > :nth-child(10)")
.should("have.text", '"79daf5b4-aa4b-1452-eae5-42c231477ba7"')
})
it("should render full syntax highlighted string in Response example", () => {
cy.visit("/?url=/documents/features/syntax-highlighting-json-oas2.yaml")
.get("#operations-default-post_setServices")
.click()
.get(".example > .language-json > :nth-child(28)")
.should("have.text", "\"5ff06f632bb165394501b05d3a833355\"")
.get("#operations-default-post_setServices")
.click()
.get(".example > .language-json > :nth-child(28)")
.should("have.text", '"5ff06f632bb165394501b05d3a833355"')
})
it("should not render syntax highlighted string when syntaxHighlight.activated is set to false", () => {
cy.visit(
"/?syntaxHighlight.activated=false&url=/documents/features/syntax-highlighting-json-oas2.yaml"
)
.get("#operations-default-post_setServices")
.click()
.get(".example > .language-json")
.should("not.exist")
.get(".example")
.contains('"5ff06f632bb165394501b05d3a833355"')
.should("exist")
})
})
describe("OAS 3", () => {
Expand All @@ -27,14 +39,26 @@ describe("Syntax Highlighting for JSON value cases", () => {
.get("#operations-default-post_setServices")
.click()
.get(".body-param__example > .language-json > :nth-child(15)")
.should("have.text", "\"22a124b4-594b-4452-bdf5-fc3ef1477ba7\"")
.should("have.text", '"22a124b4-594b-4452-bdf5-fc3ef1477ba7"')
})
it("should render full syntax highlighted string in Response example", () => {
cy.visit("/?url=/documents/features/syntax-highlighting-json-oas3.yaml")
.get("#operations-default-post_setServices")
.click()
.get(".example > .language-json > :nth-child(33)")
.should("have.text", "\"f0009babde9dbe204540d79cf754408e\"")
.should("have.text", '"f0009babde9dbe204540d79cf754408e"')
})
it("should not render syntax highlighted string when syntaxHighlight is set to false", () => {
cy.visit(
"/?syntaxHighlight=false&url=/documents/features/syntax-highlighting-json-oas3.yaml"
)
.get("#operations-default-post_setServices")
.click()
.get(".example > .language-json")
.should("not.exist")
.get(".example")
.contains('"f0009babde9dbe204540d79cf754408e"')
.should("exist")
})
})
})
5 changes: 5 additions & 0 deletions test/unit/core/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1326,6 +1326,11 @@ describe("utils", () => {
win.location.search = "?foo=foo%20bar"
expect(parseSearch()).toEqual({foo: "foo bar"})
})

it("parses boolean values", () => {
win.location.search = "?foo=true&bar=false"
expect(parseSearch()).toEqual({foo: true, bar: false})
})
})

describe("serializing", () => {
Expand Down