Update codegens

This commit is contained in:
Ankit Mahato
2024-04-19 19:26:19 +05:30
parent 61f78985ce
commit a5e5fc400d
57 changed files with 488 additions and 399 deletions

View File

@ -4,7 +4,7 @@ import 'package:jinja/jinja.dart' as jj;
import 'package:apidash/consts.dart';
import 'package:apidash/utils/utils.dart'
show getNewUuid, getValidRequestUri, stripUriParams;
import 'package:apidash/models/models.dart' show RequestModel;
import 'package:apidash/models/models.dart';
class RustActixCodeGen {
final String kTemplateStart = """
@ -112,7 +112,7 @@ multipart/form-data; boundary={{boundary}}''';
""";
String? getCode(
RequestModel requestModel, {
HttpRequestModel requestModel, {
String? boundary,
}) {
try {
@ -125,7 +125,7 @@ multipart/form-data; boundary={{boundary}}''';
var rec = getValidRequestUri(
url,
requestModel.enabledRequestParams,
requestModel.enabledParams,
);
Uri? uri = rec.$1;
if (uri != null) {
@ -137,11 +137,11 @@ multipart/form-data; boundary={{boundary}}''';
});
var method = requestModel.method;
var requestBody = requestModel.requestBody;
var requestBody = requestModel.body;
if (kMethodsWithBody.contains(method) && requestBody != null) {
var contentLength = utf8.encode(requestBody).length;
if (contentLength > 0) {
if (requestModel.requestBodyContentType == ContentType.json) {
if (requestModel.bodyContentType == ContentType.json) {
hasJsonBody = true;
var templateBody = jj.Template(kTemplateJson);
result += templateBody.render({"body": requestBody});
@ -179,7 +179,7 @@ multipart/form-data; boundary={{boundary}}''';
}
}
var headersList = requestModel.enabledRequestHeaders;
var headersList = requestModel.enabledHeaders;
if (headersList != null || hasBody || requestModel.hasFormData) {
var headers = requestModel.enabledHeadersMap;
if (requestModel.hasFormData) {
@ -190,7 +190,7 @@ multipart/form-data; boundary={{boundary}}''';
});
} else if (hasBody) {
headers[HttpHeaders.contentTypeHeader] =
requestModel.requestBodyContentType.header;
requestModel.bodyContentType.header;
}
if (headers.isNotEmpty) {