mirror of
https://github.com/foss42/apidash.git
synced 2025-09-25 16:15:25 +08:00
fix: Removed Json which was causing error
This commit is contained in:
@ -7,7 +7,6 @@ class PythonRequestCodeGen {
|
|||||||
int kHeadersPadding = 16;
|
int kHeadersPadding = 16;
|
||||||
String kPythonTemplate = '''
|
String kPythonTemplate = '''
|
||||||
import requests
|
import requests
|
||||||
import json
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
url = '{{url}}'{{params}}{{body}}{{headers}}
|
url = '{{url}}'{{params}}{{body}}{{headers}}
|
||||||
@ -56,9 +55,7 @@ main()
|
|||||||
if (requestBody != null && requestBody.isNotEmpty) {
|
if (requestBody != null && requestBody.isNotEmpty) {
|
||||||
hasBody = true;
|
hasBody = true;
|
||||||
var bodyType = requestModel.requestBodyContentType;
|
var bodyType = requestModel.requestBodyContentType;
|
||||||
if (bodyType == ContentType.text) {
|
if (bodyType == ContentType.json) {
|
||||||
requestBodyString = "data = '''$requestBody'''\n";
|
|
||||||
} else if (bodyType == ContentType.json) {
|
|
||||||
int index = requestBody.lastIndexOf("}");
|
int index = requestBody.lastIndexOf("}");
|
||||||
index--;
|
index--;
|
||||||
while (requestBody[index] == " " || requestBody[index] == "\n") {
|
while (requestBody[index] == " " || requestBody[index] == "\n") {
|
||||||
@ -68,9 +65,8 @@ main()
|
|||||||
requestBody = requestBody.substring(0, index) +
|
requestBody = requestBody.substring(0, index) +
|
||||||
requestBody.substring(index + 1);
|
requestBody.substring(index + 1);
|
||||||
}
|
}
|
||||||
requestBodyString =
|
|
||||||
"data = '''$requestBody''' \n data = json.loads(data)\n";
|
|
||||||
}
|
}
|
||||||
|
requestBodyString = "data = '''$requestBody'''";
|
||||||
}
|
}
|
||||||
|
|
||||||
var headersList = requestModel.requestHeaders;
|
var headersList = requestModel.requestHeaders;
|
||||||
|
@ -14,7 +14,6 @@ void main() {
|
|||||||
id: '',
|
id: '',
|
||||||
);
|
);
|
||||||
const expectedCode = """import requests
|
const expectedCode = """import requests
|
||||||
import json
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
url = 'https://jsonplaceholder.typicode.com/todos/1'
|
url = 'https://jsonplaceholder.typicode.com/todos/1'
|
||||||
@ -44,14 +43,11 @@ main()""";
|
|||||||
id: '1',
|
id: '1',
|
||||||
);
|
);
|
||||||
const expectedCode = """import requests
|
const expectedCode = """import requests
|
||||||
import json
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
url = 'https://jsonplaceholder.typicode.com/posts'
|
url = 'https://jsonplaceholder.typicode.com/posts'
|
||||||
|
|
||||||
data = '''{"title": "foo","body": "bar","userId": 1}'''
|
data = '''{"title": "foo","body": "bar","userId": 1}'''
|
||||||
data = json.loads(data)
|
|
||||||
|
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
"content-type": "application/json"
|
"content-type": "application/json"
|
||||||
@ -82,14 +78,11 @@ main()""";
|
|||||||
id: '1',
|
id: '1',
|
||||||
);
|
);
|
||||||
const expectedCode = """import requests
|
const expectedCode = """import requests
|
||||||
import json
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
url = 'https://jsonplaceholder.typicode.com/posts/1'
|
url = 'https://jsonplaceholder.typicode.com/posts/1'
|
||||||
|
|
||||||
data = '''{"title": "foo","body": "bar","userId": 1}'''
|
data = '''{"title": "foo","body": "bar","userId": 1}'''
|
||||||
data = json.loads(data)
|
|
||||||
|
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
"content-type": "application/json"
|
"content-type": "application/json"
|
||||||
@ -118,7 +111,6 @@ main()""";
|
|||||||
id: '1',
|
id: '1',
|
||||||
);
|
);
|
||||||
const expectedCode = """import requests
|
const expectedCode = """import requests
|
||||||
import json
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
url = 'https://jsonplaceholder.typicode.com/posts/1'
|
url = 'https://jsonplaceholder.typicode.com/posts/1'
|
||||||
@ -155,7 +147,6 @@ main()""";
|
|||||||
id: '1',
|
id: '1',
|
||||||
);
|
);
|
||||||
const expectedCode = """import requests
|
const expectedCode = """import requests
|
||||||
import json
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
url = 'https://jsonplaceholder.typicode.com/posts'
|
url = 'https://jsonplaceholder.typicode.com/posts'
|
||||||
|
Reference in New Issue
Block a user