mirror of
https://github.com/foss42/apidash.git
synced 2025-12-02 18:57:05 +08:00
modify core http_service
This commit is contained in:
@@ -74,7 +74,7 @@ class EditRequestBody extends ConsumerWidget {
|
|||||||
|
|
||||||
ref
|
ref
|
||||||
.read(collectionStateNotifierProvider.notifier)
|
.read(collectionStateNotifierProvider.notifier)
|
||||||
.update(body: removeJsonComments(value));
|
.update(body: value);
|
||||||
},
|
},
|
||||||
hintText: kHintJson,
|
hintText: kHintJson,
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'package:apidash_core/apidash_core.dart';
|
import 'package:apidash_core/apidash_core.dart';
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:json5/json5.dart' as json5;
|
|
||||||
|
|
||||||
String humanizeDate(DateTime? date) {
|
String humanizeDate(DateTime? date) {
|
||||||
if (date == null) {
|
if (date == null) {
|
||||||
@@ -84,12 +82,3 @@ Uint8List jsonMapToBytes(Map<String, dynamic>? map) {
|
|||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String removeJsonComments(String json) {
|
|
||||||
try {
|
|
||||||
var parsed = json5.json5Decode(json);
|
|
||||||
return jsonEncode(parsed);
|
|
||||||
} catch (e) {
|
|
||||||
return json;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -41,7 +41,10 @@ Future<(HttpResponse?, Duration?, String?)> sendHttpRequest(
|
|||||||
if (kMethodsWithBody.contains(requestModel.method)) {
|
if (kMethodsWithBody.contains(requestModel.method)) {
|
||||||
var requestBody = requestModel.body;
|
var requestBody = requestModel.body;
|
||||||
if (requestBody != null && !isMultiPartRequest) {
|
if (requestBody != null && !isMultiPartRequest) {
|
||||||
var contentLength = utf8.encode(requestBody).length;
|
if (requestModel.hasJsonData) {
|
||||||
|
requestBody = removeJsonComments(requestBody);
|
||||||
|
}
|
||||||
|
var contentLength = utf8.encode(requestBody!).length;
|
||||||
if (contentLength > 0) {
|
if (contentLength > 0) {
|
||||||
body = requestBody;
|
body = requestBody;
|
||||||
headers[HttpHeaders.contentLengthHeader] =
|
headers[HttpHeaders.contentLengthHeader] =
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:apidash_core/consts.dart';
|
import 'package:apidash_core/consts.dart';
|
||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
import 'package:seed/seed.dart';
|
import 'package:seed/seed.dart';
|
||||||
import '../models/models.dart';
|
import '../models/models.dart';
|
||||||
import 'graphql_utils.dart';
|
import 'graphql_utils.dart';
|
||||||
|
import 'package:json5/json5.dart' as json5;
|
||||||
|
|
||||||
Map<String, String>? rowsToMap(
|
Map<String, String>? rowsToMap(
|
||||||
List<NameValueModel>? kvRows, {
|
List<NameValueModel>? kvRows, {
|
||||||
@@ -101,3 +104,14 @@ String? getRequestBody(APIType type, HttpRequestModel httpRequestModel) {
|
|||||||
APIType.graphql => getGraphQLBody(httpRequestModel),
|
APIType.graphql => getGraphQLBody(httpRequestModel),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String? removeJsonComments(String? json) {
|
||||||
|
try {
|
||||||
|
if (json == null) return null;
|
||||||
|
|
||||||
|
var parsed = json5.json5Decode(json);
|
||||||
|
return kJsonEncoder.convert(parsed);
|
||||||
|
} catch (e) {
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ dependencies:
|
|||||||
path: ../insomnia_collection
|
path: ../insomnia_collection
|
||||||
seed: ^0.0.3
|
seed: ^0.0.3
|
||||||
xml: ^6.3.0
|
xml: ^6.3.0
|
||||||
|
json5: ^0.8.2
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|||||||
@@ -809,7 +809,7 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "0.7.1"
|
version: "0.7.1"
|
||||||
json5:
|
json5:
|
||||||
dependency: "direct main"
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: json5
|
name: json5
|
||||||
sha256: b67d6e06c9e225c8277d3c43f796677af7975a2a2b0669ff12ba38ff466a31f4
|
sha256: b67d6e06c9e225c8277d3c43f796677af7975a2a2b0669ff12ba38ff466a31f4
|
||||||
|
|||||||
@@ -66,7 +66,6 @@ dependencies:
|
|||||||
url: https://github.com/google/flutter-desktop-embedding.git
|
url: https://github.com/google/flutter-desktop-embedding.git
|
||||||
path: plugins/window_size
|
path: plugins/window_size
|
||||||
share_plus: ^10.1.4
|
share_plus: ^10.1.4
|
||||||
json5: ^0.8.2
|
|
||||||
|
|
||||||
dependency_overrides:
|
dependency_overrides:
|
||||||
extended_text_field: ^16.0.0
|
extended_text_field: ^16.0.0
|
||||||
|
|||||||
Reference in New Issue
Block a user