fix(req-body): fix preseting default body (raw) by content type

This commit is contained in:
Leonardo Matos
2020-03-17 11:30:45 -03:00
parent 1f38c25e6a
commit 8469d13a12

View File

@@ -1435,12 +1435,25 @@ export default {
canListParameters(canToggleRaw) { canListParameters(canToggleRaw) {
this.rawInput = !canToggleRaw this.rawInput = !canToggleRaw
}, },
rawInput(status) { contentType(contentType) {
if (status && this.rawParams === "") { switch (contentType) {
this.rawParams = "{}" case "application/json":
} else { case "application/hal+json":
this.setRouteQueryState() if (!(this.rawParams.charAt(0) in ['"', "{", "["])) {
this.rawParams = "{}"
}
break
case "application/xml":
if (this.rawParams.charAt(0) !== "<" || this.rawParams === "<!doctype html>") {
this.rawParams = "<?xml version='1.0' encoding='utf-8'?>"
}
break
case "text/html":
if (this.rawParams.charAt(0) !== "<" || this.rawParams.startsWith("<?xml")) {
this.rawParams = "<!doctype html>"
}
} }
this.setRouteQueryState()
}, },
"response.body": function(val) { "response.body": function(val) {
if ( if (