diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md
new file mode 100644
index 00000000..04873dba
--- /dev/null
+++ b/.github/pull_request_template.md
@@ -0,0 +1,18 @@
+## PR Description
+
+_Add your description_
+
+## Related Issues
+
+- Related Issue #
+- Closes #
+
+### Checklist
+- [ ] I have gone through the [contributing guide](https://github.com/foss42/apidash/blob/main/CONTRIBUTING.md)
+- [ ] I have run the tests (`flutter test`) and all tests are passing
+
+## Added/updated tests?
+_We encourage you to add relevant test cases._
+
+- [ ] Yes
+- [ ] No, and this is why: _please replace this line with details on why tests have not been included_
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 140188ac..46a9b053 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -83,7 +83,7 @@ In case you have already setup Flutter, make sure to switch to `stable` branch a
1. Fork the project.
2. Create a clone of the forked project on your computer to run it locally.
3. Based on your desktop environment, enable Windows, macOS or Linux for the project. Select the same target device.
-4. This project uses [Records feature in Dart](https://github.com/dart-lang/language/blob/main/accepted/future-releases/records/records-feature-specification.md), so to run the project execute the following command:
+4. Run the project by executing the following command:
```
flutter run
@@ -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 7c750dad..c2760f5d 100644
--- a/README.md
+++ b/README.md
@@ -2,6 +2,18 @@
[](https://bit.ly/heyfoss)
+🚨 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 ⭐️
API Dash is a beautiful open-source cross-platform API Client that can help you easily create & customize your API requests, visually inspect responses ([full list of supported mime-types](https://github.com/foss42/apidash?tab=readme-ov-file#mime-types-supported-by-api-dash-response-previewer)) and generate API integration code ([full list](https://github.com/foss42/apidash?tab=readme-ov-file#code-generators)) on the go.
@@ -123,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).
@@ -135,6 +148,7 @@ Here is the complete list of mimetypes that can be directly previewed in API Das
| File Type | Mimetype | Extension | Comment |
| --------- | -------------------------- | ----------------- | -------- |
| PDF | `application/pdf` | `.pdf` | |
+| CSV | `text/csv` | `.csv` | Can be improved |
| Image | `image/apng` | `.apng` | Animated |
| Image | `image/avif` | `.avif` | |
| Image | `image/bmp` | `.bmp` | |
@@ -175,14 +189,14 @@ Here is the complete list of mimetypes that are syntax highlighted in API Dash:
| ------------------ | --------- | ------------------------------------------------------------------------------------------------------------------ |
| `application/json` | `.json` | Other mimetypes like `application/geo+json`, `application/vcard+json` that are based on `json` are also supported. |
| `application/xml` | `.xml` | Other mimetypes like `application/xhtml+xml`, `application/vcard+xml` that are based on `xml` are also supported. |
-| `text/xml` | `.xml` | |
-| `application/yaml` | `.yaml` | Others - `application/x-yaml` or `application/x-yml` |
-| `text/yaml` | `.yaml` | Others - `text/yml` |
-| `application/sql` | `.sql` | |
-| `text/css` | `.css` | |
-| `text/html` | `.html` | Only syntax highlighting, no web preview. |
-| `text/javascript` | `.js` | |
-| `text/markdown` | `.md` | |
+| `text/xml` | `.xml` | |
+| `application/yaml` | `.yaml` | Others - `application/x-yaml` or `application/x-yml` |
+| `text/yaml` | `.yaml` | Others - `text/yml` |
+| `application/sql` | `.sql` | |
+| `text/css` | `.css` | |
+| `text/html` | `.html` | Only syntax highlighting, no web preview. |
+| `text/javascript` | `.js` | |
+| `text/markdown` | `.md` | |
## What's new in v0.3.0?
diff --git a/analysis_options.yaml b/analysis_options.yaml
index 1d5eafa4..9a1eabb4 100644
--- a/analysis_options.yaml
+++ b/analysis_options.yaml
@@ -3,8 +3,9 @@ include: package:flutter_lints/flutter.yaml
analyzer:
errors:
invalid_annotation_target: ignore
- enable-experiment:
- - records
+ exclude:
+ - "**/*.freezed.dart"
+ - "**/*.g.dart"
linter:
rules:
diff --git a/lib/codegen/codegen.dart b/lib/codegen/codegen.dart
index 7276ed29..5100f7aa 100644
--- a/lib/codegen/codegen.dart
+++ b/lib/codegen/codegen.dart
@@ -1,50 +1,81 @@
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 '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.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.javaOkHttp:
+ return JavaOkHttpCodeGen().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);
+ case CodegenLanguage.javaAsyncHttpClient:
+ return JavaAsyncHttpClientGen().getCode(rM);
case CodegenLanguage.javaHttpClient:
- return JavaHttpClientCodeGen().getCode(requestModel, defaultUriScheme);
+ return JavaHttpClientCodeGen().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