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) {
this.rawInput = !canToggleRaw
},
rawInput(status) {
if (status && this.rawParams === "") {
this.rawParams = "{}"
} else {
this.setRouteQueryState()
contentType(contentType) {
switch (contentType) {
case "application/json":
case "application/hal+json":
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) {
if (