diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 46a9b053..211eaf06 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -129,21 +129,28 @@ flutter test test/widgets/codegen_previewer_test.dart
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
+## Platform-specific Additional Instructions
-### Network Connection Issues on macOS
+### macOS
-If you encounter a network connection error similar to the following while running your Flutter app on macOS:
+Add below keys to `macos/Runner/DebugProfile.entitlements` and `macos/Runner/Release.entitlements`.
+
+```
+ com.apple.security.network.server
+
+ com.apple.security.network.client
+
+ com.apple.security.files.downloads.read-write
+
+ com.apple.security.files.user-selected.read-write
+
+```
+
+If not added, you can 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..f6f73d62 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 ⭐️
@@ -113,18 +123,28 @@ API Dash can be downloaded from the links below:
API Dash currently supports API integration code generation for the following languages/libraries.
-| Language | Library |
-| ---------------------- | ------------- |
-| cURL | |
-| HAR | |
-| Dart | `http` |
-| JavaScript | `axios` |
-| JavaScript | `fetch` |
-| JavaScript (`node.js`) | `axios` |
-| JavaScript (`node.js`) | `fetch` |
-| Python | `http.client` |
-| Python | `requests` |
-| Kotlin | `okhttp3` |
+| Language | Library | Comment/Issues |
+| ---------------------- | ------------- | ------- |
+| cURL | | |
+| HAR | | |
+| Dart | `http` | |
+| Dart | `dio` | |
+| Go | `net/http` | |
+| JavaScript | `axios` | |
+| JavaScript | `fetch` | |
+| JavaScript (`node.js`) | `axios` | |
+| JavaScript (`node.js`) | `fetch` | |
+| Python | `requests` | |
+| Python | `http.client` | |
+| Kotlin | `okhttp3` | |
+| Rust | `reqwest` | |
+| Rust | `ureq` | |
+| Rust | `Actix Client` | |
+| Java | `asynchttpclient` | https://github.com/foss42/apidash/issues/136 |
+| Java | `HttpClient` | https://github.com/foss42/apidash/issues/137 |
+| Java | `okhttp3` | |
+| Julia | `HTTP` | https://github.com/foss42/apidash/issues/154 |
+| PHP | `guzzle` | https://github.com/foss42/apidash/issues/143 |
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 db4334a0..6b5c5be3 100644
--- a/lib/codegen/codegen.dart
+++ b/lib/codegen/codegen.dart
@@ -1,50 +1,87 @@
import 'package:apidash/codegen/rust/curl-rust.dart';
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.goHttp:
+ return GoHttpCodeGen().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.javaAsyncHttpClient:
+ return JavaAsyncHttpClientGen().getCode(rM);
+ case CodegenLanguage.javaHttpClient:
+ return JavaHttpClientCodeGen().getCode(rM);
+ case CodegenLanguage.javaOkHttp:
+ return JavaOkHttpCodeGen().getCode(rM);
+ case CodegenLanguage.juliaHttp:
+ return JuliaHttpClientCodeGen().getCode(rM);
case CodegenLanguage.kotlinOkHttp:
- return KotlinOkHttpCodeGen().getCode(requestModel, defaultUriScheme);
+ return KotlinOkHttpCodeGen().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.rustCurl:
- return RustCurlCodeGen().getCode(requestModel, defaultUriScheme);
+ return RustCurlCodeGen().getCode(rM);
+ case CodegenLanguage.rustUreq:
+ return RustUreqCodeGen().getCode(rM, boundary: boundary);
+ case CodegenLanguage.phpGuzzle:
+ return PhpGuzzleCodeGen().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