Merge pull request #693 from leomp12/fix/raw-input

Fix raw input (JSON)
This commit is contained in:
Liyas Thomas
2020-03-22 10:01:40 +05:30
committed by GitHub

View File

@@ -1432,8 +1432,17 @@ export default {
]) ])
}, },
}, },
canListParameters(canToggleRaw) { canListParameters: {
this.rawInput = !canToggleRaw immediate: true,
handler(canListParameters) {
if (canListParameters) {
this.$nextTick(() => {
this.rawInput = Boolean(this.rawParams && this.rawParams !== "{}")
})
} else {
this.rawInput = true
}
},
}, },
contentType(contentType, oldContentType) { contentType(contentType, oldContentType) {
const getDefaultParams = contentType => { const getDefaultParams = contentType => {
@@ -1529,11 +1538,6 @@ export default {
}, },
}, },
computed: { computed: {
/**
* These are content types that can be automatically
* serialized by postwoman.
*/
knownContentTypes: () => ["application/json", "application/x-www-form-urlencoded", "application/vnd.api+json"],
/** /**
* These are a list of Content Types known to Postwoman. * These are a list of Content Types known to Postwoman.
*/ */
@@ -1546,13 +1550,15 @@ export default {
"text/html", "text/html",
"text/plain", "text/plain",
], ],
/**
* Check content types that can be automatically
* serialized by postwoman.
*/
canListParameters() { canListParameters() {
return [ return (
"application/json", this.contentType === "application/x-www-form-urlencoded" ||
"application/hal+json", this.contentType.endsWith("json")
"application/vnd.api+json", )
"application/x-www-form-urlencoded",
].includes(this.contentType)
}, },
uri: { uri: {
get() { get() {
@@ -1839,7 +1845,7 @@ export default {
}, },
rawRequestBody() { rawRequestBody() {
const { bodyParams, contentType } = this const { bodyParams, contentType } = this
if (contentType === "application/json") { if (contentType.endsWith("json")) {
try { try {
const obj = JSON.parse( const obj = JSON.parse(
`{${bodyParams `{${bodyParams