mirror of
https://github.com/foss42/apidash.git
synced 2025-06-04 17:37:05 +08:00
rev: reverted changes in js code gen
This commit is contained in:
@ -11,6 +11,7 @@ class AxiosCodeGen {
|
|||||||
final bool isNodeJs;
|
final bool isNodeJs;
|
||||||
|
|
||||||
String kStringImportNode = """{% if isNodeJs %}import axios from 'axios';
|
String kStringImportNode = """{% if isNodeJs %}import axios from 'axios';
|
||||||
|
|
||||||
{% endif %}{% if isFormDataRequest and isNodeJs %}const fs = require('fs');{% endif %}
|
{% endif %}{% if isFormDataRequest and isNodeJs %}const fs = require('fs');{% endif %}
|
||||||
""";
|
""";
|
||||||
|
|
||||||
|
@ -27,7 +27,8 @@ let options = {
|
|||||||
""";
|
""";
|
||||||
|
|
||||||
String kTemplateBody = """,
|
String kTemplateBody = """,
|
||||||
body: {{body}}
|
body:
|
||||||
|
{{body}}
|
||||||
""";
|
""";
|
||||||
|
|
||||||
String kMultiPartBodyTemplate = r'''
|
String kMultiPartBodyTemplate = r'''
|
||||||
|
@ -398,7 +398,8 @@ let options = {
|
|||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "text/plain"
|
"Content-Type": "text/plain"
|
||||||
},
|
},
|
||||||
body: "{\n\"text\": \"I LOVE Flutter\"\n}"
|
body:
|
||||||
|
"{\n\"text\": \"I LOVE Flutter\"\n}"
|
||||||
};
|
};
|
||||||
|
|
||||||
let status;
|
let status;
|
||||||
@ -427,7 +428,8 @@ let options = {
|
|||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
},
|
},
|
||||||
body: "{\n\"text\": \"I LOVE Flutter\"\n}"
|
body:
|
||||||
|
"{\n\"text\": \"I LOVE Flutter\"\n}"
|
||||||
};
|
};
|
||||||
|
|
||||||
let status;
|
let status;
|
||||||
@ -457,7 +459,8 @@ let options = {
|
|||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
"User-Agent": "Test Agent"
|
"User-Agent": "Test Agent"
|
||||||
},
|
},
|
||||||
body: "{\n\"text\": \"I LOVE Flutter\"\n}"
|
body:
|
||||||
|
"{\n\"text\": \"I LOVE Flutter\"\n}"
|
||||||
};
|
};
|
||||||
|
|
||||||
let status;
|
let status;
|
||||||
@ -488,7 +491,8 @@ let options = {
|
|||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
},
|
},
|
||||||
body: "{\n\"name\": \"morpheus\",\n\"job\": \"zion resident\"\n}"
|
body:
|
||||||
|
"{\n\"name\": \"morpheus\",\n\"job\": \"zion resident\"\n}"
|
||||||
};
|
};
|
||||||
|
|
||||||
let status;
|
let status;
|
||||||
@ -519,7 +523,8 @@ let options = {
|
|||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
},
|
},
|
||||||
body: "{\n\"name\": \"marfeus\",\n\"job\": \"accountant\"\n}"
|
body:
|
||||||
|
"{\n\"name\": \"marfeus\",\n\"job\": \"accountant\"\n}"
|
||||||
};
|
};
|
||||||
|
|
||||||
let status;
|
let status;
|
||||||
@ -575,7 +580,8 @@ let options = {
|
|||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
},
|
},
|
||||||
body: "{\n\"name\": \"marfeus\",\n\"job\": \"accountant\"\n}"
|
body:
|
||||||
|
"{\n\"name\": \"marfeus\",\n\"job\": \"accountant\"\n}"
|
||||||
};
|
};
|
||||||
|
|
||||||
let status;
|
let status;
|
||||||
|
@ -8,6 +8,7 @@ void main() {
|
|||||||
group('GET Request', () {
|
group('GET Request', () {
|
||||||
test('GET 1', () {
|
test('GET 1', () {
|
||||||
const expectedCode = r"""import axios from 'axios';
|
const expectedCode = r"""import axios from 'axios';
|
||||||
|
|
||||||
let config = {
|
let config = {
|
||||||
url: 'https://api.foss42.com',
|
url: 'https://api.foss42.com',
|
||||||
method: 'get'
|
method: 'get'
|
||||||
@ -30,6 +31,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 = {
|
let config = {
|
||||||
url: 'https://api.foss42.com/country/data',
|
url: 'https://api.foss42.com/country/data',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
@ -55,6 +57,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 = {
|
let config = {
|
||||||
url: 'https://api.foss42.com/country/data',
|
url: 'https://api.foss42.com/country/data',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
@ -80,6 +83,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 = {
|
let config = {
|
||||||
url: 'https://api.foss42.com/humanize/social',
|
url: 'https://api.foss42.com/humanize/social',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
@ -109,6 +113,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 = {
|
let config = {
|
||||||
url: 'https://api.github.com/repos/foss42/apidash',
|
url: 'https://api.github.com/repos/foss42/apidash',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
@ -134,6 +139,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 = {
|
let config = {
|
||||||
url: 'https://api.github.com/repos/foss42/apidash',
|
url: 'https://api.github.com/repos/foss42/apidash',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
@ -162,6 +168,7 @@ axios(config)
|
|||||||
|
|
||||||
test('GET 7', () {
|
test('GET 7', () {
|
||||||
const expectedCode = r"""import axios from 'axios';
|
const expectedCode = r"""import axios from 'axios';
|
||||||
|
|
||||||
let config = {
|
let config = {
|
||||||
url: 'https://api.foss42.com',
|
url: 'https://api.foss42.com',
|
||||||
method: 'get'
|
method: 'get'
|
||||||
@ -184,6 +191,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 = {
|
let config = {
|
||||||
url: 'https://api.github.com/repos/foss42/apidash',
|
url: 'https://api.github.com/repos/foss42/apidash',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
@ -212,6 +220,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 = {
|
let config = {
|
||||||
url: 'https://api.foss42.com/humanize/social',
|
url: 'https://api.foss42.com/humanize/social',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
@ -238,6 +247,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 = {
|
let config = {
|
||||||
url: 'https://api.foss42.com/humanize/social',
|
url: 'https://api.foss42.com/humanize/social',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
@ -268,6 +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 = {
|
let config = {
|
||||||
url: 'https://api.foss42.com/humanize/social',
|
url: 'https://api.foss42.com/humanize/social',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
@ -297,6 +308,7 @@ axios(config)
|
|||||||
|
|
||||||
test('GET 12', () {
|
test('GET 12', () {
|
||||||
const expectedCode = r"""import axios from 'axios';
|
const expectedCode = r"""import axios from 'axios';
|
||||||
|
|
||||||
let config = {
|
let config = {
|
||||||
url: 'https://api.foss42.com/humanize/social',
|
url: 'https://api.foss42.com/humanize/social',
|
||||||
method: 'get'
|
method: 'get'
|
||||||
@ -321,6 +333,7 @@ axios(config)
|
|||||||
group('HEAD Request', () {
|
group('HEAD Request', () {
|
||||||
test('HEAD 1', () {
|
test('HEAD 1', () {
|
||||||
const expectedCode = r"""import axios from 'axios';
|
const expectedCode = r"""import axios from 'axios';
|
||||||
|
|
||||||
let config = {
|
let config = {
|
||||||
url: 'https://api.foss42.com',
|
url: 'https://api.foss42.com',
|
||||||
method: 'head'
|
method: 'head'
|
||||||
@ -343,6 +356,7 @@ axios(config)
|
|||||||
|
|
||||||
test('HEAD 2', () {
|
test('HEAD 2', () {
|
||||||
const expectedCode = r"""import axios from 'axios';
|
const expectedCode = r"""import axios from 'axios';
|
||||||
|
|
||||||
let config = {
|
let config = {
|
||||||
url: 'http://api.foss42.com',
|
url: 'http://api.foss42.com',
|
||||||
method: 'head'
|
method: 'head'
|
||||||
@ -367,6 +381,7 @@ axios(config)
|
|||||||
group('POST Request', () {
|
group('POST Request', () {
|
||||||
test('POST 1', () {
|
test('POST 1', () {
|
||||||
const expectedCode = r"""import axios from 'axios';
|
const expectedCode = r"""import axios from 'axios';
|
||||||
|
|
||||||
let config = {
|
let config = {
|
||||||
url: 'https://api.foss42.com/case/lower',
|
url: 'https://api.foss42.com/case/lower',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
@ -393,6 +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 = {
|
let config = {
|
||||||
url: 'https://api.foss42.com/case/lower',
|
url: 'https://api.foss42.com/case/lower',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
@ -419,6 +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 = {
|
let config = {
|
||||||
url: 'https://api.foss42.com/case/lower',
|
url: 'https://api.foss42.com/case/lower',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
@ -448,6 +465,7 @@ axios(config)
|
|||||||
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 = {
|
let config = {
|
||||||
url: 'https://reqres.in/api/users/2',
|
url: 'https://reqres.in/api/users/2',
|
||||||
method: 'put',
|
method: 'put',
|
||||||
@ -476,6 +494,7 @@ axios(config)
|
|||||||
group('PATCH Request', () {
|
group('PATCH Request', () {
|
||||||
test('PATCH 1', () {
|
test('PATCH 1', () {
|
||||||
const expectedCode = r"""import axios from 'axios';
|
const expectedCode = r"""import axios from 'axios';
|
||||||
|
|
||||||
let config = {
|
let config = {
|
||||||
url: 'https://reqres.in/api/users/2',
|
url: 'https://reqres.in/api/users/2',
|
||||||
method: 'patch',
|
method: 'patch',
|
||||||
@ -504,6 +523,7 @@ axios(config)
|
|||||||
group('DELETE Request', () {
|
group('DELETE Request', () {
|
||||||
test('DELETE 1', () {
|
test('DELETE 1', () {
|
||||||
const expectedCode = r"""import axios from 'axios';
|
const expectedCode = r"""import axios from 'axios';
|
||||||
|
|
||||||
let config = {
|
let config = {
|
||||||
url: 'https://reqres.in/api/users/2',
|
url: 'https://reqres.in/api/users/2',
|
||||||
method: 'delete'
|
method: 'delete'
|
||||||
@ -526,6 +546,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 = {
|
let config = {
|
||||||
url: 'https://reqres.in/api/users/2',
|
url: 'https://reqres.in/api/users/2',
|
||||||
method: 'delete',
|
method: 'delete',
|
||||||
|
@ -418,7 +418,8 @@ let options = {
|
|||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "text/plain"
|
"Content-Type": "text/plain"
|
||||||
},
|
},
|
||||||
body: "{\n\"text\": \"I LOVE Flutter\"\n}"
|
body:
|
||||||
|
"{\n\"text\": \"I LOVE Flutter\"\n}"
|
||||||
};
|
};
|
||||||
|
|
||||||
let status;
|
let status;
|
||||||
@ -449,7 +450,8 @@ let options = {
|
|||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
},
|
},
|
||||||
body: "{\n\"text\": \"I LOVE Flutter\"\n}"
|
body:
|
||||||
|
"{\n\"text\": \"I LOVE Flutter\"\n}"
|
||||||
};
|
};
|
||||||
|
|
||||||
let status;
|
let status;
|
||||||
@ -481,7 +483,8 @@ let options = {
|
|||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
"User-Agent": "Test Agent"
|
"User-Agent": "Test Agent"
|
||||||
},
|
},
|
||||||
body: "{\n\"text\": \"I LOVE Flutter\"\n}"
|
body:
|
||||||
|
"{\n\"text\": \"I LOVE Flutter\"\n}"
|
||||||
};
|
};
|
||||||
|
|
||||||
let status;
|
let status;
|
||||||
@ -514,7 +517,8 @@ let options = {
|
|||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
},
|
},
|
||||||
body: "{\n\"name\": \"morpheus\",\n\"job\": \"zion resident\"\n}"
|
body:
|
||||||
|
"{\n\"name\": \"morpheus\",\n\"job\": \"zion resident\"\n}"
|
||||||
};
|
};
|
||||||
|
|
||||||
let status;
|
let status;
|
||||||
@ -547,7 +551,8 @@ let options = {
|
|||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
},
|
},
|
||||||
body: "{\n\"name\": \"marfeus\",\n\"job\": \"accountant\"\n}"
|
body:
|
||||||
|
"{\n\"name\": \"marfeus\",\n\"job\": \"accountant\"\n}"
|
||||||
};
|
};
|
||||||
|
|
||||||
let status;
|
let status;
|
||||||
@ -607,7 +612,8 @@ let options = {
|
|||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
},
|
},
|
||||||
body: "{\n\"name\": \"marfeus\",\n\"job\": \"accountant\"\n}"
|
body:
|
||||||
|
"{\n\"name\": \"marfeus\",\n\"job\": \"accountant\"\n}"
|
||||||
};
|
};
|
||||||
|
|
||||||
let status;
|
let status;
|
||||||
|
Reference in New Issue
Block a user