mirror of
https://github.com/foss42/apidash.git
synced 2025-05-17 22:36:16 +08:00
Add postman utilities
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
library postman;
|
||||
|
||||
export 'models/models.dart';
|
||||
export 'utils/postman_utils.dart';
|
||||
|
33
packages/postman/lib/utils/postman_utils.dart
Normal file
33
packages/postman/lib/utils/postman_utils.dart
Normal file
@ -0,0 +1,33 @@
|
||||
import '../models/postman_collection.dart';
|
||||
|
||||
List<(String?, Request)> getRequestsFromPostmanCollection(
|
||||
PostmanCollection? pc) {
|
||||
if (pc == null || pc.item == null) {
|
||||
return [];
|
||||
}
|
||||
List<(String?, Request)> requests = [];
|
||||
if (pc.item!.length > 0) {
|
||||
for (var i in pc.item!) {
|
||||
requests.addAll(getRequestsFromPostmanItem(i));
|
||||
}
|
||||
}
|
||||
return requests;
|
||||
}
|
||||
|
||||
List<(String?, Request)> getRequestsFromPostmanItem(Item? item) {
|
||||
if (item == null) {
|
||||
return [];
|
||||
}
|
||||
List<(String?, Request)> requests = [];
|
||||
if (item.request != null) {
|
||||
requests.add((item.name, item.request!));
|
||||
} else {
|
||||
if (item.item != null && item.item!.length > 0) {
|
||||
for (var i in item.item!) {
|
||||
var r = getRequestsFromPostmanItem(i);
|
||||
requests.addAll(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
return requests;
|
||||
}
|
Reference in New Issue
Block a user