mirror of
https://github.com/foss42/apidash.git
synced 2025-05-29 12:59:58 +08:00
Merge branch 'main' into resolve-issue-missing-drag-scrolling
This commit is contained in:
@ -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).
|
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`.
|
||||||
|
|
||||||
|
```
|
||||||
|
<key>com.apple.security.network.server</key>
|
||||||
|
<true/>
|
||||||
|
<key>com.apple.security.network.client</key>
|
||||||
|
<true/>
|
||||||
|
<key>com.apple.security.files.downloads.read-write</key>
|
||||||
|
<true/>
|
||||||
|
<key>com.apple.security.files.user-selected.read-write</key>
|
||||||
|
<true/>
|
||||||
|
```
|
||||||
|
|
||||||
|
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)
|
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`.
|
|
||||||
|
|
||||||
```
|
|
||||||
<key>com.apple.security.network.client</key>
|
|
||||||
<true/>
|
|
||||||
```
|
|
||||||
|
|
||||||
You can read more [here](https://docs.flutter.dev/platform-integration/macos/building#setting-up-entitlements)
|
You can read more [here](https://docs.flutter.dev/platform-integration/macos/building#setting-up-entitlements)
|
||||||
|
|
||||||
|
35
README.md
35
README.md
@ -123,19 +123,28 @@ API Dash can be downloaded from the links below:
|
|||||||
|
|
||||||
API Dash currently supports API integration code generation for the following languages/libraries.
|
API Dash currently supports API integration code generation for the following languages/libraries.
|
||||||
|
|
||||||
| Language | Library |
|
| Language | Library | Comment/Issues |
|
||||||
| ---------------------- | ------------- |
|
| ---------------------- | ------------- | ------- |
|
||||||
| cURL | |
|
| cURL | | |
|
||||||
| HAR | |
|
| HAR | | |
|
||||||
| Dart | `http` |
|
| Dart | `http` | |
|
||||||
| JavaScript | `axios` |
|
| Dart | `dio` | |
|
||||||
| JavaScript | `fetch` |
|
| Go | `net/http` | |
|
||||||
| JavaScript (`node.js`) | `axios` |
|
| JavaScript | `axios` | |
|
||||||
| JavaScript (`node.js`) | `fetch` |
|
| JavaScript | `fetch` | |
|
||||||
| Python | `http.client` |
|
| JavaScript (`node.js`) | `axios` | |
|
||||||
| Python | `requests` |
|
| JavaScript (`node.js`) | `fetch` | |
|
||||||
| Kotlin | `okhttp3` |
|
| Python | `requests` | |
|
||||||
| Java | `okhttp3` |
|
| 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).
|
We welcome contributions to support other programming languages/libraries/frameworks. Please check out more details [here](https://github.com/foss42/apidash/discussions/80).
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import 'dart/http.dart';
|
|||||||
import 'dart/dio.dart';
|
import 'dart/dio.dart';
|
||||||
import 'go/http.dart';
|
import 'go/http.dart';
|
||||||
import 'kotlin/okhttp.dart';
|
import 'kotlin/okhttp.dart';
|
||||||
|
import 'php/guzzle.dart';
|
||||||
import 'python/http_client.dart';
|
import 'python/http_client.dart';
|
||||||
import 'python/requests.dart';
|
import 'python/requests.dart';
|
||||||
import 'rust/actix.dart';
|
import 'rust/actix.dart';
|
||||||
@ -17,6 +18,7 @@ import 'others/curl.dart';
|
|||||||
import 'julia/http.dart';
|
import 'julia/http.dart';
|
||||||
import 'java/okhttp.dart';
|
import 'java/okhttp.dart';
|
||||||
import 'java/async_http_client.dart';
|
import 'java/async_http_client.dart';
|
||||||
|
import 'java/httpclient.dart';
|
||||||
|
|
||||||
class Codegen {
|
class Codegen {
|
||||||
String? getCode(
|
String? getCode(
|
||||||
@ -44,6 +46,8 @@ class Codegen {
|
|||||||
return DartHttpCodeGen().getCode(rM);
|
return DartHttpCodeGen().getCode(rM);
|
||||||
case CodegenLanguage.dartDio:
|
case CodegenLanguage.dartDio:
|
||||||
return DartDioCodeGen().getCode(rM);
|
return DartDioCodeGen().getCode(rM);
|
||||||
|
case CodegenLanguage.goHttp:
|
||||||
|
return GoHttpCodeGen().getCode(rM);
|
||||||
case CodegenLanguage.jsAxios:
|
case CodegenLanguage.jsAxios:
|
||||||
return AxiosCodeGen().getCode(rM);
|
return AxiosCodeGen().getCode(rM);
|
||||||
case CodegenLanguage.jsFetch:
|
case CodegenLanguage.jsFetch:
|
||||||
@ -52,10 +56,16 @@ class Codegen {
|
|||||||
return AxiosCodeGen(isNodeJs: true).getCode(rM);
|
return AxiosCodeGen(isNodeJs: true).getCode(rM);
|
||||||
case CodegenLanguage.nodejsFetch:
|
case CodegenLanguage.nodejsFetch:
|
||||||
return FetchCodeGen(isNodeJs: true).getCode(rM);
|
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:
|
case CodegenLanguage.kotlinOkHttp:
|
||||||
return KotlinOkHttpCodeGen().getCode(rM);
|
return KotlinOkHttpCodeGen().getCode(rM);
|
||||||
case CodegenLanguage.javaOkHttp:
|
|
||||||
return JavaOkHttpCodeGen().getCode(rM);
|
|
||||||
case CodegenLanguage.pythonHttpClient:
|
case CodegenLanguage.pythonHttpClient:
|
||||||
return PythonHttpClientCodeGen()
|
return PythonHttpClientCodeGen()
|
||||||
.getCode(rM, boundary: boundary ?? getNewUuid());
|
.getCode(rM, boundary: boundary ?? getNewUuid());
|
||||||
@ -67,12 +77,8 @@ class Codegen {
|
|||||||
return RustReqwestCodeGen().getCode(rM);
|
return RustReqwestCodeGen().getCode(rM);
|
||||||
case CodegenLanguage.rustUreq:
|
case CodegenLanguage.rustUreq:
|
||||||
return RustUreqCodeGen().getCode(rM, boundary: boundary);
|
return RustUreqCodeGen().getCode(rM, boundary: boundary);
|
||||||
case CodegenLanguage.goHttp:
|
case CodegenLanguage.phpGuzzle:
|
||||||
return GoHttpCodeGen().getCode(rM);
|
return PhpGuzzleCodeGen().getCode(rM);
|
||||||
case CodegenLanguage.juliaHttp:
|
|
||||||
return JuliaHttpClientCodeGen().getCode(rM);
|
|
||||||
case CodegenLanguage.javaAsyncHttpClient:
|
|
||||||
return JavaAsyncHttpClientGen().getCode(rM);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ func main() {
|
|||||||
|
|
||||||
var templateStart = jj.Template(kTemplateStart);
|
var templateStart = jj.Template(kTemplateStart);
|
||||||
result += templateStart.render({
|
result += templateStart.render({
|
||||||
"hasBody": requestModel.hasData,
|
"hasBody": requestModel.hasBody,
|
||||||
"hasFormData": requestModel.hasFormData,
|
"hasFormData": requestModel.hasFormData,
|
||||||
"hasFileInFormData": requestModel.hasFileInFormData,
|
"hasFileInFormData": requestModel.hasFileInFormData,
|
||||||
});
|
});
|
||||||
@ -144,7 +144,7 @@ func main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
var headersList = requestModel.enabledRequestHeaders;
|
var headersList = requestModel.enabledRequestHeaders;
|
||||||
if (headersList != null || requestModel.hasData) {
|
if (headersList != null || requestModel.hasBody) {
|
||||||
var headers = requestModel.enabledHeadersMap;
|
var headers = requestModel.enabledHeadersMap;
|
||||||
if (requestModel.hasJsonData || requestModel.hasTextData) {
|
if (requestModel.hasJsonData || requestModel.hasTextData) {
|
||||||
headers.putIfAbsent(kHeaderContentType,
|
headers.putIfAbsent(kHeaderContentType,
|
||||||
|
183
lib/codegen/java/httpclient.dart
Normal file
183
lib/codegen/java/httpclient.dart
Normal file
@ -0,0 +1,183 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
import 'package:jinja/jinja.dart' as jj;
|
||||||
|
import 'package:apidash/utils/utils.dart'
|
||||||
|
show getValidRequestUri, requestModelToHARJsonRequest, stripUriParams;
|
||||||
|
import '../../models/request_model.dart';
|
||||||
|
import 'package:apidash/consts.dart';
|
||||||
|
|
||||||
|
class JavaHttpClientCodeGen {
|
||||||
|
final String kTemplateStart = """
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.net.http.HttpClient;
|
||||||
|
import java.net.http.HttpRequest;
|
||||||
|
import java.net.http.HttpResponse;
|
||||||
|
import java.net.http.HttpHeaders;
|
||||||
|
import java.net.http.HttpRequest.BodyPublishers;
|
||||||
|
import java.net.http.HttpResponse.BodyHandlers;
|
||||||
|
|
||||||
|
public class JavaHttpClientExample {
|
||||||
|
|
||||||
|
public static void main(String[] args) throws IOException, InterruptedException {
|
||||||
|
HttpClient client = HttpClient.newHttpClient();
|
||||||
|
""";
|
||||||
|
final String kTemplateUrl = '''
|
||||||
|
|
||||||
|
String url = "{{url}}";
|
||||||
|
|
||||||
|
''';
|
||||||
|
|
||||||
|
final String kTemplateUrlQuery = '''
|
||||||
|
|
||||||
|
String url = "{{url}}";
|
||||||
|
try {
|
||||||
|
URI uri = new URI(url);
|
||||||
|
url = uri.resolve("{{params}}").toString();
|
||||||
|
} catch (URISyntaxException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
''';
|
||||||
|
|
||||||
|
String kTemplateRequestBody = '''
|
||||||
|
|
||||||
|
String body = "{{body}}";
|
||||||
|
|
||||||
|
''';
|
||||||
|
|
||||||
|
final String kStringRequestStart = """
|
||||||
|
|
||||||
|
HttpRequest request = HttpRequest.newBuilder()
|
||||||
|
.uri(URI.create(url))
|
||||||
|
""";
|
||||||
|
|
||||||
|
final String kTemplateRequestEnd = """
|
||||||
|
.{{method}}({{body}})
|
||||||
|
.build();
|
||||||
|
|
||||||
|
HttpResponse<String> response = client.send(request, BodyHandlers.ofString());
|
||||||
|
System.out.println(response.statusCode());
|
||||||
|
System.out.println(response.body());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
\n
|
||||||
|
""";
|
||||||
|
|
||||||
|
String? getCode(
|
||||||
|
RequestModel requestModel,
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
String result = "";
|
||||||
|
bool hasQuery = false;
|
||||||
|
bool hasBody = false;
|
||||||
|
bool hasJsonBody = false;
|
||||||
|
|
||||||
|
var rec = getValidRequestUri(
|
||||||
|
requestModel.url,
|
||||||
|
requestModel.enabledRequestParams,
|
||||||
|
);
|
||||||
|
Uri? uri = rec.$1;
|
||||||
|
|
||||||
|
if (uri != null) {
|
||||||
|
String url = stripUriParams(uri);
|
||||||
|
|
||||||
|
if (uri.hasQuery) {
|
||||||
|
var params = uri.queryParameters;
|
||||||
|
if (params.isNotEmpty) {
|
||||||
|
hasQuery = true;
|
||||||
|
var templateParams = jj.Template(kTemplateUrlQuery);
|
||||||
|
result += templateParams.render({"url": url, "params": uri.query});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hasQuery) {
|
||||||
|
var templateUrl = jj.Template(kTemplateUrl);
|
||||||
|
result += templateUrl.render({"url": url});
|
||||||
|
}
|
||||||
|
var rM = requestModel.copyWith(url: url);
|
||||||
|
|
||||||
|
var harJson = requestModelToHARJsonRequest(rM, useEnabled: true);
|
||||||
|
|
||||||
|
var method = requestModel.method;
|
||||||
|
var requestBody = requestModel.requestBody;
|
||||||
|
if (requestModel.hasFormData &&
|
||||||
|
requestModel.formDataMapList.isNotEmpty &&
|
||||||
|
kMethodsWithBody.contains(method)) {
|
||||||
|
var formDataList = requestModel.formDataMapList;
|
||||||
|
result += """
|
||||||
|
StringBuilder formData = new StringBuilder();
|
||||||
|
formData.append(""";
|
||||||
|
|
||||||
|
for (var formDataMap in formDataList) {
|
||||||
|
result += '"""${formDataMap['name']}=${formDataMap['value']}&""",';
|
||||||
|
}
|
||||||
|
|
||||||
|
result = result.substring(0, result.length - 1);
|
||||||
|
result += ");\n";
|
||||||
|
hasBody = true;
|
||||||
|
} else if (kMethodsWithBody.contains(method) && requestBody != null) {
|
||||||
|
var contentLength = utf8.encode(requestBody).length;
|
||||||
|
if (contentLength > 0) {
|
||||||
|
var templateBody = jj.Template(kTemplateRequestBody);
|
||||||
|
hasBody = true;
|
||||||
|
hasJsonBody =
|
||||||
|
requestBody.startsWith("{") && requestBody.endsWith("}");
|
||||||
|
if (harJson["postData"]?["text"] != null) {
|
||||||
|
result += templateBody.render({
|
||||||
|
"body": kEncoder.convert(harJson["postData"]["text"]).substring(
|
||||||
|
1, kEncoder.convert(harJson["postData"]["text"]).length - 1)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result = kTemplateStart + result;
|
||||||
|
result += kStringRequestStart;
|
||||||
|
|
||||||
|
var headersList = requestModel.enabledRequestHeaders;
|
||||||
|
var contentType = requestModel.requestBodyContentType.header;
|
||||||
|
if (hasBody &&
|
||||||
|
!requestModel.enabledHeadersMap.containsKey('Content-Type')) {
|
||||||
|
result =
|
||||||
|
"""$result .header("Content-Type", "$contentType")\n""";
|
||||||
|
}
|
||||||
|
if (headersList != null) {
|
||||||
|
var headers = requestModel.enabledHeadersMap;
|
||||||
|
if (headers.isNotEmpty) {
|
||||||
|
result += getHeaders(headers, hasJsonBody);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var templateRequestEnd = jj.Template(kTemplateRequestEnd);
|
||||||
|
|
||||||
|
if (kMethodsWithBody.contains(method)) {
|
||||||
|
result += templateRequestEnd.render({
|
||||||
|
"method": method.name.toUpperCase(),
|
||||||
|
"body": hasBody
|
||||||
|
? "BodyPublishers.ofString(body)"
|
||||||
|
: "BodyPublishers.noBody()"
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
result += templateRequestEnd
|
||||||
|
.render({"method": method.name.toUpperCase(), "body": ""});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
} catch (e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String getHeaders(Map<String, String> headers, hasJsonBody) {
|
||||||
|
String result = "";
|
||||||
|
for (final k in headers.keys) {
|
||||||
|
if (k.toLowerCase() == 'authorization') {
|
||||||
|
result = """$result .header("$k", "${headers[k]}")\n""";
|
||||||
|
} else {
|
||||||
|
result = """$result .header("$k", "${headers[k]}")\n""";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,3 @@
|
|||||||
import 'dart:convert';
|
|
||||||
import 'package:jinja/jinja.dart' as jj;
|
import 'package:jinja/jinja.dart' as jj;
|
||||||
import 'package:apidash/utils/utils.dart'
|
import 'package:apidash/utils/utils.dart'
|
||||||
show padMultilineString, requestModelToHARJsonRequest, stripUrlParams;
|
show padMultilineString, requestModelToHARJsonRequest, stripUrlParams;
|
||||||
@ -10,12 +9,14 @@ class AxiosCodeGen {
|
|||||||
|
|
||||||
final bool isNodeJs;
|
final bool isNodeJs;
|
||||||
|
|
||||||
String kStringImportNode = """{% if isNodeJs %}import axios from 'axios';
|
String kStringImportNode = """import axios from 'axios';
|
||||||
|
{%if hasFileInFormData -%}
|
||||||
|
import fs from 'fs'
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% endif %}{% if hasFormData and isNodeJs %}const fs = require('fs');{% endif %}
|
|
||||||
""";
|
""";
|
||||||
|
|
||||||
String kTemplateStart = """let config = {
|
String kTemplateStart = """const config = {
|
||||||
url: '{{url}}',
|
url: '{{url}}',
|
||||||
method: '{{method}}'
|
method: '{{method}}'
|
||||||
""";
|
""";
|
||||||
@ -37,59 +38,28 @@ class AxiosCodeGen {
|
|||||||
};
|
};
|
||||||
|
|
||||||
axios(config)
|
axios(config)
|
||||||
.then(function (response) {
|
.then(res => {
|
||||||
// handle success
|
console.log(res.status);
|
||||||
console.log(response.status);
|
console.log(res.data);
|
||||||
console.log(response.data);
|
})
|
||||||
})
|
.catch(err => {
|
||||||
.catch(function (error) {
|
console.log(err);
|
||||||
// handle error
|
});
|
||||||
console.log(error.response.status);
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
""";
|
""";
|
||||||
String kMultiPartBodyTemplate = r'''
|
|
||||||
|
|
||||||
|
|
||||||
async function buildFormData(fields) {
|
|
||||||
var formdata = new FormData();
|
|
||||||
for (const field of fields) {
|
|
||||||
const name = field.name || '';
|
|
||||||
const value = field.value || '';
|
|
||||||
const type = field.type || 'text';
|
|
||||||
|
|
||||||
if (type === 'text') {
|
|
||||||
formdata.append(name, value);
|
|
||||||
} else if (type === 'file') {
|
|
||||||
formdata.append(name,{% if isNodeJs %} fs.createReadStream(value){% else %} fileInput.files[0],value{% endif %});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return formdata;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
''';
|
|
||||||
var kGetFormDataTemplate = '''buildFormData({{fields_list}});
|
|
||||||
''';
|
|
||||||
String? getCode(
|
String? getCode(
|
||||||
RequestModel requestModel,
|
RequestModel requestModel,
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
jj.Template kNodejsImportTemplate = jj.Template(kStringImportNode);
|
jj.Template kNodejsImportTemplate = jj.Template(kStringImportNode);
|
||||||
String importsData = kNodejsImportTemplate.render({
|
String importsData = kNodejsImportTemplate.render({
|
||||||
"hasFormData": requestModel.hasFormData,
|
"hasFileInFormData": requestModel.hasFileInFormData,
|
||||||
"isNodeJs": isNodeJs,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
String result = importsData;
|
String result = isNodeJs
|
||||||
if (requestModel.hasFormData && requestModel.formDataMapList.isNotEmpty) {
|
? importsData
|
||||||
var templateMultiPartBody = jj.Template(kMultiPartBodyTemplate);
|
: requestModel.hasFileInFormData
|
||||||
var renderedMultiPartBody = templateMultiPartBody.render({
|
? "// refer https://github.com/foss42/apidash/issues/293#issuecomment-1997568083 for details regarding integration\n\n"
|
||||||
"isNodeJs": isNodeJs,
|
: "";
|
||||||
});
|
|
||||||
result += renderedMultiPartBody;
|
|
||||||
}
|
|
||||||
|
|
||||||
var harJson = requestModelToHARJsonRequest(
|
var harJson = requestModelToHARJsonRequest(
|
||||||
requestModel,
|
requestModel,
|
||||||
useEnabled: true,
|
useEnabled: true,
|
||||||
@ -126,17 +96,22 @@ async function buildFormData(fields) {
|
|||||||
.render({"headers": padMultilineString(kEncoder.convert(m), 2)});
|
.render({"headers": padMultilineString(kEncoder.convert(m), 2)});
|
||||||
}
|
}
|
||||||
var templateBody = jj.Template(kTemplateBody);
|
var templateBody = jj.Template(kTemplateBody);
|
||||||
|
|
||||||
if (requestModel.hasFormData && requestModel.formDataMapList.isNotEmpty) {
|
if (requestModel.hasFormData && requestModel.formDataMapList.isNotEmpty) {
|
||||||
var getFieldDataTemplate = jj.Template(kGetFormDataTemplate);
|
// Manually Create a JS Object
|
||||||
|
Map<String, String> formParams = {};
|
||||||
result += templateBody.render({
|
int formFileCounter = 1;
|
||||||
"body": getFieldDataTemplate.render({
|
for (var element in requestModel.formDataMapList) {
|
||||||
"fields_list": json.encode(requestModel.formDataMapList),
|
formParams["${element["name"]}"] = element["type"] == "text"
|
||||||
})
|
? "${element["value"]}"
|
||||||
});
|
: isNodeJs
|
||||||
}
|
? "fs.createReadStream(${element["value"]})"
|
||||||
if (harJson["postData"]?["text"] != null) {
|
: "fileInput$formFileCounter.files[0]";
|
||||||
|
if (element["type"] == "file") formFileCounter++;
|
||||||
|
}
|
||||||
|
var sanitizedJSObject = sanitzeJSObject(kEncoder.convert(formParams));
|
||||||
|
result += templateBody
|
||||||
|
.render({"body": padMultilineString(sanitizedJSObject, 2)});
|
||||||
|
} else if (harJson["postData"]?["text"] != null) {
|
||||||
result += templateBody
|
result += templateBody
|
||||||
.render({"body": kEncoder.convert(harJson["postData"]["text"])});
|
.render({"body": kEncoder.convert(harJson["postData"]["text"])});
|
||||||
}
|
}
|
||||||
@ -146,4 +121,18 @@ async function buildFormData(fields) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// escape function and variables in JS Object
|
||||||
|
String sanitzeJSObject(String jsObject) {
|
||||||
|
RegExp pattern = isNodeJs
|
||||||
|
? RegExp(r'"fs\.createReadStream\((.*?)\)"')
|
||||||
|
: RegExp(r'"fileInput(\d+)\.files\[0\]"');
|
||||||
|
|
||||||
|
var sanitizedJSObject = jsObject.replaceAllMapped(pattern, (match) {
|
||||||
|
return isNodeJs
|
||||||
|
? 'fs.createReadStream("${match.group(1)}")'
|
||||||
|
: 'fileInput${match.group(1)}.files[0]';
|
||||||
|
});
|
||||||
|
return sanitizedJSObject;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import 'package:apidash/consts.dart';
|
|||||||
|
|
||||||
class KotlinOkHttpCodeGen {
|
class KotlinOkHttpCodeGen {
|
||||||
final String kTemplateStart = """import okhttp3.OkHttpClient
|
final String kTemplateStart = """import okhttp3.OkHttpClient
|
||||||
import okhttp3.Request{{importForQuery}}{{importForBody}}{{importForFormData}}
|
import okhttp3.Request{{importForQuery}}{{importForBody}}{{importForFormData}}{{importForFile}}
|
||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
val client = OkHttpClient()
|
val client = OkHttpClient()
|
||||||
@ -27,6 +27,12 @@ import okhttp3.MediaType.Companion.toMediaType""";
|
|||||||
|
|
||||||
import okhttp3.MultipartBody""";
|
import okhttp3.MultipartBody""";
|
||||||
|
|
||||||
|
final String kStringImportForFile = """
|
||||||
|
|
||||||
|
import java.io.File
|
||||||
|
import okhttp3.RequestBody.Companion.asRequestBody
|
||||||
|
import okhttp3.MediaType.Companion.toMediaType""";
|
||||||
|
|
||||||
final String kTemplateUrl = '''
|
final String kTemplateUrl = '''
|
||||||
|
|
||||||
val url = "{{url}}"
|
val url = "{{url}}"
|
||||||
@ -68,7 +74,7 @@ import okhttp3.MultipartBody""";
|
|||||||
// Converting list of form data objects to kolin multi part data
|
// Converting list of form data objects to kolin multi part data
|
||||||
String kFormDataBody = '''
|
String kFormDataBody = '''
|
||||||
val body = MultipartBody.Builder().setType(MultipartBody.FORM){% for item in formDataList %}{% if item.type == 'file' %}
|
val body = MultipartBody.Builder().setType(MultipartBody.FORM){% for item in formDataList %}{% if item.type == 'file' %}
|
||||||
.addFormDataPart("{{item.name}}",null,File("{{item.value}}").asRequestBody("application/octet-stream".toMediaType()))
|
.addFormDataPart("{{item.name}}",File("{{item.value}}").name,File("{{item.value}}").asRequestBody("application/octet-stream".toMediaType()))
|
||||||
{% else %}.addFormDataPart("{{item.name}}","{{item.value}}")
|
{% else %}.addFormDataPart("{{item.name}}","{{item.value}}")
|
||||||
{% endif %}{% endfor %}.build()
|
{% endif %}{% endfor %}.build()
|
||||||
''';
|
''';
|
||||||
@ -81,6 +87,7 @@ import okhttp3.MultipartBody""";
|
|||||||
bool hasQuery = false;
|
bool hasQuery = false;
|
||||||
bool hasBody = false;
|
bool hasBody = false;
|
||||||
bool hasFormData = false;
|
bool hasFormData = false;
|
||||||
|
bool hasFile = false;
|
||||||
|
|
||||||
var rec = getValidRequestUri(
|
var rec = getValidRequestUri(
|
||||||
requestModel.url,
|
requestModel.url,
|
||||||
@ -111,8 +118,34 @@ import okhttp3.MultipartBody""";
|
|||||||
hasFormData = true;
|
hasFormData = true;
|
||||||
var formDataTemplate = jj.Template(kFormDataBody);
|
var formDataTemplate = jj.Template(kFormDataBody);
|
||||||
|
|
||||||
|
List<Map<String,String>> modifiedFormDataList = [];
|
||||||
|
for (var item in requestModel.formDataList) {
|
||||||
|
if (item.type == FormDataType.file ) {
|
||||||
|
if (item.value[0] == "/") {
|
||||||
|
modifiedFormDataList.add({
|
||||||
|
"name": item.name,
|
||||||
|
"value": item.value.substring(1),
|
||||||
|
"type": "file"
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
modifiedFormDataList.add({
|
||||||
|
"name": item.name,
|
||||||
|
"value": item.value,
|
||||||
|
"type": "file"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
hasFile = true;
|
||||||
|
}else{
|
||||||
|
modifiedFormDataList.add({
|
||||||
|
"name": item.name,
|
||||||
|
"value": item.value,
|
||||||
|
"type": "text"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
result += formDataTemplate.render({
|
result += formDataTemplate.render({
|
||||||
"formDataList": requestModel.formDataMapList,
|
"formDataList": modifiedFormDataList,
|
||||||
});
|
});
|
||||||
} else if (kMethodsWithBody.contains(method) && requestBody != null) {
|
} else if (kMethodsWithBody.contains(method) && requestBody != null) {
|
||||||
var contentLength = utf8.encode(requestBody).length;
|
var contentLength = utf8.encode(requestBody).length;
|
||||||
@ -129,7 +162,8 @@ import okhttp3.MultipartBody""";
|
|||||||
var stringStart = templateStart.render({
|
var stringStart = templateStart.render({
|
||||||
"importForQuery": hasQuery ? kStringImportForQuery : "",
|
"importForQuery": hasQuery ? kStringImportForQuery : "",
|
||||||
"importForBody": hasBody ? kStringImportForBody : "",
|
"importForBody": hasBody ? kStringImportForBody : "",
|
||||||
"importForFormData": hasFormData ? kStringImportForFormData : ""
|
"importForFormData": hasFormData ? kStringImportForFormData : "",
|
||||||
|
"importForFile": hasFile ? kStringImportForFile : "",
|
||||||
});
|
});
|
||||||
|
|
||||||
result = stringStart + result;
|
result = stringStart + result;
|
||||||
|
161
lib/codegen/php/guzzle.dart
Normal file
161
lib/codegen/php/guzzle.dart
Normal file
@ -0,0 +1,161 @@
|
|||||||
|
import 'package:jinja/jinja.dart' as jj;
|
||||||
|
import 'package:apidash/utils/utils.dart'
|
||||||
|
show requestModelToHARJsonRequest, stripUrlParams;
|
||||||
|
import 'package:apidash/models/models.dart' show RequestModel;
|
||||||
|
import 'package:apidash/consts.dart';
|
||||||
|
|
||||||
|
class PhpGuzzleCodeGen {
|
||||||
|
String kStringImportNode = """use GuzzleHttp\\Client;
|
||||||
|
use GuzzleHttp\\Psr7\\Request;
|
||||||
|
{% if hasFormData %}use GuzzleHttp\\Psr7\\MultipartStream;{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
""";
|
||||||
|
|
||||||
|
String kMultiPartBodyTemplate = """
|
||||||
|
\$multipart = [
|
||||||
|
{{fields_list}}
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
""";
|
||||||
|
|
||||||
|
String kTemplateParams = """
|
||||||
|
\$queryParams = [
|
||||||
|
{{params}}
|
||||||
|
];
|
||||||
|
\$queryParamsStr = '?' . http_build_query(\$queryParams);
|
||||||
|
|
||||||
|
|
||||||
|
""";
|
||||||
|
|
||||||
|
String kTemplateHeader = """
|
||||||
|
\$headers = [
|
||||||
|
{{headers}}
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
""";
|
||||||
|
|
||||||
|
String kTemplateBody = """
|
||||||
|
\$body = {{body}};
|
||||||
|
|
||||||
|
|
||||||
|
""";
|
||||||
|
|
||||||
|
String kStringRequest = """
|
||||||
|
\$client = new Client();
|
||||||
|
|
||||||
|
\$request = new Request('{{method}}', '{{url}}'{{queryParams}} {{headers}} {{body}});
|
||||||
|
\$res = \$client->sendAsync(\$request)->wait();
|
||||||
|
echo \$res->getBody();
|
||||||
|
""";
|
||||||
|
|
||||||
|
String? getCode(RequestModel requestModel) {
|
||||||
|
try {
|
||||||
|
jj.Template kNodejsImportTemplate = jj.Template(kStringImportNode);
|
||||||
|
String importsData = kNodejsImportTemplate.render({
|
||||||
|
"hasFormData": requestModel.hasFormData,
|
||||||
|
});
|
||||||
|
|
||||||
|
String result = importsData;
|
||||||
|
|
||||||
|
if (requestModel.hasFormData && requestModel.formDataMapList.isNotEmpty) {
|
||||||
|
var templateMultiPartBody = jj.Template(kMultiPartBodyTemplate);
|
||||||
|
var renderedMultiPartBody = templateMultiPartBody.render({
|
||||||
|
"fields_list": requestModel.formDataMapList.map((field) {
|
||||||
|
return '''
|
||||||
|
[
|
||||||
|
'name' => '${field['name']}',
|
||||||
|
'contents' => '${field['value']}'
|
||||||
|
],''';
|
||||||
|
}).join(),
|
||||||
|
});
|
||||||
|
result += renderedMultiPartBody;
|
||||||
|
}
|
||||||
|
|
||||||
|
var harJson =
|
||||||
|
requestModelToHARJsonRequest(requestModel, useEnabled: true);
|
||||||
|
|
||||||
|
var params = harJson["queryString"];
|
||||||
|
if (params.isNotEmpty) {
|
||||||
|
var templateParams = jj.Template(kTemplateParams);
|
||||||
|
var m = {};
|
||||||
|
for (var i in params) {
|
||||||
|
m[i["name"]] = i["value"];
|
||||||
|
}
|
||||||
|
var jsonString = '';
|
||||||
|
m.forEach((key, value) {
|
||||||
|
jsonString += "\t\t\t\t'$key' => '$value', \n";
|
||||||
|
});
|
||||||
|
jsonString = jsonString.substring(
|
||||||
|
0, jsonString.length - 2); // Removing trailing comma and space
|
||||||
|
result += templateParams.render({
|
||||||
|
"params": jsonString,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var headers = harJson["headers"];
|
||||||
|
if (headers.isNotEmpty || requestModel.hasFormData) {
|
||||||
|
var templateHeader = jj.Template(kTemplateHeader);
|
||||||
|
var m = {};
|
||||||
|
for (var i in headers) {
|
||||||
|
m[i["name"]] = i["value"];
|
||||||
|
}
|
||||||
|
var headersString = '';
|
||||||
|
m.forEach((key, value) {
|
||||||
|
headersString += "\t\t\t\t'$key' => '$value', \n";
|
||||||
|
});
|
||||||
|
if (requestModel.hasFormData) {
|
||||||
|
m['Content-Type'] = 'multipart/form-data';
|
||||||
|
}
|
||||||
|
headersString = headersString.substring(
|
||||||
|
0, headersString.length - 2); // Removing trailing comma and space
|
||||||
|
result += templateHeader.render({
|
||||||
|
"headers": headersString,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var templateBody = jj.Template(kTemplateBody);
|
||||||
|
if (requestModel.hasFormData && requestModel.formDataMapList.isNotEmpty) {
|
||||||
|
result += templateBody.render({
|
||||||
|
"body": "new MultipartStream(\$multipart)",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (harJson["postData"]?["text"] != null) {
|
||||||
|
result += templateBody
|
||||||
|
.render({"body": kEncoder.convert(harJson["postData"]["text"])});
|
||||||
|
}
|
||||||
|
|
||||||
|
String getRequestBody(Map harJson) {
|
||||||
|
if (harJson.containsKey("postData")) {
|
||||||
|
var postData = harJson["postData"];
|
||||||
|
if (postData.containsKey("mimeType")) {
|
||||||
|
var mimeType = postData["mimeType"];
|
||||||
|
if (mimeType == "text/plain" || mimeType == "application/json") {
|
||||||
|
return " \$body";
|
||||||
|
} else if (mimeType == "multipart/form-data") {
|
||||||
|
return " new MultipartStream(\$multipart)";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""; // Return empty string if postData or formdata is not present
|
||||||
|
}
|
||||||
|
|
||||||
|
var templateRequest = jj.Template(kStringRequest);
|
||||||
|
result += templateRequest.render({
|
||||||
|
"url": stripUrlParams(requestModel.url),
|
||||||
|
"method": harJson["method"].toLowerCase(),
|
||||||
|
"queryParams":
|
||||||
|
harJson["queryString"].isNotEmpty ? ". \$queryParamsStr," : "",
|
||||||
|
"headers": harJson["headers"].isNotEmpty ? " \$headers," : "",
|
||||||
|
"body": getRequestBody(harJson),
|
||||||
|
});
|
||||||
|
|
||||||
|
return result;
|
||||||
|
} catch (e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -116,7 +116,7 @@ body = b'\r\n'.join(dataList)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (requestModel.hasData) {
|
if (requestModel.hasBody) {
|
||||||
hasBody = true;
|
hasBody = true;
|
||||||
if (requestModel.hasJsonData || requestModel.hasTextData) {
|
if (requestModel.hasJsonData || requestModel.hasTextData) {
|
||||||
var templateBody = jj.Template(kTemplateBody);
|
var templateBody = jj.Template(kTemplateBody);
|
||||||
|
@ -265,14 +265,16 @@ enum CodegenLanguage {
|
|||||||
nodejsAxios("node.js (axios)", "javascript", "js"),
|
nodejsAxios("node.js (axios)", "javascript", "js"),
|
||||||
nodejsFetch("node.js (fetch)", "javascript", "js"),
|
nodejsFetch("node.js (fetch)", "javascript", "js"),
|
||||||
kotlinOkHttp("Kotlin (okhttp3)", "java", "kt"),
|
kotlinOkHttp("Kotlin (okhttp3)", "java", "kt"),
|
||||||
pythonHttpClient("Python (http.client)", "python", "py"),
|
|
||||||
pythonRequests("Python (requests)", "python", "py"),
|
pythonRequests("Python (requests)", "python", "py"),
|
||||||
|
pythonHttpClient("Python (http.client)", "python", "py"),
|
||||||
rustActix("Rust (Actix Client)", "rust", "rs"),
|
rustActix("Rust (Actix Client)", "rust", "rs"),
|
||||||
rustReqwest("Rust (reqwest)", "rust", "rs"),
|
rustReqwest("Rust (reqwest)", "rust", "rs"),
|
||||||
rustUreq("Rust (ureq)", "rust", "rs"),
|
rustUreq("Rust (ureq)", "rust", "rs"),
|
||||||
javaOkHttp("Java (okhttp3)", "java", 'java'),
|
javaOkHttp("Java (okhttp3)", "java", 'java'),
|
||||||
javaAsyncHttpClient("Java (async-http-client)", "java", "java"),
|
javaAsyncHttpClient("Java (asynchttpclient)", "java", "java"),
|
||||||
juliaHttp("Julia (HTTP)", "julia", "jl");
|
javaHttpClient("Java (HttpClient)", "java", "java"),
|
||||||
|
juliaHttp("Julia (HTTP)", "julia", "jl"),
|
||||||
|
phpGuzzle("PHP (guzzle)", "php", "php");
|
||||||
|
|
||||||
const CodegenLanguage(this.label, this.codeHighlightLang, this.ext);
|
const CodegenLanguage(this.label, this.codeHighlightLang, this.ext);
|
||||||
final String label;
|
final String label;
|
||||||
|
@ -68,7 +68,7 @@ class RequestModel {
|
|||||||
bool get hasJsonContentType => requestBodyContentType == ContentType.json;
|
bool get hasJsonContentType => requestBodyContentType == ContentType.json;
|
||||||
bool get hasTextContentType => requestBodyContentType == ContentType.text;
|
bool get hasTextContentType => requestBodyContentType == ContentType.text;
|
||||||
int get contentLength => utf8.encode(requestBody ?? "").length;
|
int get contentLength => utf8.encode(requestBody ?? "").length;
|
||||||
bool get hasData => hasJsonData || hasTextData || hasFormData;
|
bool get hasBody => hasJsonData || hasTextData || hasFormData;
|
||||||
bool get hasJsonData =>
|
bool get hasJsonData =>
|
||||||
kMethodsWithBody.contains(method) &&
|
kMethodsWithBody.contains(method) &&
|
||||||
hasJsonContentType &&
|
hasJsonContentType &&
|
||||||
|
@ -17,11 +17,14 @@ class EditRequestPane extends ConsumerWidget {
|
|||||||
selectedRequestModelProvider.select((value) => value?.requestTabIndex));
|
selectedRequestModelProvider.select((value) => value?.requestTabIndex));
|
||||||
|
|
||||||
final headerLength = ref.watch(selectedRequestModelProvider
|
final headerLength = ref.watch(selectedRequestModelProvider
|
||||||
.select((value) => value?.headersMap.length));
|
.select((value) => value?.headersMap.length)) ??
|
||||||
|
0;
|
||||||
final paramLength = ref.watch(selectedRequestModelProvider
|
final paramLength = ref.watch(selectedRequestModelProvider
|
||||||
.select((value) => value?.paramsMap.length));
|
.select((value) => value?.paramsMap.length)) ??
|
||||||
final bodyLength = ref.watch(selectedRequestModelProvider
|
0;
|
||||||
.select((value) => value?.requestBody?.length));
|
final hasBody = ref.watch(
|
||||||
|
selectedRequestModelProvider.select((value) => value?.hasBody)) ??
|
||||||
|
false;
|
||||||
|
|
||||||
return RequestPane(
|
return RequestPane(
|
||||||
selectedId: selectedId,
|
selectedId: selectedId,
|
||||||
@ -37,9 +40,9 @@ class EditRequestPane extends ConsumerWidget {
|
|||||||
.update(selectedId!, requestTabIndex: index);
|
.update(selectedId!, requestTabIndex: index);
|
||||||
},
|
},
|
||||||
showIndicators: [
|
showIndicators: [
|
||||||
paramLength != null && paramLength > 0,
|
paramLength > 0,
|
||||||
headerLength != null && headerLength > 0,
|
headerLength > 0,
|
||||||
bodyLength != null && bodyLength > 0,
|
hasBody,
|
||||||
],
|
],
|
||||||
children: const [
|
children: const [
|
||||||
EditRequestURLParams(),
|
EditRequestURLParams(),
|
||||||
|
122
pubspec.lock
122
pubspec.lock
@ -109,10 +109,10 @@ packages:
|
|||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description:
|
description:
|
||||||
name: build_runner
|
name: build_runner
|
||||||
sha256: "67d591d602906ef9201caf93452495ad1812bea2074f04e25dbd7c133785821b"
|
sha256: "581bacf68f89ec8792f5e5a0b2c4decd1c948e97ce659dc783688c8a88fbec21"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.4.7"
|
version: "2.4.8"
|
||||||
build_runner_core:
|
build_runner_core:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -173,10 +173,10 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: code_builder
|
name: code_builder
|
||||||
sha256: feee43a5c05e7b3199bb375a86430b8ada1b04104f2923d0e03cc01ca87b6d84
|
sha256: f692079e25e7869c14132d39f223f8eec9830eb76131925143b2129c4bb01b37
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.9.0"
|
version: "4.10.0"
|
||||||
collection:
|
collection:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -213,18 +213,18 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: csv
|
name: csv
|
||||||
sha256: "63ed2871dd6471193dffc52c0e6c76fb86269c00244d244297abbb355c84a86e"
|
sha256: c6aa2679b2a18cb57652920f674488d89712efaf4d3fdf2e537215b35fc19d6c
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "5.1.1"
|
version: "6.0.0"
|
||||||
dart_style:
|
dart_style:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: dart_style
|
name: dart_style
|
||||||
sha256: "40ae61a5d43feea6d24bd22c0537a6629db858963b99b4bc1c3db80676f32368"
|
sha256: "99e066ce75c89d6b29903d788a7bb9369cf754f7b24bf70bf4b6d6d6b26853b9"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.3.4"
|
version: "2.3.6"
|
||||||
data_table_2:
|
data_table_2:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -285,10 +285,10 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: file_picker
|
name: file_picker
|
||||||
sha256: "4e42aacde3b993c5947467ab640882c56947d9d27342a5b6f2895b23956954a6"
|
sha256: caa6bc229eab3e32eb2f37b53a5f9d22a6981474afd210c512a7546c1e1a04f6
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.1.1"
|
version: "6.2.0"
|
||||||
fixnum:
|
fixnum:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -370,10 +370,10 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: flutter_markdown
|
name: flutter_markdown
|
||||||
sha256: "35108526a233cc0755664d445f8a6b4b61e6f8fe993b3658b80b4a26827fc196"
|
sha256: cb44f7831b23a6bdd0f501718b0d2e8045cbc625a15f668af37ddb80314821db
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.6.18+2"
|
version: "0.6.21"
|
||||||
flutter_plugin_android_lifecycle:
|
flutter_plugin_android_lifecycle:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -386,18 +386,18 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: flutter_riverpod
|
name: flutter_riverpod
|
||||||
sha256: da9591d1f8d5881628ccd5c25c40e74fc3eef50ba45e40c3905a06e1712412d5
|
sha256: "0f1974eff5bbe774bf1d870e406fc6f29e3d6f1c46bd9c58e7172ff68a785d7d"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.4.9"
|
version: "2.5.1"
|
||||||
flutter_svg:
|
flutter_svg:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: flutter_svg
|
name: flutter_svg
|
||||||
sha256: d39e7f95621fc84376bc0f7d504f05c3a41488c562f4a8ad410569127507402c
|
sha256: "7b4ca6cf3304575fe9c8ec64813c8d02ee41d2afe60bcfe0678bcb5375d596a2"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.9"
|
version: "2.0.10+1"
|
||||||
flutter_test:
|
flutter_test:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description: flutter
|
description: flutter
|
||||||
@ -420,10 +420,10 @@ packages:
|
|||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description:
|
description:
|
||||||
name: freezed
|
name: freezed
|
||||||
sha256: "6c5031daae12c7072b3a87eff98983076434b4889ef2a44384d0cae3f82372ba"
|
sha256: "57247f692f35f068cae297549a46a9a097100685c6780fe67177503eea5ed4e5"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.4.6"
|
version: "2.4.7"
|
||||||
freezed_annotation:
|
freezed_annotation:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -452,10 +452,10 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: google_fonts
|
name: google_fonts
|
||||||
sha256: f0b8d115a13ecf827013ec9fc883390ccc0e87a96ed5347a3114cac177ef18e8
|
sha256: b1ac0fe2832c9cc95e5e88b57d627c5e68c223b9657f4b96e1487aa9098c7b82
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.1.0"
|
version: "6.2.1"
|
||||||
graphs:
|
graphs:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -564,8 +564,8 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
path: "."
|
path: "."
|
||||||
ref: "9fa58d7b51e65174ab11cbcae17bba88a4194dde"
|
ref: b7dde2f85dff4f482eed7eda4ef2a71344ef8b3a
|
||||||
resolved-ref: "9fa58d7b51e65174ab11cbcae17bba88a4194dde"
|
resolved-ref: b7dde2f85dff4f482eed7eda4ef2a71344ef8b3a
|
||||||
url: "https://github.com/foss42/json_data_explorer.git"
|
url: "https://github.com/foss42/json_data_explorer.git"
|
||||||
source: git
|
source: git
|
||||||
version: "0.1.2"
|
version: "0.1.2"
|
||||||
@ -669,18 +669,18 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: lottie
|
name: lottie
|
||||||
sha256: a93542cc2d60a7057255405f62252533f8e8956e7e06754955669fd32fb4b216
|
sha256: ce2bb2605753915080e4ee47f036a64228c88dc7f56f7bc1dbe912d75b55b1e2
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.7.0"
|
version: "3.1.0"
|
||||||
markdown:
|
markdown:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: markdown
|
name: markdown
|
||||||
sha256: acf35edccc0463a9d7384e437c015a3535772e09714cf60e07eeef3a15870dcd
|
sha256: ef2a1298144e3f985cc736b22e0ccdaf188b5b3970648f2d9dc13efd1d9df051
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "7.1.1"
|
version: "7.2.2"
|
||||||
matcher:
|
matcher:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -765,10 +765,10 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: package_info_plus
|
name: package_info_plus
|
||||||
sha256: "7e76fad405b3e4016cd39d08f455a4eb5199723cf594cd1b8916d47140d93017"
|
sha256: "88bc797f44a94814f2213db1c9bd5badebafdfb8290ca9f78d4b9ee2a3db4d79"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.2.0"
|
version: "5.0.1"
|
||||||
package_info_plus_platform_interface:
|
package_info_plus_platform_interface:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -797,10 +797,10 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: path_provider
|
name: path_provider
|
||||||
sha256: a1aa8aaa2542a6bc57e381f132af822420216c80d4781f7aa085ca3229208aaa
|
sha256: b27217933eeeba8ff24845c34003b003b2b22151de3c908d0e679e8fe1aa078b
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.1"
|
version: "2.1.2"
|
||||||
path_provider_android:
|
path_provider_android:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -849,6 +849,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.10.7"
|
version: "3.10.7"
|
||||||
|
pdf_widget_wrapper:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: pdf_widget_wrapper
|
||||||
|
sha256: "9c3ca36e5000c9682d52bbdc486867ba7c5ee4403d1a5d6d03ed72157753377b"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.3"
|
||||||
petitparser:
|
petitparser:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -901,10 +909,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: pointer_interceptor_web
|
name: pointer_interceptor_web
|
||||||
sha256: a6237528b46c411d8d55cdfad8fcb3269fc4cbb26060b14bff94879165887d1e
|
sha256: "9386e064097fd16419e935c23f08f35b58e6aaec155dd39bd6a003b88f9c14b4"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.10.2"
|
version: "0.10.1+2"
|
||||||
pointycastle:
|
pointycastle:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -925,18 +933,18 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: printing
|
name: printing
|
||||||
sha256: ad39a42a5f83125952457dfd94f395c8cf0eb1f7759583dadb769be5c7f99d24
|
sha256: "1c99cab90ebcc1fff65831d264627d5b529359d563e53f33ab9b8117f2d280bc"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "5.11.1"
|
version: "5.12.0"
|
||||||
provider:
|
provider:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: provider
|
name: provider
|
||||||
sha256: "9a96a0a19b594dbc5bf0f1f27d2bc67d5f95957359b461cd9feb44ed6ae75096"
|
sha256: c8a055ee5ce3fd98d6fc872478b03823ffdb448699c6ebdbbc71d59b596fd48c
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.1.1"
|
version: "6.1.2"
|
||||||
pub_semver:
|
pub_semver:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -962,13 +970,13 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "3.0.1"
|
version: "3.0.1"
|
||||||
riverpod:
|
riverpod:
|
||||||
dependency: transitive
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: riverpod
|
name: riverpod
|
||||||
sha256: "942999ee48b899f8a46a860f1e13cee36f2f77609eb54c5b7a669bb20d550b11"
|
sha256: f21b32ffd26a36555e501b04f4a5dca43ed59e16343f1a30c13632b2351dfa4d
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.4.9"
|
version: "2.5.1"
|
||||||
rxdart:
|
rxdart:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -989,10 +997,10 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: scrollable_positioned_list
|
name: scrollable_positioned_list
|
||||||
sha256: "9566352ab9ba05794ee6c8864f154afba5d36c5637d0e3e32c615ba4ceb92772"
|
sha256: "1b54d5f1329a1e263269abc9e2543d90806131aa14fe7c6062a8054d57249287"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.2.3"
|
version: "0.3.8"
|
||||||
shelf:
|
shelf:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -1178,10 +1186,10 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: url_launcher
|
name: url_launcher
|
||||||
sha256: e9aa5ea75c84cf46b3db4eea212523591211c3cf2e13099ee4ec147f54201c86
|
sha256: "0ecc004c62fd3ed36a2ffcbe0dd9700aee63bd7532d0b642a488b1ec310f492e"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.2.2"
|
version: "6.2.5"
|
||||||
url_launcher_android:
|
url_launcher_android:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -1226,10 +1234,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: url_launcher_web
|
name: url_launcher_web
|
||||||
sha256: "3692a459204a33e04bc94f5fb91158faf4f2c8903281ddd82915adecdb1a901d"
|
sha256: fff0932192afeedf63cdd50ecbb1bc825d31aed259f02bb8dba0f3b729a5e88b
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.3.0"
|
version: "2.2.3"
|
||||||
url_launcher_windows:
|
url_launcher_windows:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -1242,34 +1250,34 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: uuid
|
name: uuid
|
||||||
sha256: "22c94e5ad1e75f9934b766b53c742572ee2677c56bc871d850a57dad0f82127f"
|
sha256: cd210a09f7c18cbe5a02511718e0334de6559871052c90a90c0cca46a4aa81c8
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.2.2"
|
version: "4.3.3"
|
||||||
vector_graphics:
|
vector_graphics:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: vector_graphics
|
name: vector_graphics
|
||||||
sha256: "0f0c746dd2d6254a0057218ff980fc7f5670fd0fcf5e4db38a490d31eed4ad43"
|
sha256: "32c3c684e02f9bc0afb0ae0aa653337a2fe022e8ab064bcd7ffda27a74e288e3"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.9+1"
|
version: "1.1.11+1"
|
||||||
vector_graphics_codec:
|
vector_graphics_codec:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: vector_graphics_codec
|
name: vector_graphics_codec
|
||||||
sha256: "0edf6d630d1bfd5589114138ed8fada3234deacc37966bec033d3047c29248b7"
|
sha256: c86987475f162fadff579e7320c7ddda04cd2fdeffbe1129227a85d9ac9e03da
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.9+1"
|
version: "1.1.11+1"
|
||||||
vector_graphics_compiler:
|
vector_graphics_compiler:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: vector_graphics_compiler
|
name: vector_graphics_compiler
|
||||||
sha256: d24333727332d9bd20990f1483af4e09abdb9b1fc7c3db940b56ab5c42790c26
|
sha256: "12faff3f73b1741a36ca7e31b292ddeb629af819ca9efe9953b70bd63fc8cd81"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.9+1"
|
version: "1.1.11+1"
|
||||||
vector_math:
|
vector_math:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -1295,7 +1303,7 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.0"
|
version: "1.1.0"
|
||||||
web:
|
web:
|
||||||
dependency: "direct main"
|
dependency: "direct overridden"
|
||||||
description:
|
description:
|
||||||
name: web
|
name: web
|
||||||
sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27"
|
sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27"
|
||||||
@ -1330,10 +1338,10 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: window_manager
|
name: window_manager
|
||||||
sha256: dcc865277f26a7dad263a47d0e405d77e21f12cb71f30333a52710a408690bd7
|
sha256: b3c895bdf936c77b83c5254bec2e6b3f066710c1f89c38b20b8acc382b525494
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.3.7"
|
version: "0.3.8"
|
||||||
window_size:
|
window_size:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -1369,4 +1377,4 @@ packages:
|
|||||||
version: "3.1.2"
|
version: "3.1.2"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=3.3.0 <4.0.0"
|
dart: ">=3.3.0 <4.0.0"
|
||||||
flutter: ">=3.19.0"
|
flutter: ">=3.19.2"
|
||||||
|
57
pubspec.yaml
57
pubspec.yaml
@ -1,24 +1,24 @@
|
|||||||
name: apidash
|
name: apidash
|
||||||
description: API Dash is a beautiful open-source cross-platform API Client built using Flutter which can help you easily create & customize your API requests, visually inspect responses and generate Dart code on the go.
|
description: API Dash is a beautiful open-source cross-platform API Client built using Flutter which can help you easily create & customize your API requests, visually inspect responses and generate Dart code on the go.
|
||||||
publish_to: "none"
|
publish_to: "none"
|
||||||
version: 0.3.0+3
|
version: 0.4.0+4
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=3.0.0 <4.0.0"
|
sdk: ">=3.0.0 <4.0.0"
|
||||||
flutter: ">=3.16.0"
|
flutter: ">=3.19.0"
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
web: ^0.5.0
|
|
||||||
multi_split_view: ^2.4.0
|
multi_split_view: ^2.4.0
|
||||||
url_launcher: ^6.1.12
|
url_launcher: ^6.2.5
|
||||||
flutter_riverpod: ^2.3.7
|
flutter_riverpod: ^2.5.1
|
||||||
uuid: ^4.1.0
|
riverpod: ^2.5.1
|
||||||
http: ^1.1.0
|
uuid: ^4.3.3
|
||||||
|
http: ^1.2.1
|
||||||
http_parser: ^4.0.2
|
http_parser: ^4.0.2
|
||||||
collection: ^1.17.2
|
collection: ^1.17.2
|
||||||
google_fonts: ^6.1.0
|
google_fonts: ^6.2.1
|
||||||
highlighter: ^0.1.1
|
highlighter: ^0.1.1
|
||||||
xml: ^6.3.0
|
xml: ^6.3.0
|
||||||
jinja: ^0.5.0
|
jinja: ^0.5.0
|
||||||
@ -27,44 +27,47 @@ 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
|
||||||
hive_flutter: ^1.1.0
|
hive_flutter: ^1.1.0
|
||||||
lottie: ^2.6.0
|
lottie: ^3.1.0
|
||||||
mime_dart: ^3.0.0
|
mime_dart: ^3.0.0
|
||||||
path_provider: ^2.1.0
|
path_provider: ^2.1.2
|
||||||
window_manager: ^0.3.5
|
window_manager: ^0.3.8
|
||||||
path: ^1.8.3
|
path: ^1.8.3
|
||||||
flutter_markdown: ^0.6.17+1
|
flutter_markdown: ^0.6.21
|
||||||
markdown: ^7.1.1
|
markdown: ^7.2.2
|
||||||
just_audio: ^0.9.34
|
just_audio: ^0.9.34
|
||||||
just_audio_mpv: ^0.1.7
|
just_audio_mpv: ^0.1.7
|
||||||
just_audio_windows: ^0.2.0
|
just_audio_windows: ^0.2.0
|
||||||
freezed_annotation: ^2.4.1
|
freezed_annotation: ^2.4.1
|
||||||
json_annotation: ^4.8.1
|
json_annotation: ^4.8.1
|
||||||
printing: ^5.11.1
|
printing: ^5.12.0
|
||||||
package_info_plus: ^4.1.0
|
package_info_plus: ^5.0.1
|
||||||
flutter_typeahead: ^5.2.0
|
flutter_typeahead: ^5.2.0
|
||||||
provider: ^6.0.5
|
provider: ^6.1.2
|
||||||
json_data_explorer:
|
json_data_explorer:
|
||||||
git:
|
git:
|
||||||
url: https://github.com/foss42/json_data_explorer.git
|
url: https://github.com/foss42/json_data_explorer.git
|
||||||
ref: 9fa58d7b51e65174ab11cbcae17bba88a4194dde
|
ref: b7dde2f85dff4f482eed7eda4ef2a71344ef8b3a
|
||||||
scrollable_positioned_list: ^0.2.3
|
scrollable_positioned_list: ^0.3.8
|
||||||
file_picker: ^6.1.1
|
file_picker: ^6.2.0
|
||||||
flutter_svg: ^2.0.9
|
flutter_svg: ^2.0.10+1
|
||||||
vector_graphics_compiler: ^1.1.9+1
|
vector_graphics_compiler: ^1.1.9+1
|
||||||
code_builder: ^4.9.0
|
code_builder: ^4.10.0
|
||||||
dart_style: ^2.3.4
|
dart_style: ^2.3.6
|
||||||
json_text_field: ^1.1.0
|
json_text_field: ^1.1.0
|
||||||
csv: ^5.1.1
|
csv: ^6.0.0
|
||||||
data_table_2: ^2.5.11
|
data_table_2: ^2.5.11
|
||||||
|
|
||||||
|
dependency_overrides:
|
||||||
|
web: ^0.5.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
flutter_lints: ^3.0.0
|
flutter_lints: ^3.0.1
|
||||||
flutter_launcher_icons: ^0.13.1
|
flutter_launcher_icons: ^0.13.1
|
||||||
test: ^1.24.3
|
test: ^1.24.9
|
||||||
build_runner: ^2.4.6
|
build_runner: ^2.4.8
|
||||||
freezed: ^2.4.1
|
freezed: ^2.4.7
|
||||||
json_serializable: ^6.7.1
|
json_serializable: ^6.7.1
|
||||||
|
|
||||||
flutter:
|
flutter:
|
||||||
|
@ -8,22 +8,19 @@ void main() {
|
|||||||
|
|
||||||
group('GET Request', () {
|
group('GET Request', () {
|
||||||
test('GET 1', () {
|
test('GET 1', () {
|
||||||
const expectedCode = r"""let config = {
|
const expectedCode = r"""const config = {
|
||||||
url: 'https://api.apidash.dev',
|
url: 'https://api.apidash.dev',
|
||||||
method: 'get'
|
method: 'get'
|
||||||
};
|
};
|
||||||
|
|
||||||
axios(config)
|
axios(config)
|
||||||
.then(function (response) {
|
.then(res => {
|
||||||
// handle success
|
console.log(res.status);
|
||||||
console.log(response.status);
|
console.log(res.data);
|
||||||
console.log(response.data);
|
})
|
||||||
})
|
.catch(err => {
|
||||||
.catch(function (error) {
|
console.log(err);
|
||||||
// handle error
|
});
|
||||||
console.log(error.response.status);
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
""";
|
""";
|
||||||
expect(
|
expect(
|
||||||
codeGen.getCode(CodegenLanguage.jsAxios, requestModelGet1, "https"),
|
codeGen.getCode(CodegenLanguage.jsAxios, requestModelGet1, "https"),
|
||||||
@ -31,7 +28,7 @@ axios(config)
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('GET 2', () {
|
test('GET 2', () {
|
||||||
const expectedCode = r"""let config = {
|
const expectedCode = r"""const config = {
|
||||||
url: 'https://api.apidash.dev/country/data',
|
url: 'https://api.apidash.dev/country/data',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: {
|
params: {
|
||||||
@ -40,16 +37,13 @@ axios(config)
|
|||||||
};
|
};
|
||||||
|
|
||||||
axios(config)
|
axios(config)
|
||||||
.then(function (response) {
|
.then(res => {
|
||||||
// handle success
|
console.log(res.status);
|
||||||
console.log(response.status);
|
console.log(res.data);
|
||||||
console.log(response.data);
|
})
|
||||||
})
|
.catch(err => {
|
||||||
.catch(function (error) {
|
console.log(err);
|
||||||
// handle error
|
});
|
||||||
console.log(error.response.status);
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
""";
|
""";
|
||||||
expect(
|
expect(
|
||||||
codeGen.getCode(CodegenLanguage.jsAxios, requestModelGet2, "https"),
|
codeGen.getCode(CodegenLanguage.jsAxios, requestModelGet2, "https"),
|
||||||
@ -57,7 +51,7 @@ axios(config)
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('GET 3', () {
|
test('GET 3', () {
|
||||||
const expectedCode = r"""let config = {
|
const expectedCode = r"""const config = {
|
||||||
url: 'https://api.apidash.dev/country/data',
|
url: 'https://api.apidash.dev/country/data',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: {
|
params: {
|
||||||
@ -66,16 +60,13 @@ axios(config)
|
|||||||
};
|
};
|
||||||
|
|
||||||
axios(config)
|
axios(config)
|
||||||
.then(function (response) {
|
.then(res => {
|
||||||
// handle success
|
console.log(res.status);
|
||||||
console.log(response.status);
|
console.log(res.data);
|
||||||
console.log(response.data);
|
})
|
||||||
})
|
.catch(err => {
|
||||||
.catch(function (error) {
|
console.log(err);
|
||||||
// handle error
|
});
|
||||||
console.log(error.response.status);
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
""";
|
""";
|
||||||
expect(
|
expect(
|
||||||
codeGen.getCode(CodegenLanguage.jsAxios, requestModelGet3, "https"),
|
codeGen.getCode(CodegenLanguage.jsAxios, requestModelGet3, "https"),
|
||||||
@ -83,7 +74,7 @@ axios(config)
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('GET 4', () {
|
test('GET 4', () {
|
||||||
const expectedCode = r"""let config = {
|
const expectedCode = r"""const config = {
|
||||||
url: 'https://api.apidash.dev/humanize/social',
|
url: 'https://api.apidash.dev/humanize/social',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: {
|
params: {
|
||||||
@ -96,16 +87,13 @@ axios(config)
|
|||||||
};
|
};
|
||||||
|
|
||||||
axios(config)
|
axios(config)
|
||||||
.then(function (response) {
|
.then(res => {
|
||||||
// handle success
|
console.log(res.status);
|
||||||
console.log(response.status);
|
console.log(res.data);
|
||||||
console.log(response.data);
|
})
|
||||||
})
|
.catch(err => {
|
||||||
.catch(function (error) {
|
console.log(err);
|
||||||
// handle error
|
});
|
||||||
console.log(error.response.status);
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
""";
|
""";
|
||||||
expect(
|
expect(
|
||||||
codeGen.getCode(CodegenLanguage.jsAxios, requestModelGet4, "https"),
|
codeGen.getCode(CodegenLanguage.jsAxios, requestModelGet4, "https"),
|
||||||
@ -113,7 +101,7 @@ axios(config)
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('GET 5', () {
|
test('GET 5', () {
|
||||||
const expectedCode = r"""let config = {
|
const expectedCode = r"""const config = {
|
||||||
url: 'https://api.github.com/repos/foss42/apidash',
|
url: 'https://api.github.com/repos/foss42/apidash',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
headers: {
|
headers: {
|
||||||
@ -122,16 +110,13 @@ axios(config)
|
|||||||
};
|
};
|
||||||
|
|
||||||
axios(config)
|
axios(config)
|
||||||
.then(function (response) {
|
.then(res => {
|
||||||
// handle success
|
console.log(res.status);
|
||||||
console.log(response.status);
|
console.log(res.data);
|
||||||
console.log(response.data);
|
})
|
||||||
})
|
.catch(err => {
|
||||||
.catch(function (error) {
|
console.log(err);
|
||||||
// handle error
|
});
|
||||||
console.log(error.response.status);
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
""";
|
""";
|
||||||
expect(
|
expect(
|
||||||
codeGen.getCode(CodegenLanguage.jsAxios, requestModelGet5, "https"),
|
codeGen.getCode(CodegenLanguage.jsAxios, requestModelGet5, "https"),
|
||||||
@ -139,7 +124,7 @@ axios(config)
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('GET 6', () {
|
test('GET 6', () {
|
||||||
const expectedCode = r"""let config = {
|
const expectedCode = r"""const config = {
|
||||||
url: 'https://api.github.com/repos/foss42/apidash',
|
url: 'https://api.github.com/repos/foss42/apidash',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: {
|
params: {
|
||||||
@ -151,16 +136,13 @@ axios(config)
|
|||||||
};
|
};
|
||||||
|
|
||||||
axios(config)
|
axios(config)
|
||||||
.then(function (response) {
|
.then(res => {
|
||||||
// handle success
|
console.log(res.status);
|
||||||
console.log(response.status);
|
console.log(res.data);
|
||||||
console.log(response.data);
|
})
|
||||||
})
|
.catch(err => {
|
||||||
.catch(function (error) {
|
console.log(err);
|
||||||
// handle error
|
});
|
||||||
console.log(error.response.status);
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
""";
|
""";
|
||||||
expect(
|
expect(
|
||||||
codeGen.getCode(CodegenLanguage.jsAxios, requestModelGet6, "https"),
|
codeGen.getCode(CodegenLanguage.jsAxios, requestModelGet6, "https"),
|
||||||
@ -168,22 +150,19 @@ axios(config)
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('GET 7', () {
|
test('GET 7', () {
|
||||||
const expectedCode = r"""let config = {
|
const expectedCode = r"""const config = {
|
||||||
url: 'https://api.apidash.dev',
|
url: 'https://api.apidash.dev',
|
||||||
method: 'get'
|
method: 'get'
|
||||||
};
|
};
|
||||||
|
|
||||||
axios(config)
|
axios(config)
|
||||||
.then(function (response) {
|
.then(res => {
|
||||||
// handle success
|
console.log(res.status);
|
||||||
console.log(response.status);
|
console.log(res.data);
|
||||||
console.log(response.data);
|
})
|
||||||
})
|
.catch(err => {
|
||||||
.catch(function (error) {
|
console.log(err);
|
||||||
// handle error
|
});
|
||||||
console.log(error.response.status);
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
""";
|
""";
|
||||||
expect(
|
expect(
|
||||||
codeGen.getCode(CodegenLanguage.jsAxios, requestModelGet7, "https"),
|
codeGen.getCode(CodegenLanguage.jsAxios, requestModelGet7, "https"),
|
||||||
@ -191,7 +170,7 @@ axios(config)
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('GET 8', () {
|
test('GET 8', () {
|
||||||
const expectedCode = r"""let config = {
|
const expectedCode = r"""const config = {
|
||||||
url: 'https://api.github.com/repos/foss42/apidash',
|
url: 'https://api.github.com/repos/foss42/apidash',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: {
|
params: {
|
||||||
@ -203,16 +182,13 @@ axios(config)
|
|||||||
};
|
};
|
||||||
|
|
||||||
axios(config)
|
axios(config)
|
||||||
.then(function (response) {
|
.then(res => {
|
||||||
// handle success
|
console.log(res.status);
|
||||||
console.log(response.status);
|
console.log(res.data);
|
||||||
console.log(response.data);
|
})
|
||||||
})
|
.catch(err => {
|
||||||
.catch(function (error) {
|
console.log(err);
|
||||||
// handle error
|
});
|
||||||
console.log(error.response.status);
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
""";
|
""";
|
||||||
expect(
|
expect(
|
||||||
codeGen.getCode(CodegenLanguage.jsAxios, requestModelGet8, "https"),
|
codeGen.getCode(CodegenLanguage.jsAxios, requestModelGet8, "https"),
|
||||||
@ -220,7 +196,7 @@ axios(config)
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('GET 9', () {
|
test('GET 9', () {
|
||||||
const expectedCode = r"""let config = {
|
const expectedCode = r"""const config = {
|
||||||
url: 'https://api.apidash.dev/humanize/social',
|
url: 'https://api.apidash.dev/humanize/social',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: {
|
params: {
|
||||||
@ -230,16 +206,13 @@ axios(config)
|
|||||||
};
|
};
|
||||||
|
|
||||||
axios(config)
|
axios(config)
|
||||||
.then(function (response) {
|
.then(res => {
|
||||||
// handle success
|
console.log(res.status);
|
||||||
console.log(response.status);
|
console.log(res.data);
|
||||||
console.log(response.data);
|
})
|
||||||
})
|
.catch(err => {
|
||||||
.catch(function (error) {
|
console.log(err);
|
||||||
// handle error
|
});
|
||||||
console.log(error.response.status);
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
""";
|
""";
|
||||||
expect(
|
expect(
|
||||||
codeGen.getCode(CodegenLanguage.jsAxios, requestModelGet9, "https"),
|
codeGen.getCode(CodegenLanguage.jsAxios, requestModelGet9, "https"),
|
||||||
@ -247,7 +220,7 @@ axios(config)
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('GET 10', () {
|
test('GET 10', () {
|
||||||
const expectedCode = r"""let config = {
|
const expectedCode = r"""const config = {
|
||||||
url: 'https://api.apidash.dev/humanize/social',
|
url: 'https://api.apidash.dev/humanize/social',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
headers: {
|
headers: {
|
||||||
@ -256,16 +229,13 @@ axios(config)
|
|||||||
};
|
};
|
||||||
|
|
||||||
axios(config)
|
axios(config)
|
||||||
.then(function (response) {
|
.then(res => {
|
||||||
// handle success
|
console.log(res.status);
|
||||||
console.log(response.status);
|
console.log(res.data);
|
||||||
console.log(response.data);
|
})
|
||||||
})
|
.catch(err => {
|
||||||
.catch(function (error) {
|
console.log(err);
|
||||||
// handle error
|
});
|
||||||
console.log(error.response.status);
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
""";
|
""";
|
||||||
expect(
|
expect(
|
||||||
codeGen.getCode(
|
codeGen.getCode(
|
||||||
@ -277,7 +247,7 @@ axios(config)
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('GET 11', () {
|
test('GET 11', () {
|
||||||
const expectedCode = r"""let config = {
|
const expectedCode = r"""const config = {
|
||||||
url: 'https://api.apidash.dev/humanize/social',
|
url: 'https://api.apidash.dev/humanize/social',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: {
|
params: {
|
||||||
@ -290,16 +260,13 @@ axios(config)
|
|||||||
};
|
};
|
||||||
|
|
||||||
axios(config)
|
axios(config)
|
||||||
.then(function (response) {
|
.then(res => {
|
||||||
// handle success
|
console.log(res.status);
|
||||||
console.log(response.status);
|
console.log(res.data);
|
||||||
console.log(response.data);
|
})
|
||||||
})
|
.catch(err => {
|
||||||
.catch(function (error) {
|
console.log(err);
|
||||||
// handle error
|
});
|
||||||
console.log(error.response.status);
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
""";
|
""";
|
||||||
expect(
|
expect(
|
||||||
codeGen.getCode(CodegenLanguage.jsAxios, requestModelGet11, "https"),
|
codeGen.getCode(CodegenLanguage.jsAxios, requestModelGet11, "https"),
|
||||||
@ -307,22 +274,19 @@ axios(config)
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('GET 12', () {
|
test('GET 12', () {
|
||||||
const expectedCode = r"""let config = {
|
const expectedCode = r"""const config = {
|
||||||
url: 'https://api.apidash.dev/humanize/social',
|
url: 'https://api.apidash.dev/humanize/social',
|
||||||
method: 'get'
|
method: 'get'
|
||||||
};
|
};
|
||||||
|
|
||||||
axios(config)
|
axios(config)
|
||||||
.then(function (response) {
|
.then(res => {
|
||||||
// handle success
|
console.log(res.status);
|
||||||
console.log(response.status);
|
console.log(res.data);
|
||||||
console.log(response.data);
|
})
|
||||||
})
|
.catch(err => {
|
||||||
.catch(function (error) {
|
console.log(err);
|
||||||
// handle error
|
});
|
||||||
console.log(error.response.status);
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
""";
|
""";
|
||||||
expect(
|
expect(
|
||||||
codeGen.getCode(CodegenLanguage.jsAxios, requestModelGet12, "https"),
|
codeGen.getCode(CodegenLanguage.jsAxios, requestModelGet12, "https"),
|
||||||
@ -332,22 +296,19 @@ axios(config)
|
|||||||
|
|
||||||
group('HEAD Request', () {
|
group('HEAD Request', () {
|
||||||
test('HEAD 1', () {
|
test('HEAD 1', () {
|
||||||
const expectedCode = r"""let config = {
|
const expectedCode = r"""const config = {
|
||||||
url: 'https://api.apidash.dev',
|
url: 'https://api.apidash.dev',
|
||||||
method: 'head'
|
method: 'head'
|
||||||
};
|
};
|
||||||
|
|
||||||
axios(config)
|
axios(config)
|
||||||
.then(function (response) {
|
.then(res => {
|
||||||
// handle success
|
console.log(res.status);
|
||||||
console.log(response.status);
|
console.log(res.data);
|
||||||
console.log(response.data);
|
})
|
||||||
})
|
.catch(err => {
|
||||||
.catch(function (error) {
|
console.log(err);
|
||||||
// handle error
|
});
|
||||||
console.log(error.response.status);
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
""";
|
""";
|
||||||
expect(
|
expect(
|
||||||
codeGen.getCode(CodegenLanguage.jsAxios, requestModelHead1, "https"),
|
codeGen.getCode(CodegenLanguage.jsAxios, requestModelHead1, "https"),
|
||||||
@ -355,22 +316,19 @@ axios(config)
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('HEAD 2', () {
|
test('HEAD 2', () {
|
||||||
const expectedCode = r"""let config = {
|
const expectedCode = r"""const config = {
|
||||||
url: 'http://api.apidash.dev',
|
url: 'http://api.apidash.dev',
|
||||||
method: 'head'
|
method: 'head'
|
||||||
};
|
};
|
||||||
|
|
||||||
axios(config)
|
axios(config)
|
||||||
.then(function (response) {
|
.then(res => {
|
||||||
// handle success
|
console.log(res.status);
|
||||||
console.log(response.status);
|
console.log(res.data);
|
||||||
console.log(response.data);
|
})
|
||||||
})
|
.catch(err => {
|
||||||
.catch(function (error) {
|
console.log(err);
|
||||||
// handle error
|
});
|
||||||
console.log(error.response.status);
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
""";
|
""";
|
||||||
expect(
|
expect(
|
||||||
codeGen.getCode(CodegenLanguage.jsAxios, requestModelHead2, "http"),
|
codeGen.getCode(CodegenLanguage.jsAxios, requestModelHead2, "http"),
|
||||||
@ -380,7 +338,7 @@ axios(config)
|
|||||||
|
|
||||||
group('POST Request', () {
|
group('POST Request', () {
|
||||||
test('POST 1', () {
|
test('POST 1', () {
|
||||||
const expectedCode = r"""let config = {
|
const expectedCode = r"""const config = {
|
||||||
url: 'https://api.apidash.dev/case/lower',
|
url: 'https://api.apidash.dev/case/lower',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
headers: {
|
headers: {
|
||||||
@ -390,16 +348,13 @@ axios(config)
|
|||||||
};
|
};
|
||||||
|
|
||||||
axios(config)
|
axios(config)
|
||||||
.then(function (response) {
|
.then(res => {
|
||||||
// handle success
|
console.log(res.status);
|
||||||
console.log(response.status);
|
console.log(res.data);
|
||||||
console.log(response.data);
|
})
|
||||||
})
|
.catch(err => {
|
||||||
.catch(function (error) {
|
console.log(err);
|
||||||
// handle error
|
});
|
||||||
console.log(error.response.status);
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
""";
|
""";
|
||||||
expect(
|
expect(
|
||||||
codeGen.getCode(CodegenLanguage.jsAxios, requestModelPost1, "https"),
|
codeGen.getCode(CodegenLanguage.jsAxios, requestModelPost1, "https"),
|
||||||
@ -407,7 +362,7 @@ axios(config)
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('POST 2', () {
|
test('POST 2', () {
|
||||||
const expectedCode = r"""let config = {
|
const expectedCode = r"""const config = {
|
||||||
url: 'https://api.apidash.dev/case/lower',
|
url: 'https://api.apidash.dev/case/lower',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
headers: {
|
headers: {
|
||||||
@ -417,16 +372,13 @@ axios(config)
|
|||||||
};
|
};
|
||||||
|
|
||||||
axios(config)
|
axios(config)
|
||||||
.then(function (response) {
|
.then(res => {
|
||||||
// handle success
|
console.log(res.status);
|
||||||
console.log(response.status);
|
console.log(res.data);
|
||||||
console.log(response.data);
|
})
|
||||||
})
|
.catch(err => {
|
||||||
.catch(function (error) {
|
console.log(err);
|
||||||
// handle error
|
});
|
||||||
console.log(error.response.status);
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
""";
|
""";
|
||||||
expect(
|
expect(
|
||||||
codeGen.getCode(CodegenLanguage.jsAxios, requestModelPost2, "https"),
|
codeGen.getCode(CodegenLanguage.jsAxios, requestModelPost2, "https"),
|
||||||
@ -434,7 +386,7 @@ axios(config)
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('POST 3', () {
|
test('POST 3', () {
|
||||||
const expectedCode = r"""let config = {
|
const expectedCode = r"""const config = {
|
||||||
url: 'https://api.apidash.dev/case/lower',
|
url: 'https://api.apidash.dev/case/lower',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
headers: {
|
headers: {
|
||||||
@ -445,26 +397,227 @@ axios(config)
|
|||||||
};
|
};
|
||||||
|
|
||||||
axios(config)
|
axios(config)
|
||||||
.then(function (response) {
|
.then(res => {
|
||||||
// handle success
|
console.log(res.status);
|
||||||
console.log(response.status);
|
console.log(res.data);
|
||||||
console.log(response.data);
|
})
|
||||||
})
|
.catch(err => {
|
||||||
.catch(function (error) {
|
console.log(err);
|
||||||
// handle error
|
});
|
||||||
console.log(error.response.status);
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
""";
|
""";
|
||||||
expect(
|
expect(
|
||||||
codeGen.getCode(CodegenLanguage.jsAxios, requestModelPost3, "https"),
|
codeGen.getCode(CodegenLanguage.jsAxios, requestModelPost3, "https"),
|
||||||
expectedCode);
|
expectedCode);
|
||||||
});
|
});
|
||||||
|
test('POST 4', () {
|
||||||
|
const expectedCode = r"""const config = {
|
||||||
|
url: 'https://api.apidash.dev/io/form',
|
||||||
|
method: 'post',
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "multipart/form-data"
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
"text": "API",
|
||||||
|
"sep": "|",
|
||||||
|
"times": "3"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
axios(config)
|
||||||
|
.then(res => {
|
||||||
|
console.log(res.status);
|
||||||
|
console.log(res.data);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
|
""";
|
||||||
|
expect(
|
||||||
|
codeGen.getCode(
|
||||||
|
CodegenLanguage.jsAxios,
|
||||||
|
requestModelPost4,
|
||||||
|
"https",
|
||||||
|
),
|
||||||
|
expectedCode);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('POST 5', () {
|
||||||
|
const expectedCode = r"""const config = {
|
||||||
|
url: 'https://api.apidash.dev/io/form',
|
||||||
|
method: 'post',
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "multipart/form-data",
|
||||||
|
"User-Agent": "Test Agent"
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
"text": "API",
|
||||||
|
"sep": "|",
|
||||||
|
"times": "3"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
axios(config)
|
||||||
|
.then(res => {
|
||||||
|
console.log(res.status);
|
||||||
|
console.log(res.data);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
|
""";
|
||||||
|
expect(
|
||||||
|
codeGen.getCode(
|
||||||
|
CodegenLanguage.jsAxios,
|
||||||
|
requestModelPost5,
|
||||||
|
"https",
|
||||||
|
),
|
||||||
|
expectedCode);
|
||||||
|
});
|
||||||
|
test('POST 6', () {
|
||||||
|
const expectedCode =
|
||||||
|
r"""// refer https://github.com/foss42/apidash/issues/293#issuecomment-1997568083 for details regarding integration
|
||||||
|
|
||||||
|
const config = {
|
||||||
|
url: 'https://api.apidash.dev/io/img',
|
||||||
|
method: 'post',
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "multipart/form-data"
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
"token": "xyz",
|
||||||
|
"imfile": fileInput1.files[0]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
axios(config)
|
||||||
|
.then(res => {
|
||||||
|
console.log(res.status);
|
||||||
|
console.log(res.data);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
|
""";
|
||||||
|
expect(
|
||||||
|
codeGen.getCode(
|
||||||
|
CodegenLanguage.jsAxios,
|
||||||
|
requestModelPost6,
|
||||||
|
"https",
|
||||||
|
),
|
||||||
|
expectedCode);
|
||||||
|
});
|
||||||
|
test('POST 7', () {
|
||||||
|
const expectedCode =
|
||||||
|
r"""// refer https://github.com/foss42/apidash/issues/293#issuecomment-1997568083 for details regarding integration
|
||||||
|
|
||||||
|
const config = {
|
||||||
|
url: 'https://api.apidash.dev/io/img',
|
||||||
|
method: 'post',
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "multipart/form-data"
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
"token": "xyz",
|
||||||
|
"imfile": fileInput1.files[0]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
axios(config)
|
||||||
|
.then(res => {
|
||||||
|
console.log(res.status);
|
||||||
|
console.log(res.data);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
|
""";
|
||||||
|
expect(
|
||||||
|
codeGen.getCode(
|
||||||
|
CodegenLanguage.jsAxios,
|
||||||
|
requestModelPost7,
|
||||||
|
"https",
|
||||||
|
),
|
||||||
|
expectedCode);
|
||||||
|
});
|
||||||
|
test('POST 8', () {
|
||||||
|
const expectedCode = r"""const config = {
|
||||||
|
url: 'https://api.apidash.dev/io/form',
|
||||||
|
method: 'post',
|
||||||
|
params: {
|
||||||
|
"size": "2",
|
||||||
|
"len": "3"
|
||||||
|
},
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "multipart/form-data"
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
"text": "API",
|
||||||
|
"sep": "|",
|
||||||
|
"times": "3"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
axios(config)
|
||||||
|
.then(res => {
|
||||||
|
console.log(res.status);
|
||||||
|
console.log(res.data);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
|
""";
|
||||||
|
expect(
|
||||||
|
codeGen.getCode(
|
||||||
|
CodegenLanguage.jsAxios,
|
||||||
|
requestModelPost8,
|
||||||
|
"https",
|
||||||
|
),
|
||||||
|
expectedCode);
|
||||||
|
});
|
||||||
|
test('POST 9', () {
|
||||||
|
const expectedCode =
|
||||||
|
r"""// refer https://github.com/foss42/apidash/issues/293#issuecomment-1997568083 for details regarding integration
|
||||||
|
|
||||||
|
const config = {
|
||||||
|
url: 'https://api.apidash.dev/io/img',
|
||||||
|
method: 'post',
|
||||||
|
params: {
|
||||||
|
"size": "2",
|
||||||
|
"len": "3"
|
||||||
|
},
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "multipart/form-data",
|
||||||
|
"User-Agent": "Test Agent",
|
||||||
|
"Keep-Alive": "true"
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
"token": "xyz",
|
||||||
|
"imfile": fileInput1.files[0]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
axios(config)
|
||||||
|
.then(res => {
|
||||||
|
console.log(res.status);
|
||||||
|
console.log(res.data);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
|
""";
|
||||||
|
expect(
|
||||||
|
codeGen.getCode(
|
||||||
|
CodegenLanguage.jsAxios,
|
||||||
|
requestModelPost9,
|
||||||
|
"https",
|
||||||
|
),
|
||||||
|
expectedCode);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
group('PUT Request', () {
|
group('PUT Request', () {
|
||||||
test('PUT 1', () {
|
test('PUT 1', () {
|
||||||
const expectedCode = r"""let config = {
|
const expectedCode = r"""const config = {
|
||||||
url: 'https://reqres.in/api/users/2',
|
url: 'https://reqres.in/api/users/2',
|
||||||
method: 'put',
|
method: 'put',
|
||||||
headers: {
|
headers: {
|
||||||
@ -474,16 +627,13 @@ axios(config)
|
|||||||
};
|
};
|
||||||
|
|
||||||
axios(config)
|
axios(config)
|
||||||
.then(function (response) {
|
.then(res => {
|
||||||
// handle success
|
console.log(res.status);
|
||||||
console.log(response.status);
|
console.log(res.data);
|
||||||
console.log(response.data);
|
})
|
||||||
})
|
.catch(err => {
|
||||||
.catch(function (error) {
|
console.log(err);
|
||||||
// handle error
|
});
|
||||||
console.log(error.response.status);
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
""";
|
""";
|
||||||
expect(
|
expect(
|
||||||
codeGen.getCode(CodegenLanguage.jsAxios, requestModelPut1, "https"),
|
codeGen.getCode(CodegenLanguage.jsAxios, requestModelPut1, "https"),
|
||||||
@ -493,7 +643,7 @@ axios(config)
|
|||||||
|
|
||||||
group('PATCH Request', () {
|
group('PATCH Request', () {
|
||||||
test('PATCH 1', () {
|
test('PATCH 1', () {
|
||||||
const expectedCode = r"""let config = {
|
const expectedCode = r"""const config = {
|
||||||
url: 'https://reqres.in/api/users/2',
|
url: 'https://reqres.in/api/users/2',
|
||||||
method: 'patch',
|
method: 'patch',
|
||||||
headers: {
|
headers: {
|
||||||
@ -503,16 +653,13 @@ axios(config)
|
|||||||
};
|
};
|
||||||
|
|
||||||
axios(config)
|
axios(config)
|
||||||
.then(function (response) {
|
.then(res => {
|
||||||
// handle success
|
console.log(res.status);
|
||||||
console.log(response.status);
|
console.log(res.data);
|
||||||
console.log(response.data);
|
})
|
||||||
})
|
.catch(err => {
|
||||||
.catch(function (error) {
|
console.log(err);
|
||||||
// handle error
|
});
|
||||||
console.log(error.response.status);
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
""";
|
""";
|
||||||
expect(
|
expect(
|
||||||
codeGen.getCode(CodegenLanguage.jsAxios, requestModelPatch1, "https"),
|
codeGen.getCode(CodegenLanguage.jsAxios, requestModelPatch1, "https"),
|
||||||
@ -522,22 +669,19 @@ axios(config)
|
|||||||
|
|
||||||
group('DELETE Request', () {
|
group('DELETE Request', () {
|
||||||
test('DELETE 1', () {
|
test('DELETE 1', () {
|
||||||
const expectedCode = r"""let config = {
|
const expectedCode = r"""const config = {
|
||||||
url: 'https://reqres.in/api/users/2',
|
url: 'https://reqres.in/api/users/2',
|
||||||
method: 'delete'
|
method: 'delete'
|
||||||
};
|
};
|
||||||
|
|
||||||
axios(config)
|
axios(config)
|
||||||
.then(function (response) {
|
.then(res => {
|
||||||
// handle success
|
console.log(res.status);
|
||||||
console.log(response.status);
|
console.log(res.data);
|
||||||
console.log(response.data);
|
})
|
||||||
})
|
.catch(err => {
|
||||||
.catch(function (error) {
|
console.log(err);
|
||||||
// handle error
|
});
|
||||||
console.log(error.response.status);
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
""";
|
""";
|
||||||
expect(
|
expect(
|
||||||
codeGen.getCode(
|
codeGen.getCode(
|
||||||
@ -546,7 +690,7 @@ axios(config)
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('DELETE 2', () {
|
test('DELETE 2', () {
|
||||||
const expectedCode = r"""let config = {
|
const expectedCode = r"""const config = {
|
||||||
url: 'https://reqres.in/api/users/2',
|
url: 'https://reqres.in/api/users/2',
|
||||||
method: 'delete',
|
method: 'delete',
|
||||||
headers: {
|
headers: {
|
||||||
@ -556,16 +700,13 @@ axios(config)
|
|||||||
};
|
};
|
||||||
|
|
||||||
axios(config)
|
axios(config)
|
||||||
.then(function (response) {
|
.then(res => {
|
||||||
// handle success
|
console.log(res.status);
|
||||||
console.log(response.status);
|
console.log(res.data);
|
||||||
console.log(response.data);
|
})
|
||||||
})
|
.catch(err => {
|
||||||
.catch(function (error) {
|
console.log(err);
|
||||||
// handle error
|
});
|
||||||
console.log(error.response.status);
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
""";
|
""";
|
||||||
expect(
|
expect(
|
||||||
codeGen.getCode(
|
codeGen.getCode(
|
||||||
|
@ -517,6 +517,35 @@ fun main() {
|
|||||||
CodegenLanguage.kotlinOkHttp, requestModelPost3, "https"),
|
CodegenLanguage.kotlinOkHttp, requestModelPost3, "https"),
|
||||||
expectedCode);
|
expectedCode);
|
||||||
});
|
});
|
||||||
|
test('POST 4', () {
|
||||||
|
const expectedCode = r'''import okhttp3.OkHttpClient
|
||||||
|
import okhttp3.Request
|
||||||
|
import okhttp3.MultipartBody
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
val client = OkHttpClient()
|
||||||
|
|
||||||
|
val url = "https://api.apidash.dev/io/form"
|
||||||
|
val body = MultipartBody.Builder().setType(MultipartBody.FORM).addFormDataPart("text","API")
|
||||||
|
.addFormDataPart("sep","|")
|
||||||
|
.addFormDataPart("times","3")
|
||||||
|
.build()
|
||||||
|
val request = Request.Builder()
|
||||||
|
.url(url)
|
||||||
|
.post(body)
|
||||||
|
.build()
|
||||||
|
|
||||||
|
val response = client.newCall(request).execute()
|
||||||
|
|
||||||
|
println(response.code)
|
||||||
|
println(response.body?.string())
|
||||||
|
}
|
||||||
|
''';
|
||||||
|
expect(
|
||||||
|
codeGen.getCode(
|
||||||
|
CodegenLanguage.kotlinOkHttp, requestModelPost4, "https"),
|
||||||
|
expectedCode);
|
||||||
|
});
|
||||||
|
|
||||||
test('POST 5', () {
|
test('POST 5', () {
|
||||||
const expectedCode = r'''import okhttp3.OkHttpClient
|
const expectedCode = r'''import okhttp3.OkHttpClient
|
||||||
@ -548,6 +577,141 @@ fun main() {
|
|||||||
CodegenLanguage.kotlinOkHttp, requestModelPost5, "https"),
|
CodegenLanguage.kotlinOkHttp, requestModelPost5, "https"),
|
||||||
expectedCode);
|
expectedCode);
|
||||||
});
|
});
|
||||||
|
test('POST 6', () {
|
||||||
|
const expectedCode = r'''import okhttp3.OkHttpClient
|
||||||
|
import okhttp3.Request
|
||||||
|
import okhttp3.MultipartBody
|
||||||
|
import java.io.File
|
||||||
|
import okhttp3.RequestBody.Companion.asRequestBody
|
||||||
|
import okhttp3.MediaType.Companion.toMediaType
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
val client = OkHttpClient()
|
||||||
|
|
||||||
|
val url = "https://api.apidash.dev/io/img"
|
||||||
|
val body = MultipartBody.Builder().setType(MultipartBody.FORM).addFormDataPart("token","xyz")
|
||||||
|
|
||||||
|
.addFormDataPart("imfile",File("Documents/up/1.png").name,File("Documents/up/1.png").asRequestBody("application/octet-stream".toMediaType()))
|
||||||
|
.build()
|
||||||
|
val request = Request.Builder()
|
||||||
|
.url(url)
|
||||||
|
.post(body)
|
||||||
|
.build()
|
||||||
|
|
||||||
|
val response = client.newCall(request).execute()
|
||||||
|
|
||||||
|
println(response.code)
|
||||||
|
println(response.body?.string())
|
||||||
|
}
|
||||||
|
''';
|
||||||
|
expect(
|
||||||
|
codeGen.getCode(
|
||||||
|
CodegenLanguage.kotlinOkHttp, requestModelPost6, "https"),
|
||||||
|
expectedCode);
|
||||||
|
});
|
||||||
|
test('POST 7', () {
|
||||||
|
const expectedCode = r'''import okhttp3.OkHttpClient
|
||||||
|
import okhttp3.Request
|
||||||
|
import okhttp3.MultipartBody
|
||||||
|
import java.io.File
|
||||||
|
import okhttp3.RequestBody.Companion.asRequestBody
|
||||||
|
import okhttp3.MediaType.Companion.toMediaType
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
val client = OkHttpClient()
|
||||||
|
|
||||||
|
val url = "https://api.apidash.dev/io/img"
|
||||||
|
val body = MultipartBody.Builder().setType(MultipartBody.FORM).addFormDataPart("token","xyz")
|
||||||
|
|
||||||
|
.addFormDataPart("imfile",File("Documents/up/1.png").name,File("Documents/up/1.png").asRequestBody("application/octet-stream".toMediaType()))
|
||||||
|
.build()
|
||||||
|
val request = Request.Builder()
|
||||||
|
.url(url)
|
||||||
|
.post(body)
|
||||||
|
.build()
|
||||||
|
|
||||||
|
val response = client.newCall(request).execute()
|
||||||
|
|
||||||
|
println(response.code)
|
||||||
|
println(response.body?.string())
|
||||||
|
}
|
||||||
|
''';
|
||||||
|
expect(
|
||||||
|
codeGen.getCode(
|
||||||
|
CodegenLanguage.kotlinOkHttp, requestModelPost7, "https"),
|
||||||
|
expectedCode);
|
||||||
|
});
|
||||||
|
test('POST 8', () {
|
||||||
|
const expectedCode = r'''import okhttp3.OkHttpClient
|
||||||
|
import okhttp3.Request
|
||||||
|
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||||
|
import okhttp3.MultipartBody
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
val client = OkHttpClient()
|
||||||
|
|
||||||
|
val url = "https://api.apidash.dev/io/form".toHttpUrl().newBuilder()
|
||||||
|
.addQueryParameter("size", "2")
|
||||||
|
.addQueryParameter("len", "3")
|
||||||
|
.build()
|
||||||
|
val body = MultipartBody.Builder().setType(MultipartBody.FORM).addFormDataPart("text","API")
|
||||||
|
.addFormDataPart("sep","|")
|
||||||
|
.addFormDataPart("times","3")
|
||||||
|
.build()
|
||||||
|
val request = Request.Builder()
|
||||||
|
.url(url)
|
||||||
|
.post(body)
|
||||||
|
.build()
|
||||||
|
|
||||||
|
val response = client.newCall(request).execute()
|
||||||
|
|
||||||
|
println(response.code)
|
||||||
|
println(response.body?.string())
|
||||||
|
}
|
||||||
|
''';
|
||||||
|
expect(
|
||||||
|
codeGen.getCode(
|
||||||
|
CodegenLanguage.kotlinOkHttp, requestModelPost8, "https"),
|
||||||
|
expectedCode);
|
||||||
|
});
|
||||||
|
test('POST 9', () {
|
||||||
|
const expectedCode = r'''import okhttp3.OkHttpClient
|
||||||
|
import okhttp3.Request
|
||||||
|
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||||
|
import okhttp3.MultipartBody
|
||||||
|
import java.io.File
|
||||||
|
import okhttp3.RequestBody.Companion.asRequestBody
|
||||||
|
import okhttp3.MediaType.Companion.toMediaType
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
val client = OkHttpClient()
|
||||||
|
|
||||||
|
val url = "https://api.apidash.dev/io/img".toHttpUrl().newBuilder()
|
||||||
|
.addQueryParameter("size", "2")
|
||||||
|
.addQueryParameter("len", "3")
|
||||||
|
.build()
|
||||||
|
val body = MultipartBody.Builder().setType(MultipartBody.FORM).addFormDataPart("token","xyz")
|
||||||
|
|
||||||
|
.addFormDataPart("imfile",File("Documents/up/1.png").name,File("Documents/up/1.png").asRequestBody("application/octet-stream".toMediaType()))
|
||||||
|
.build()
|
||||||
|
val request = Request.Builder()
|
||||||
|
.url(url)
|
||||||
|
.addHeader("User-Agent", "Test Agent")
|
||||||
|
.addHeader("Keep-Alive", "true")
|
||||||
|
.post(body)
|
||||||
|
.build()
|
||||||
|
|
||||||
|
val response = client.newCall(request).execute()
|
||||||
|
|
||||||
|
println(response.code)
|
||||||
|
println(response.body?.string())
|
||||||
|
}
|
||||||
|
''';
|
||||||
|
expect(
|
||||||
|
codeGen.getCode(
|
||||||
|
CodegenLanguage.kotlinOkHttp, requestModelPost9, "https"),
|
||||||
|
expectedCode);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
group('PUT Request', () {
|
group('PUT Request', () {
|
||||||
|
@ -10,22 +10,19 @@ void main() {
|
|||||||
test('GET 1', () {
|
test('GET 1', () {
|
||||||
const expectedCode = r"""import axios from 'axios';
|
const expectedCode = r"""import axios from 'axios';
|
||||||
|
|
||||||
let config = {
|
const config = {
|
||||||
url: 'https://api.apidash.dev',
|
url: 'https://api.apidash.dev',
|
||||||
method: 'get'
|
method: 'get'
|
||||||
};
|
};
|
||||||
|
|
||||||
axios(config)
|
axios(config)
|
||||||
.then(function (response) {
|
.then(res => {
|
||||||
// handle success
|
console.log(res.status);
|
||||||
console.log(response.status);
|
console.log(res.data);
|
||||||
console.log(response.data);
|
})
|
||||||
})
|
.catch(err => {
|
||||||
.catch(function (error) {
|
console.log(err);
|
||||||
// handle error
|
});
|
||||||
console.log(error.response.status);
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
""";
|
""";
|
||||||
expect(
|
expect(
|
||||||
codeGen.getCode(
|
codeGen.getCode(
|
||||||
@ -36,7 +33,7 @@ axios(config)
|
|||||||
test('GET 2', () {
|
test('GET 2', () {
|
||||||
const expectedCode = r"""import axios from 'axios';
|
const expectedCode = r"""import axios from 'axios';
|
||||||
|
|
||||||
let config = {
|
const config = {
|
||||||
url: 'https://api.apidash.dev/country/data',
|
url: 'https://api.apidash.dev/country/data',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: {
|
params: {
|
||||||
@ -45,16 +42,13 @@ let config = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
axios(config)
|
axios(config)
|
||||||
.then(function (response) {
|
.then(res => {
|
||||||
// handle success
|
console.log(res.status);
|
||||||
console.log(response.status);
|
console.log(res.data);
|
||||||
console.log(response.data);
|
})
|
||||||
})
|
.catch(err => {
|
||||||
.catch(function (error) {
|
console.log(err);
|
||||||
// handle error
|
});
|
||||||
console.log(error.response.status);
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
""";
|
""";
|
||||||
expect(
|
expect(
|
||||||
codeGen.getCode(
|
codeGen.getCode(
|
||||||
@ -65,7 +59,7 @@ axios(config)
|
|||||||
test('GET 3', () {
|
test('GET 3', () {
|
||||||
const expectedCode = r"""import axios from 'axios';
|
const expectedCode = r"""import axios from 'axios';
|
||||||
|
|
||||||
let config = {
|
const config = {
|
||||||
url: 'https://api.apidash.dev/country/data',
|
url: 'https://api.apidash.dev/country/data',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: {
|
params: {
|
||||||
@ -74,16 +68,13 @@ let config = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
axios(config)
|
axios(config)
|
||||||
.then(function (response) {
|
.then(res => {
|
||||||
// handle success
|
console.log(res.status);
|
||||||
console.log(response.status);
|
console.log(res.data);
|
||||||
console.log(response.data);
|
})
|
||||||
})
|
.catch(err => {
|
||||||
.catch(function (error) {
|
console.log(err);
|
||||||
// handle error
|
});
|
||||||
console.log(error.response.status);
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
""";
|
""";
|
||||||
expect(
|
expect(
|
||||||
codeGen.getCode(
|
codeGen.getCode(
|
||||||
@ -94,7 +85,7 @@ axios(config)
|
|||||||
test('GET 4', () {
|
test('GET 4', () {
|
||||||
const expectedCode = r"""import axios from 'axios';
|
const expectedCode = r"""import axios from 'axios';
|
||||||
|
|
||||||
let config = {
|
const config = {
|
||||||
url: 'https://api.apidash.dev/humanize/social',
|
url: 'https://api.apidash.dev/humanize/social',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: {
|
params: {
|
||||||
@ -107,16 +98,13 @@ let config = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
axios(config)
|
axios(config)
|
||||||
.then(function (response) {
|
.then(res => {
|
||||||
// handle success
|
console.log(res.status);
|
||||||
console.log(response.status);
|
console.log(res.data);
|
||||||
console.log(response.data);
|
})
|
||||||
})
|
.catch(err => {
|
||||||
.catch(function (error) {
|
console.log(err);
|
||||||
// handle error
|
});
|
||||||
console.log(error.response.status);
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
""";
|
""";
|
||||||
expect(
|
expect(
|
||||||
codeGen.getCode(
|
codeGen.getCode(
|
||||||
@ -127,7 +115,7 @@ axios(config)
|
|||||||
test('GET 5', () {
|
test('GET 5', () {
|
||||||
const expectedCode = r"""import axios from 'axios';
|
const expectedCode = r"""import axios from 'axios';
|
||||||
|
|
||||||
let config = {
|
const config = {
|
||||||
url: 'https://api.github.com/repos/foss42/apidash',
|
url: 'https://api.github.com/repos/foss42/apidash',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
headers: {
|
headers: {
|
||||||
@ -136,16 +124,13 @@ let config = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
axios(config)
|
axios(config)
|
||||||
.then(function (response) {
|
.then(res => {
|
||||||
// handle success
|
console.log(res.status);
|
||||||
console.log(response.status);
|
console.log(res.data);
|
||||||
console.log(response.data);
|
})
|
||||||
})
|
.catch(err => {
|
||||||
.catch(function (error) {
|
console.log(err);
|
||||||
// handle error
|
});
|
||||||
console.log(error.response.status);
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
""";
|
""";
|
||||||
expect(
|
expect(
|
||||||
codeGen.getCode(
|
codeGen.getCode(
|
||||||
@ -156,7 +141,7 @@ axios(config)
|
|||||||
test('GET 6', () {
|
test('GET 6', () {
|
||||||
const expectedCode = r"""import axios from 'axios';
|
const expectedCode = r"""import axios from 'axios';
|
||||||
|
|
||||||
let config = {
|
const config = {
|
||||||
url: 'https://api.github.com/repos/foss42/apidash',
|
url: 'https://api.github.com/repos/foss42/apidash',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: {
|
params: {
|
||||||
@ -168,16 +153,13 @@ let config = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
axios(config)
|
axios(config)
|
||||||
.then(function (response) {
|
.then(res => {
|
||||||
// handle success
|
console.log(res.status);
|
||||||
console.log(response.status);
|
console.log(res.data);
|
||||||
console.log(response.data);
|
})
|
||||||
})
|
.catch(err => {
|
||||||
.catch(function (error) {
|
console.log(err);
|
||||||
// handle error
|
});
|
||||||
console.log(error.response.status);
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
""";
|
""";
|
||||||
expect(
|
expect(
|
||||||
codeGen.getCode(
|
codeGen.getCode(
|
||||||
@ -188,22 +170,19 @@ axios(config)
|
|||||||
test('GET 7', () {
|
test('GET 7', () {
|
||||||
const expectedCode = r"""import axios from 'axios';
|
const expectedCode = r"""import axios from 'axios';
|
||||||
|
|
||||||
let config = {
|
const config = {
|
||||||
url: 'https://api.apidash.dev',
|
url: 'https://api.apidash.dev',
|
||||||
method: 'get'
|
method: 'get'
|
||||||
};
|
};
|
||||||
|
|
||||||
axios(config)
|
axios(config)
|
||||||
.then(function (response) {
|
.then(res => {
|
||||||
// handle success
|
console.log(res.status);
|
||||||
console.log(response.status);
|
console.log(res.data);
|
||||||
console.log(response.data);
|
})
|
||||||
})
|
.catch(err => {
|
||||||
.catch(function (error) {
|
console.log(err);
|
||||||
// handle error
|
});
|
||||||
console.log(error.response.status);
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
""";
|
""";
|
||||||
expect(
|
expect(
|
||||||
codeGen.getCode(
|
codeGen.getCode(
|
||||||
@ -214,7 +193,7 @@ axios(config)
|
|||||||
test('GET 8', () {
|
test('GET 8', () {
|
||||||
const expectedCode = r"""import axios from 'axios';
|
const expectedCode = r"""import axios from 'axios';
|
||||||
|
|
||||||
let config = {
|
const config = {
|
||||||
url: 'https://api.github.com/repos/foss42/apidash',
|
url: 'https://api.github.com/repos/foss42/apidash',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: {
|
params: {
|
||||||
@ -226,16 +205,13 @@ let config = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
axios(config)
|
axios(config)
|
||||||
.then(function (response) {
|
.then(res => {
|
||||||
// handle success
|
console.log(res.status);
|
||||||
console.log(response.status);
|
console.log(res.data);
|
||||||
console.log(response.data);
|
})
|
||||||
})
|
.catch(err => {
|
||||||
.catch(function (error) {
|
console.log(err);
|
||||||
// handle error
|
});
|
||||||
console.log(error.response.status);
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
""";
|
""";
|
||||||
expect(
|
expect(
|
||||||
codeGen.getCode(
|
codeGen.getCode(
|
||||||
@ -246,7 +222,7 @@ axios(config)
|
|||||||
test('GET 9', () {
|
test('GET 9', () {
|
||||||
const expectedCode = r"""import axios from 'axios';
|
const expectedCode = r"""import axios from 'axios';
|
||||||
|
|
||||||
let config = {
|
const config = {
|
||||||
url: 'https://api.apidash.dev/humanize/social',
|
url: 'https://api.apidash.dev/humanize/social',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: {
|
params: {
|
||||||
@ -256,16 +232,13 @@ let config = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
axios(config)
|
axios(config)
|
||||||
.then(function (response) {
|
.then(res => {
|
||||||
// handle success
|
console.log(res.status);
|
||||||
console.log(response.status);
|
console.log(res.data);
|
||||||
console.log(response.data);
|
})
|
||||||
})
|
.catch(err => {
|
||||||
.catch(function (error) {
|
console.log(err);
|
||||||
// handle error
|
});
|
||||||
console.log(error.response.status);
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
""";
|
""";
|
||||||
expect(
|
expect(
|
||||||
codeGen.getCode(
|
codeGen.getCode(
|
||||||
@ -276,7 +249,7 @@ axios(config)
|
|||||||
test('GET 10', () {
|
test('GET 10', () {
|
||||||
const expectedCode = r"""import axios from 'axios';
|
const expectedCode = r"""import axios from 'axios';
|
||||||
|
|
||||||
let config = {
|
const config = {
|
||||||
url: 'https://api.apidash.dev/humanize/social',
|
url: 'https://api.apidash.dev/humanize/social',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
headers: {
|
headers: {
|
||||||
@ -285,16 +258,13 @@ let config = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
axios(config)
|
axios(config)
|
||||||
.then(function (response) {
|
.then(res => {
|
||||||
// handle success
|
console.log(res.status);
|
||||||
console.log(response.status);
|
console.log(res.data);
|
||||||
console.log(response.data);
|
})
|
||||||
})
|
.catch(err => {
|
||||||
.catch(function (error) {
|
console.log(err);
|
||||||
// handle error
|
});
|
||||||
console.log(error.response.status);
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
""";
|
""";
|
||||||
expect(
|
expect(
|
||||||
codeGen.getCode(
|
codeGen.getCode(
|
||||||
@ -308,7 +278,7 @@ axios(config)
|
|||||||
test('GET 11', () {
|
test('GET 11', () {
|
||||||
const expectedCode = r"""import axios from 'axios';
|
const expectedCode = r"""import axios from 'axios';
|
||||||
|
|
||||||
let config = {
|
const config = {
|
||||||
url: 'https://api.apidash.dev/humanize/social',
|
url: 'https://api.apidash.dev/humanize/social',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: {
|
params: {
|
||||||
@ -321,16 +291,13 @@ let config = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
axios(config)
|
axios(config)
|
||||||
.then(function (response) {
|
.then(res => {
|
||||||
// handle success
|
console.log(res.status);
|
||||||
console.log(response.status);
|
console.log(res.data);
|
||||||
console.log(response.data);
|
})
|
||||||
})
|
.catch(err => {
|
||||||
.catch(function (error) {
|
console.log(err);
|
||||||
// handle error
|
});
|
||||||
console.log(error.response.status);
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
""";
|
""";
|
||||||
expect(
|
expect(
|
||||||
codeGen.getCode(
|
codeGen.getCode(
|
||||||
@ -341,22 +308,19 @@ axios(config)
|
|||||||
test('GET 12', () {
|
test('GET 12', () {
|
||||||
const expectedCode = r"""import axios from 'axios';
|
const expectedCode = r"""import axios from 'axios';
|
||||||
|
|
||||||
let config = {
|
const config = {
|
||||||
url: 'https://api.apidash.dev/humanize/social',
|
url: 'https://api.apidash.dev/humanize/social',
|
||||||
method: 'get'
|
method: 'get'
|
||||||
};
|
};
|
||||||
|
|
||||||
axios(config)
|
axios(config)
|
||||||
.then(function (response) {
|
.then(res => {
|
||||||
// handle success
|
console.log(res.status);
|
||||||
console.log(response.status);
|
console.log(res.data);
|
||||||
console.log(response.data);
|
})
|
||||||
})
|
.catch(err => {
|
||||||
.catch(function (error) {
|
console.log(err);
|
||||||
// handle error
|
});
|
||||||
console.log(error.response.status);
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
""";
|
""";
|
||||||
expect(
|
expect(
|
||||||
codeGen.getCode(
|
codeGen.getCode(
|
||||||
@ -369,22 +333,19 @@ axios(config)
|
|||||||
test('HEAD 1', () {
|
test('HEAD 1', () {
|
||||||
const expectedCode = r"""import axios from 'axios';
|
const expectedCode = r"""import axios from 'axios';
|
||||||
|
|
||||||
let config = {
|
const config = {
|
||||||
url: 'https://api.apidash.dev',
|
url: 'https://api.apidash.dev',
|
||||||
method: 'head'
|
method: 'head'
|
||||||
};
|
};
|
||||||
|
|
||||||
axios(config)
|
axios(config)
|
||||||
.then(function (response) {
|
.then(res => {
|
||||||
// handle success
|
console.log(res.status);
|
||||||
console.log(response.status);
|
console.log(res.data);
|
||||||
console.log(response.data);
|
})
|
||||||
})
|
.catch(err => {
|
||||||
.catch(function (error) {
|
console.log(err);
|
||||||
// handle error
|
});
|
||||||
console.log(error.response.status);
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
""";
|
""";
|
||||||
expect(
|
expect(
|
||||||
codeGen.getCode(
|
codeGen.getCode(
|
||||||
@ -395,22 +356,19 @@ axios(config)
|
|||||||
test('HEAD 2', () {
|
test('HEAD 2', () {
|
||||||
const expectedCode = r"""import axios from 'axios';
|
const expectedCode = r"""import axios from 'axios';
|
||||||
|
|
||||||
let config = {
|
const config = {
|
||||||
url: 'http://api.apidash.dev',
|
url: 'http://api.apidash.dev',
|
||||||
method: 'head'
|
method: 'head'
|
||||||
};
|
};
|
||||||
|
|
||||||
axios(config)
|
axios(config)
|
||||||
.then(function (response) {
|
.then(res => {
|
||||||
// handle success
|
console.log(res.status);
|
||||||
console.log(response.status);
|
console.log(res.data);
|
||||||
console.log(response.data);
|
})
|
||||||
})
|
.catch(err => {
|
||||||
.catch(function (error) {
|
console.log(err);
|
||||||
// handle error
|
});
|
||||||
console.log(error.response.status);
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
""";
|
""";
|
||||||
expect(
|
expect(
|
||||||
codeGen.getCode(
|
codeGen.getCode(
|
||||||
@ -423,7 +381,7 @@ axios(config)
|
|||||||
test('POST 1', () {
|
test('POST 1', () {
|
||||||
const expectedCode = r"""import axios from 'axios';
|
const expectedCode = r"""import axios from 'axios';
|
||||||
|
|
||||||
let config = {
|
const config = {
|
||||||
url: 'https://api.apidash.dev/case/lower',
|
url: 'https://api.apidash.dev/case/lower',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
headers: {
|
headers: {
|
||||||
@ -433,16 +391,13 @@ let config = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
axios(config)
|
axios(config)
|
||||||
.then(function (response) {
|
.then(res => {
|
||||||
// handle success
|
console.log(res.status);
|
||||||
console.log(response.status);
|
console.log(res.data);
|
||||||
console.log(response.data);
|
})
|
||||||
})
|
.catch(err => {
|
||||||
.catch(function (error) {
|
console.log(err);
|
||||||
// handle error
|
});
|
||||||
console.log(error.response.status);
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
""";
|
""";
|
||||||
expect(
|
expect(
|
||||||
codeGen.getCode(
|
codeGen.getCode(
|
||||||
@ -453,7 +408,7 @@ axios(config)
|
|||||||
test('POST 2', () {
|
test('POST 2', () {
|
||||||
const expectedCode = r"""import axios from 'axios';
|
const expectedCode = r"""import axios from 'axios';
|
||||||
|
|
||||||
let config = {
|
const config = {
|
||||||
url: 'https://api.apidash.dev/case/lower',
|
url: 'https://api.apidash.dev/case/lower',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
headers: {
|
headers: {
|
||||||
@ -463,16 +418,13 @@ let config = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
axios(config)
|
axios(config)
|
||||||
.then(function (response) {
|
.then(res => {
|
||||||
// handle success
|
console.log(res.status);
|
||||||
console.log(response.status);
|
console.log(res.data);
|
||||||
console.log(response.data);
|
})
|
||||||
})
|
.catch(err => {
|
||||||
.catch(function (error) {
|
console.log(err);
|
||||||
// handle error
|
});
|
||||||
console.log(error.response.status);
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
""";
|
""";
|
||||||
expect(
|
expect(
|
||||||
codeGen.getCode(
|
codeGen.getCode(
|
||||||
@ -483,7 +435,7 @@ axios(config)
|
|||||||
test('POST 3', () {
|
test('POST 3', () {
|
||||||
const expectedCode = r"""import axios from 'axios';
|
const expectedCode = r"""import axios from 'axios';
|
||||||
|
|
||||||
let config = {
|
const config = {
|
||||||
url: 'https://api.apidash.dev/case/lower',
|
url: 'https://api.apidash.dev/case/lower',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
headers: {
|
headers: {
|
||||||
@ -494,29 +446,236 @@ let config = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
axios(config)
|
axios(config)
|
||||||
.then(function (response) {
|
.then(res => {
|
||||||
// handle success
|
console.log(res.status);
|
||||||
console.log(response.status);
|
console.log(res.data);
|
||||||
console.log(response.data);
|
})
|
||||||
})
|
.catch(err => {
|
||||||
.catch(function (error) {
|
console.log(err);
|
||||||
// handle error
|
});
|
||||||
console.log(error.response.status);
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
""";
|
""";
|
||||||
expect(
|
expect(
|
||||||
codeGen.getCode(
|
codeGen.getCode(
|
||||||
CodegenLanguage.nodejsAxios, requestModelPost3, "https"),
|
CodegenLanguage.nodejsAxios, requestModelPost3, "https"),
|
||||||
expectedCode);
|
expectedCode);
|
||||||
});
|
});
|
||||||
|
test('POST 4', () {
|
||||||
|
const expectedCode = r"""import axios from 'axios';
|
||||||
|
|
||||||
|
const config = {
|
||||||
|
url: 'https://api.apidash.dev/io/form',
|
||||||
|
method: 'post',
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "multipart/form-data"
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
"text": "API",
|
||||||
|
"sep": "|",
|
||||||
|
"times": "3"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
axios(config)
|
||||||
|
.then(res => {
|
||||||
|
console.log(res.status);
|
||||||
|
console.log(res.data);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
|
""";
|
||||||
|
expect(
|
||||||
|
codeGen.getCode(
|
||||||
|
CodegenLanguage.nodejsAxios,
|
||||||
|
requestModelPost4,
|
||||||
|
"https",
|
||||||
|
),
|
||||||
|
expectedCode);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('POST 5', () {
|
||||||
|
const expectedCode = r"""import axios from 'axios';
|
||||||
|
|
||||||
|
const config = {
|
||||||
|
url: 'https://api.apidash.dev/io/form',
|
||||||
|
method: 'post',
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "multipart/form-data",
|
||||||
|
"User-Agent": "Test Agent"
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
"text": "API",
|
||||||
|
"sep": "|",
|
||||||
|
"times": "3"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
axios(config)
|
||||||
|
.then(res => {
|
||||||
|
console.log(res.status);
|
||||||
|
console.log(res.data);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
|
""";
|
||||||
|
expect(
|
||||||
|
codeGen.getCode(
|
||||||
|
CodegenLanguage.nodejsAxios,
|
||||||
|
requestModelPost5,
|
||||||
|
"https",
|
||||||
|
),
|
||||||
|
expectedCode);
|
||||||
|
});
|
||||||
|
test('POST 6', () {
|
||||||
|
const expectedCode = r"""import axios from 'axios';
|
||||||
|
import fs from 'fs'
|
||||||
|
|
||||||
|
const config = {
|
||||||
|
url: 'https://api.apidash.dev/io/img',
|
||||||
|
method: 'post',
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "multipart/form-data"
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
"token": "xyz",
|
||||||
|
"imfile": fs.createReadStream("/Documents/up/1.png")
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
axios(config)
|
||||||
|
.then(res => {
|
||||||
|
console.log(res.status);
|
||||||
|
console.log(res.data);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
|
""";
|
||||||
|
expect(
|
||||||
|
codeGen.getCode(
|
||||||
|
CodegenLanguage.nodejsAxios,
|
||||||
|
requestModelPost6,
|
||||||
|
"https",
|
||||||
|
),
|
||||||
|
expectedCode);
|
||||||
|
});
|
||||||
|
test('POST 7', () {
|
||||||
|
const expectedCode = r"""import axios from 'axios';
|
||||||
|
import fs from 'fs'
|
||||||
|
|
||||||
|
const config = {
|
||||||
|
url: 'https://api.apidash.dev/io/img',
|
||||||
|
method: 'post',
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "multipart/form-data"
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
"token": "xyz",
|
||||||
|
"imfile": fs.createReadStream("/Documents/up/1.png")
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
axios(config)
|
||||||
|
.then(res => {
|
||||||
|
console.log(res.status);
|
||||||
|
console.log(res.data);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
|
""";
|
||||||
|
expect(
|
||||||
|
codeGen.getCode(
|
||||||
|
CodegenLanguage.nodejsAxios,
|
||||||
|
requestModelPost7,
|
||||||
|
"https",
|
||||||
|
),
|
||||||
|
expectedCode);
|
||||||
|
});
|
||||||
|
test('POST 8', () {
|
||||||
|
const expectedCode = r"""import axios from 'axios';
|
||||||
|
|
||||||
|
const config = {
|
||||||
|
url: 'https://api.apidash.dev/io/form',
|
||||||
|
method: 'post',
|
||||||
|
params: {
|
||||||
|
"size": "2",
|
||||||
|
"len": "3"
|
||||||
|
},
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "multipart/form-data"
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
"text": "API",
|
||||||
|
"sep": "|",
|
||||||
|
"times": "3"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
axios(config)
|
||||||
|
.then(res => {
|
||||||
|
console.log(res.status);
|
||||||
|
console.log(res.data);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
|
""";
|
||||||
|
expect(
|
||||||
|
codeGen.getCode(
|
||||||
|
CodegenLanguage.nodejsAxios,
|
||||||
|
requestModelPost8,
|
||||||
|
"https",
|
||||||
|
),
|
||||||
|
expectedCode);
|
||||||
|
});
|
||||||
|
test('POST 9', () {
|
||||||
|
const expectedCode = r"""import axios from 'axios';
|
||||||
|
import fs from 'fs'
|
||||||
|
|
||||||
|
const config = {
|
||||||
|
url: 'https://api.apidash.dev/io/img',
|
||||||
|
method: 'post',
|
||||||
|
params: {
|
||||||
|
"size": "2",
|
||||||
|
"len": "3"
|
||||||
|
},
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "multipart/form-data",
|
||||||
|
"User-Agent": "Test Agent",
|
||||||
|
"Keep-Alive": "true"
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
"token": "xyz",
|
||||||
|
"imfile": fs.createReadStream("/Documents/up/1.png")
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
axios(config)
|
||||||
|
.then(res => {
|
||||||
|
console.log(res.status);
|
||||||
|
console.log(res.data);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
|
""";
|
||||||
|
expect(
|
||||||
|
codeGen.getCode(
|
||||||
|
CodegenLanguage.nodejsAxios,
|
||||||
|
requestModelPost9,
|
||||||
|
"https",
|
||||||
|
),
|
||||||
|
expectedCode);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
group('PUT Request', () {
|
group('PUT Request', () {
|
||||||
test('PUT 1', () {
|
test('PUT 1', () {
|
||||||
const expectedCode = r"""import axios from 'axios';
|
const expectedCode = r"""import axios from 'axios';
|
||||||
|
|
||||||
let config = {
|
const config = {
|
||||||
url: 'https://reqres.in/api/users/2',
|
url: 'https://reqres.in/api/users/2',
|
||||||
method: 'put',
|
method: 'put',
|
||||||
headers: {
|
headers: {
|
||||||
@ -526,16 +685,13 @@ let config = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
axios(config)
|
axios(config)
|
||||||
.then(function (response) {
|
.then(res => {
|
||||||
// handle success
|
console.log(res.status);
|
||||||
console.log(response.status);
|
console.log(res.data);
|
||||||
console.log(response.data);
|
})
|
||||||
})
|
.catch(err => {
|
||||||
.catch(function (error) {
|
console.log(err);
|
||||||
// handle error
|
});
|
||||||
console.log(error.response.status);
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
""";
|
""";
|
||||||
expect(
|
expect(
|
||||||
codeGen.getCode(
|
codeGen.getCode(
|
||||||
@ -548,7 +704,7 @@ axios(config)
|
|||||||
test('PATCH 1', () {
|
test('PATCH 1', () {
|
||||||
const expectedCode = r"""import axios from 'axios';
|
const expectedCode = r"""import axios from 'axios';
|
||||||
|
|
||||||
let config = {
|
const config = {
|
||||||
url: 'https://reqres.in/api/users/2',
|
url: 'https://reqres.in/api/users/2',
|
||||||
method: 'patch',
|
method: 'patch',
|
||||||
headers: {
|
headers: {
|
||||||
@ -558,16 +714,13 @@ let config = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
axios(config)
|
axios(config)
|
||||||
.then(function (response) {
|
.then(res => {
|
||||||
// handle success
|
console.log(res.status);
|
||||||
console.log(response.status);
|
console.log(res.data);
|
||||||
console.log(response.data);
|
})
|
||||||
})
|
.catch(err => {
|
||||||
.catch(function (error) {
|
console.log(err);
|
||||||
// handle error
|
});
|
||||||
console.log(error.response.status);
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
""";
|
""";
|
||||||
expect(
|
expect(
|
||||||
codeGen.getCode(
|
codeGen.getCode(
|
||||||
@ -580,22 +733,19 @@ axios(config)
|
|||||||
test('DELETE 1', () {
|
test('DELETE 1', () {
|
||||||
const expectedCode = r"""import axios from 'axios';
|
const expectedCode = r"""import axios from 'axios';
|
||||||
|
|
||||||
let config = {
|
const config = {
|
||||||
url: 'https://reqres.in/api/users/2',
|
url: 'https://reqres.in/api/users/2',
|
||||||
method: 'delete'
|
method: 'delete'
|
||||||
};
|
};
|
||||||
|
|
||||||
axios(config)
|
axios(config)
|
||||||
.then(function (response) {
|
.then(res => {
|
||||||
// handle success
|
console.log(res.status);
|
||||||
console.log(response.status);
|
console.log(res.data);
|
||||||
console.log(response.data);
|
})
|
||||||
})
|
.catch(err => {
|
||||||
.catch(function (error) {
|
console.log(err);
|
||||||
// handle error
|
});
|
||||||
console.log(error.response.status);
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
""";
|
""";
|
||||||
expect(
|
expect(
|
||||||
codeGen.getCode(
|
codeGen.getCode(
|
||||||
@ -606,7 +756,7 @@ axios(config)
|
|||||||
test('DELETE 2', () {
|
test('DELETE 2', () {
|
||||||
const expectedCode = r"""import axios from 'axios';
|
const expectedCode = r"""import axios from 'axios';
|
||||||
|
|
||||||
let config = {
|
const config = {
|
||||||
url: 'https://reqres.in/api/users/2',
|
url: 'https://reqres.in/api/users/2',
|
||||||
method: 'delete',
|
method: 'delete',
|
||||||
headers: {
|
headers: {
|
||||||
@ -616,16 +766,13 @@ let config = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
axios(config)
|
axios(config)
|
||||||
.then(function (response) {
|
.then(res => {
|
||||||
// handle success
|
console.log(res.status);
|
||||||
console.log(response.status);
|
console.log(res.data);
|
||||||
console.log(response.data);
|
})
|
||||||
})
|
.catch(err => {
|
||||||
.catch(function (error) {
|
console.log(err);
|
||||||
// handle error
|
});
|
||||||
console.log(error.response.status);
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
""";
|
""";
|
||||||
expect(
|
expect(
|
||||||
codeGen.getCode(
|
codeGen.getCode(
|
||||||
|
Reference in New Issue
Block a user