mirror of
https://github.com/foss42/apidash.git
synced 2025-08-06 13:51:20 +08:00
Merge pull request #161 from Tanish2002/fix-redundant-form-payload
fix: remove redundant body payload from codegen
This commit is contained in:
@ -53,7 +53,9 @@ class DartHttpCodeGen {
|
||||
declareVar('uri').assign(refer('Uri.parse').call([literalString(url)]));
|
||||
|
||||
Expression? dataExp;
|
||||
if (kMethodsWithBody.contains(method) && (body?.isNotEmpty ?? false)) {
|
||||
if (kMethodsWithBody.contains(method) &&
|
||||
(body?.isNotEmpty ?? false) &&
|
||||
contentType != ContentType.formdata) {
|
||||
final strContent = CodeExpression(Code('r\'\'\'$body\'\'\''));
|
||||
dataExp = declareVar('body', type: refer('String')).assign(strContent);
|
||||
if (!hasContentTypeHeader) {
|
||||
|
@ -130,7 +130,9 @@ body = b'\r\n'.join(dataList)
|
||||
|
||||
var method = requestModel.method;
|
||||
var requestBody = requestModel.requestBody;
|
||||
if (kMethodsWithBody.contains(method) && requestBody != null) {
|
||||
if (kMethodsWithBody.contains(method) &&
|
||||
requestBody != null &&
|
||||
!requestModel.isFormDataRequest) {
|
||||
var contentLength = utf8.encode(requestBody).length;
|
||||
if (contentLength > 0) {
|
||||
hasBody = true;
|
||||
|
@ -140,7 +140,7 @@ print('Response Body:', response.text)
|
||||
hasJsonBody = true;
|
||||
var templateBody = jj.Template(kTemplateJson);
|
||||
result += templateBody.render({"body": requestBody});
|
||||
} else {
|
||||
} else if (!requestModel.isFormDataRequest) {
|
||||
hasBody = true;
|
||||
var templateBody = jj.Template(kTemplateBody);
|
||||
result += templateBody.render({"body": requestBody});
|
||||
|
@ -112,7 +112,9 @@ Map<String, dynamic> requestModelToHARJsonRequest(
|
||||
|
||||
var method = requestModel.method;
|
||||
var requestBody = requestModel.requestBody;
|
||||
if (kMethodsWithBody.contains(method) && requestBody != null) {
|
||||
if (kMethodsWithBody.contains(method) &&
|
||||
requestBody != null &&
|
||||
!requestModel.isFormDataRequest) {
|
||||
var contentLength = utf8.encode(requestBody).length;
|
||||
if (contentLength > 0) {
|
||||
hasBody = true;
|
||||
|
Reference in New Issue
Block a user