mirror of
https://github.com/foss42/apidash.git
synced 2025-05-31 14:23:45 +08:00
FileType -> ImportFormat
This commit is contained in:
@ -348,8 +348,11 @@ enum CodegenLanguage {
|
||||
final String ext;
|
||||
}
|
||||
|
||||
enum FileType {
|
||||
curl,
|
||||
enum ImportFormat {
|
||||
curl("cURL");
|
||||
|
||||
const ImportFormat(this.label);
|
||||
final String label;
|
||||
}
|
||||
|
||||
const JsonEncoder kEncoder = JsonEncoder.withIndent(' ');
|
||||
|
@ -3,9 +3,10 @@ import 'package:apidash/fileimport/curl/curl.dart';
|
||||
import 'package:apidash/models/request_model.dart';
|
||||
|
||||
class FileImport {
|
||||
Future<RequestModel?> getRequestModel(FileType fileType, String contents, String newId) async {
|
||||
Future<RequestModel?> getRequestModel(
|
||||
ImportFormat fileType, String contents, String newId) async {
|
||||
switch (fileType) {
|
||||
case FileType.curl:
|
||||
case ImportFormat.curl:
|
||||
return CurlFileImport().getRequestModel(contents, newId);
|
||||
default:
|
||||
return null;
|
||||
|
@ -47,7 +47,7 @@ class CollectionPane extends ConsumerWidget {
|
||||
final newId = ref.watch(selectedIdStateProvider)!;
|
||||
final i = file.path.lastIndexOf('.') + 1;
|
||||
final String ext = file.path.substring(i);
|
||||
final fileType = FileType.values.byName(ext);
|
||||
final fileType = ImportFormat.values.byName(ext);
|
||||
file.readAsString().then((contents) {
|
||||
fileImport
|
||||
.getRequestModel(fileType, contents, newId)
|
||||
|
Reference in New Issue
Block a user