From dc771f51e8364df675bf7859fc8a344fc149408b Mon Sep 17 00:00:00 2001 From: Leonardo Matos Date: Fri, 20 Mar 2020 15:40:04 -0300 Subject: [PATCH 1/7] fix(req-body): ensure raw input if `!canListParameters` --- pages/index.vue | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/pages/index.vue b/pages/index.vue index c3bdee4b0..35a01acaf 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -1432,8 +1432,11 @@ export default { ]) }, }, - canListParameters(canToggleRaw) { - this.rawInput = !canToggleRaw + canListParameters: { + immediate: true, + handler (canToggleRaw) { + this.rawInput = !canToggleRaw + } }, contentType(contentType, oldContentType) { const getDefaultParams = contentType => { @@ -1544,11 +1547,7 @@ export default { "text/plain", ], canListParameters() { - return [ - "application/json", - "application/hal+json", - "application/x-www-form-urlencoded", - ].includes(this.contentType) + this.contentType === "application/x-www-form-urlencoded" }, uri: { get() { @@ -1765,7 +1764,7 @@ export default { }, rawInput: { get() { - return this.$store.state.request.rawInput + return this.canListParameter ? this.$store.state.request.rawInput : true }, set(value) { this.$store.commit("setState", { value, attribute: "rawInput" }) From 9a4e64e13f5c0f23bc5b631988c0609700fb3513 Mon Sep 17 00:00:00 2001 From: Leonardo Matos Date: Fri, 20 Mar 2020 15:56:29 -0300 Subject: [PATCH 2/7] fix: fix `canListParameter` (undefined) to `canListParameters` --- pages/index.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pages/index.vue b/pages/index.vue index 35a01acaf..a9541abf0 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -1434,8 +1434,8 @@ export default { }, canListParameters: { immediate: true, - handler (canToggleRaw) { - this.rawInput = !canToggleRaw + handler (canListParameters) { + this.rawInput = !canListParameters } }, contentType(contentType, oldContentType) { @@ -1764,7 +1764,7 @@ export default { }, rawInput: { get() { - return this.canListParameter ? this.$store.state.request.rawInput : true + return this.canListParameters ? this.$store.state.request.rawInput : true }, set(value) { this.$store.commit("setState", { value, attribute: "rawInput" }) From c370ee8018b0fe0f0c3da15b2d357e659d9efbb4 Mon Sep 17 00:00:00 2001 From: Leonardo Matos Date: Fri, 20 Mar 2020 15:58:52 -0300 Subject: [PATCH 3/7] fix: `canListParameters` prop must return --- pages/index.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/index.vue b/pages/index.vue index a9541abf0..ba59c9a6f 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -1547,7 +1547,7 @@ export default { "text/plain", ], canListParameters() { - this.contentType === "application/x-www-form-urlencoded" + return this.contentType === "application/x-www-form-urlencoded" }, uri: { get() { From 90bd8d45b4bc38680ee076030076a606a5b637a1 Mon Sep 17 00:00:00 2001 From: Leonardo Matos Date: Fri, 20 Mar 2020 16:06:52 -0300 Subject: [PATCH 4/7] style(js): minor code style fix --- pages/index.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pages/index.vue b/pages/index.vue index ba59c9a6f..89b432856 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -1434,9 +1434,9 @@ export default { }, canListParameters: { immediate: true, - handler (canListParameters) { + handler(canListParameters) { this.rawInput = !canListParameters - } + }, }, contentType(contentType, oldContentType) { const getDefaultParams = contentType => { From 76786f7a0187e1509489dc1010e1776fe06b300b Mon Sep 17 00:00:00 2001 From: Leonardo Matos Date: Sat, 21 Mar 2020 23:31:56 -0300 Subject: [PATCH 5/7] fix(raw-input): allow list parameters for json, set true when raw params is changed --- pages/index.vue | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/pages/index.vue b/pages/index.vue index 89b432856..a594af062 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -1435,7 +1435,13 @@ export default { canListParameters: { immediate: true, handler(canListParameters) { - this.rawInput = !canListParameters + if (canListParameters) { + this.$nextTick(() => { + this.rawInput = Boolean(this.rawParams && this.rawParams !== "{}") + }) + } else { + this.rawInput = true + } }, }, contentType(contentType, oldContentType) { @@ -1530,11 +1536,6 @@ export default { }, }, computed: { - /** - * These are content types that can be automatically - * serialized by postwoman. - */ - knownContentTypes: () => ["application/json", "application/x-www-form-urlencoded"], /** * These are a list of Content Types known to Postwoman. */ @@ -1546,8 +1547,12 @@ export default { "text/html", "text/plain", ], + /** + * Check content types that can be automatically + * serialized by postwoman. + */ canListParameters() { - return this.contentType === "application/x-www-form-urlencoded" + return ["application/json", "application/x-www-form-urlencoded"].includes(this.contentType) }, uri: { get() { @@ -1764,7 +1769,7 @@ export default { }, rawInput: { get() { - return this.canListParameters ? this.$store.state.request.rawInput : true + return this.$store.state.request.rawInput }, set(value) { this.$store.commit("setState", { value, attribute: "rawInput" }) From 3f9ae7fecc9ec98a2c66dfd01f59b6859a6d3e52 Mon Sep 17 00:00:00 2001 From: Leonardo Matos Date: Sat, 21 Mar 2020 23:37:55 -0300 Subject: [PATCH 6/7] fix(raw-input): allow list parameter for any content type ending with 'json' --- pages/index.vue | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pages/index.vue b/pages/index.vue index a594af062..30bc8b5ca 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -1552,7 +1552,10 @@ export default { * serialized by postwoman. */ canListParameters() { - return ["application/json", "application/x-www-form-urlencoded"].includes(this.contentType) + return ( + this.contentType === "application/x-www-form-urlencoded" || + this.contentType.endsWith("json") + ) }, uri: { get() { From ed4f1fe6f86381c984154da24dc23556156fa387 Mon Sep 17 00:00:00 2001 From: Liyas Thomas Date: Sun, 22 Mar 2020 09:56:53 +0530 Subject: [PATCH 7/7] Update index.vue --- pages/index.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/index.vue b/pages/index.vue index fda9b937a..068d18495 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -1845,7 +1845,7 @@ export default { }, rawRequestBody() { const { bodyParams, contentType } = this - if (contentType === "application/json") { + if (contentType.endsWith("json")) { try { const obj = JSON.parse( `{${bodyParams