mirror of
https://github.com/foss42/apidash.git
synced 2025-07-04 07:18:11 +08:00
Update CurlIO
This commit is contained in:
@ -7,7 +7,7 @@ class Importer {
|
||||
String content,
|
||||
) async {
|
||||
return switch (fileType) {
|
||||
ImportFormat.curl => CurlFileImport().getHttpRequestModel(content),
|
||||
ImportFormat.curl => CurlIO().getHttpRequestModel(content),
|
||||
ImportFormat.postman => null
|
||||
};
|
||||
}
|
||||
|
@ -3,10 +3,12 @@ import '../consts.dart';
|
||||
import '../models/models.dart';
|
||||
import '../utils/utils.dart';
|
||||
|
||||
class CurlFileImport {
|
||||
class CurlIO {
|
||||
List<HttpRequestModel>? getHttpRequestModel(String content) {
|
||||
content = content.trim();
|
||||
try {
|
||||
// TODO: Allow files with multiple curl commands and create
|
||||
// a request model for each
|
||||
final curl = Curl.parse(content);
|
||||
final url = stripUriParams(curl.uri);
|
||||
final method = HTTPVerb.values.byName(curl.method.toLowerCase());
|
||||
|
@ -3,10 +3,10 @@ import 'package:apidash_core/apidash_core.dart';
|
||||
|
||||
void main() {
|
||||
group('CurlFileImport Tests', () {
|
||||
late CurlFileImport curlImport;
|
||||
late CurlIO curlImport;
|
||||
|
||||
setUp(() {
|
||||
curlImport = CurlFileImport();
|
||||
curlImport = CurlIO();
|
||||
});
|
||||
|
||||
test('should parse simple GET request', () {
|
||||
|
Reference in New Issue
Block a user