mirror of
https://github.com/foss42/apidash.git
synced 2025-08-14 14:31:21 +08:00
Fixed a bug in toCurlString() and fixed the dart_to_curl_test with valid curls.
This commit is contained in:
@ -260,7 +260,11 @@ class Curl extends Equatable {
|
|||||||
if (form) {
|
if (form) {
|
||||||
for (final formEntry in formData!) {
|
for (final formEntry in formData!) {
|
||||||
cmd += '\\\n -F ';
|
cmd += '\\\n -F ';
|
||||||
cmd += '"${formEntry.name}=${formEntry.value}" ';
|
if (formEntry.type == FormDataType.file) {
|
||||||
|
cmd += '"${formEntry.name}=@${formEntry.value}" ';
|
||||||
|
} else {
|
||||||
|
cmd += '"${formEntry.name}=${formEntry.value}" ';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Add the insecure flag
|
// Add the insecure flag
|
||||||
|
@ -51,9 +51,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
curl.toCurlString(),
|
curl.toCurlString(),
|
||||||
'curl "https://api.apidash.dev" \\\n'
|
'curl "https://api.apidash.dev" \\\n -H "Content-Type: application/json" \\\n -H "Authorization: Bearer token123"',
|
||||||
' -H "Content-Type: application/json" \\\n'
|
|
||||||
' -H "Authorization: Bearer token123"',
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -66,9 +64,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
curl.toCurlString(),
|
curl.toCurlString(),
|
||||||
'curl -X POST "https://api.apidash.dev/test" \\\n'
|
"""curl -X POST "https://api.apidash.dev/test" \\\n -H "Content-Type: application/json" \\\n -d '{"key": "value"}'""",
|
||||||
' -H "Content-Type: application/json" \\\n'
|
|
||||||
' -d \'{"key": "value"}\'',
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -95,10 +91,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
curl.toCurlString(),
|
curl.toCurlString(),
|
||||||
'curl -X POST "https://api.apidash.dev/upload" \\\n'
|
'curl -X POST "https://api.apidash.dev/upload" \\\n -H "Content-Type: multipart/form-data" \\\n -F "file=@/path/to/file.txt" \\\n -F "name=test"',
|
||||||
' -H "Content-Type: multipart/form-data" \\\n'
|
|
||||||
' -F "file=/path/to/file.txt" \\\n'
|
|
||||||
' -F "name=test"',
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -112,8 +105,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
curl.toCurlString(),
|
curl.toCurlString(),
|
||||||
'curl "https://api.apidash.dev" \\\n'
|
"""curl "https://api.apidash.dev" \\\n -b 'session=abc123'""",
|
||||||
' -b \'session=abc123\'',
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -125,8 +117,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
curl.toCurlString(),
|
curl.toCurlString(),
|
||||||
'curl "https://api.apidash.dev" \\\n'
|
"""curl "https://api.apidash.dev" \\\n -u 'username:password'""",
|
||||||
' -u \'username:password\'',
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -138,8 +129,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
curl.toCurlString(),
|
curl.toCurlString(),
|
||||||
'curl "https://api.apidash.dev" \\\n'
|
"""curl "https://api.apidash.dev" \\\n -e 'https://example.com'""",
|
||||||
' -e \'https://example.com\'',
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -151,8 +141,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
curl.toCurlString(),
|
curl.toCurlString(),
|
||||||
'curl "https://api.apidash.dev" \\\n'
|
"""curl "https://api.apidash.dev" \\\n -A 'MyApp/1.0'""",
|
||||||
' -A \'MyApp/1.0\'',
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -164,8 +153,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
curl.toCurlString(),
|
curl.toCurlString(),
|
||||||
'curl "https://api.apidash.dev" \\\n'
|
"""curl "https://api.apidash.dev" \\\n -k""",
|
||||||
' -k',
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -177,8 +165,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
curl.toCurlString(),
|
curl.toCurlString(),
|
||||||
'curl "https://api.apidash.dev" \\\n'
|
"""curl "https://api.apidash.dev" \\\n -L""",
|
||||||
' -L',
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -202,16 +189,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
curl.toCurlString(),
|
curl.toCurlString(),
|
||||||
'curl -X POST "https://api.apidash.dev/test" \\\n'
|
"""curl -X POST "https://api.apidash.dev/test" \\\n -H "Content-Type: application/json" \\\n -H "Authorization: Bearer token123" \\\n -d '{"key": "value"}' \\\n -b 'session=abc123' \\\n -u 'username:password' \\\n -e 'https://example.com' \\\n -A 'MyApp/1.0' \\\n -k \\\n -L""",
|
||||||
' -H "Content-Type: application/json" \\\n'
|
|
||||||
' -H "Authorization: Bearer token123" \\\n'
|
|
||||||
' -d \'{"key": "value"}\' \\\n'
|
|
||||||
' -b \'session=abc123\' \\\n'
|
|
||||||
' -u \'username:password\' \\\n'
|
|
||||||
' -e \'https://example.com\' \\\n'
|
|
||||||
' -A \'MyApp/1.0\' \\\n'
|
|
||||||
' -k \\\n'
|
|
||||||
' -L',
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user