diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 58fd388d..46a9b053 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -128,3 +128,23 @@ flutter test test/widgets/codegen_previewer_test.dart
### How to add a new package to pubspec.yaml?
Instead of copy pasting from pub.dev, it is recommended that you use `flutter pub add package_name` to add a new package to `pubspec.yaml`. You can read more [here](https://docs.flutter.dev/packages-and-plugins/using-packages#adding-a-package-dependency-to-an-app-using-flutter-pub-add).
+
+## Troubleshooting Common Issues
+
+### Network Connection Issues on macOS
+
+If you encounter a network connection error similar to the following while running your Flutter app on macOS:
+
+```
+ClientException with SocketException: Connection failed (OS Error: Operation not permitted, errno = 1)
+```
+Add below key to `macos/Runner/DebugProfile.entitlements` and `macos/Runner/Release.entitlements`.
+
+```
+ com.apple.security.network.client
+
+```
+
+You can read more [here](https://docs.flutter.dev/platform-integration/macos/building#setting-up-entitlements)
+
+
diff --git a/README.md b/README.md
index d8b258e5..c2760f5d 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,17 @@
[](https://bit.ly/heyfoss)
-We are participating in GSoC 2024 🎉 [More Details ...](https://summerofcode.withgoogle.com/programs/2024/organizations/api-dash)
+🚨 We are participating in GSoC 2024 🎉
+
+
+
+| | Link |
+|--|--|
+| Learn about GSoC | [Link](https://summerofcode.withgoogle.com) |
+| Organization page on GSoC | [Link](https://summerofcode.withgoogle.com/programs/2024/organizations/api-dash) |
+| Project Ideas List | [Link](https://github.com/foss42/apidash/discussions/112) |
+| Application Guide | [Link](https://github.com/foss42/apidash/discussions/111) |
+| Discord Channel | [Link](https://discord.com/invite/2s49SCNfyJ) |
### Please support this initiative by giving this project a Star ⭐️
@@ -125,6 +135,7 @@ API Dash currently supports API integration code generation for the following la
| Python | `http.client` |
| Python | `requests` |
| Kotlin | `okhttp3` |
+| Java | `okhttp3` |
We welcome contributions to support other programming languages/libraries/frameworks. Please check out more details [here](https://github.com/foss42/apidash/discussions/80).
diff --git a/lib/codegen/codegen.dart b/lib/codegen/codegen.dart
index aed1074d..e2038a27 100644
--- a/lib/codegen/codegen.dart
+++ b/lib/codegen/codegen.dart
@@ -1,50 +1,84 @@
import 'package:apidash/models/models.dart' show RequestModel;
import 'package:apidash/consts.dart';
+import 'package:apidash/utils/utils.dart' show getNewUuid;
import 'dart/http.dart';
import 'dart/dio.dart';
+import 'go/http.dart';
import 'kotlin/okhttp.dart';
import 'php/guzzle.dart';
import 'python/http_client.dart';
import 'python/requests.dart';
+import 'rust/actix.dart';
+import 'rust/reqwest.dart';
+import 'rust/ureq.dart';
import 'js/axios.dart';
import 'js/fetch.dart';
import 'others/har.dart';
import 'others/curl.dart';
+import 'julia/http.dart';
+import 'java/okhttp.dart';
+import 'java/async_http_client.dart';
+import 'java/httpclient.dart';
class Codegen {
String? getCode(
CodegenLanguage codegenLanguage,
RequestModel requestModel,
- String defaultUriScheme,
- ) {
+ String defaultUriScheme, {
+ String? boundary,
+ }) {
+ String url = requestModel.url;
+
+ if (url.isEmpty) {
+ url = kDefaultUri;
+ }
+ if (!url.contains("://") && url.isNotEmpty) {
+ url = "$defaultUriScheme://$url";
+ }
+ var rM = requestModel.copyWith(url: url);
+
switch (codegenLanguage) {
case CodegenLanguage.curl:
- return cURLCodeGen().getCode(requestModel, defaultUriScheme);
+ return cURLCodeGen().getCode(rM);
case CodegenLanguage.har:
- return HARCodeGen().getCode(requestModel, defaultUriScheme);
+ return HARCodeGen().getCode(rM, defaultUriScheme, boundary: boundary);
case CodegenLanguage.dartHttp:
- return DartHttpCodeGen().getCode(requestModel, defaultUriScheme);
+ return DartHttpCodeGen().getCode(rM);
case CodegenLanguage.dartDio:
- return DartDioCodeGen().getCode(requestModel, defaultUriScheme);
+ return DartDioCodeGen().getCode(rM);
+ case CodegenLanguage.javaAsyncHttpClient:
+ return JavaAsyncHttpClientGen().getCode(rM);
+ case CodegenLanguage.javaHttpClient:
+ return JavaHttpClientCodeGen().getCode(rM);
+ case CodegenLanguage.javaOkHttp:
+ return JavaOkHttpCodeGen().getCode(rM);
case CodegenLanguage.jsAxios:
- return AxiosCodeGen().getCode(requestModel, defaultUriScheme);
+ return AxiosCodeGen().getCode(rM);
case CodegenLanguage.jsFetch:
- return FetchCodeGen().getCode(requestModel, defaultUriScheme);
+ return FetchCodeGen().getCode(rM);
case CodegenLanguage.nodejsAxios:
- return AxiosCodeGen(isNodeJs: true)
- .getCode(requestModel, defaultUriScheme);
+ return AxiosCodeGen(isNodeJs: true).getCode(rM);
case CodegenLanguage.nodejsFetch:
- return FetchCodeGen(isNodeJs: true)
- .getCode(requestModel, defaultUriScheme);
+ return FetchCodeGen(isNodeJs: true).getCode(rM);
case CodegenLanguage.kotlinOkHttp:
- return KotlinOkHttpCodeGen().getCode(requestModel, defaultUriScheme);
+ return KotlinOkHttpCodeGen().getCode(rM);
case CodegenLanguage.phpGuzzle:
- return PhpGuzzleCodeGen().getCode(requestModel, defaultUriScheme);
+ return PhpGuzzleCodeGen().getCode(rM);
case CodegenLanguage.pythonHttpClient:
return PythonHttpClientCodeGen()
- .getCode(requestModel, defaultUriScheme);
+ .getCode(rM, boundary: boundary ?? getNewUuid());
case CodegenLanguage.pythonRequests:
- return PythonRequestsCodeGen().getCode(requestModel, defaultUriScheme);
+ return PythonRequestsCodeGen().getCode(rM, boundary: boundary);
+ case CodegenLanguage.rustActix:
+ return RustActixCodeGen().getCode(rM, boundary: boundary);
+ case CodegenLanguage.rustReqwest:
+ return RustReqwestCodeGen().getCode(rM);
+ case CodegenLanguage.rustUreq:
+ return RustUreqCodeGen().getCode(rM, boundary: boundary);
+ case CodegenLanguage.goHttp:
+ return GoHttpCodeGen().getCode(rM);
+ case CodegenLanguage.juliaHttp:
+ return JuliaHttpClientCodeGen().getCode(rM);
}
}
}
diff --git a/lib/codegen/codegen_utils.dart b/lib/codegen/codegen_utils.dart
new file mode 100644
index 00000000..2d7a1846
--- /dev/null
+++ b/lib/codegen/codegen_utils.dart
@@ -0,0 +1,15 @@
+String jsonToPyDict(String jsonString) {
+ Map replaceWithMap = {
+ "null": "None",
+ "true": "True",
+ "false": "False"
+ };
+ String pyDict = jsonString;
+ for (var k in replaceWithMap.keys) {
+ RegExp regExp = RegExp(k + r'(?=([^"]*"[^"]*")*[^"]*$)');
+ pyDict = pyDict.replaceAllMapped(regExp, (match) {
+ return replaceWithMap[match.group(0)] ?? match.group(0)!;
+ });
+ }
+ return pyDict;
+}
diff --git a/lib/codegen/dart/dio.dart b/lib/codegen/dart/dio.dart
index c4a7ed8e..e9590f79 100644
--- a/lib/codegen/dart/dio.dart
+++ b/lib/codegen/dart/dio.dart
@@ -8,15 +8,10 @@ import 'shared.dart';
class DartDioCodeGen {
String? getCode(
RequestModel requestModel,
- String defaultUriScheme,
) {
try {
- String url = requestModel.url;
- if (!url.contains("://") && url.isNotEmpty) {
- url = "$defaultUriScheme://$url";
- }
final next = generatedDartCode(
- url: url,
+ url: requestModel.url,
method: requestModel.method,
queryParams: requestModel.enabledParamsMap,
headers: requestModel.enabledHeadersMap,
@@ -60,12 +55,17 @@ class DartDioCodeGen {
final List