add code generation
This commit is contained in:
1 parent
7b8ac91183
commit
8f8e291188
14 files changed
+362
-35
No files matched your search
@@ -0,0 +1,17 @@
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
{{#body}}
|
||||
jsonObject.put("{{{key}}}", "{{{value}}}");
|
||||
{{/body}}
|
||||
MediaType mediaType = "application/json; charset=utf-8".toMediaType();
|
||||
RequestBody body = jsonObject.toString().toRequestBody(mediaType);
|
||||
Request request = new Request.Builder()
|
||||
.url("{{{url}}}")
|
||||
.{{{method}}}(body)
|
||||
{{#headers}}
|
||||
.addHeader("{{{key}}}", "{{{value}}}")
|
||||
{{/headers}}
|
||||
.build();
|
||||
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
Response response = client.newCall(request).execute();
|
||||
System.out.print(response.body!!.string())
|
||||
@@ -0,0 +1,18 @@
|
||||
const options = {
|
||||
method: '{{{method}}}',
|
||||
headers: {
|
||||
{{#headers}}
|
||||
'{{{key}}}': '{{{value}}}'{{^last}},{{/last}}
|
||||
{{/headers}}
|
||||
},
|
||||
body: JSON.stringify({
|
||||
{{#body}}
|
||||
{{{key}}}: '{{{value}}}'{{^last}},{{/last}}
|
||||
{{/body}}
|
||||
})
|
||||
};
|
||||
|
||||
fetch('{{{url}}}', options)
|
||||
.then(response => response.json())
|
||||
.then(response => console.log(response))
|
||||
.catch(err => console.error(err));
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
require_once('vendor/autoload.php');
|
||||
|
||||
$client = new \GuzzleHttp\Client();
|
||||
|
||||
$response = $client->request('{{{method}}}', '{{{url}}}', [
|
||||
'body' => '{
|
||||
{{#body}}
|
||||
"{{{key}}}": "{{{value}}}"{{^last}},{{/last}}
|
||||
{{/body}}
|
||||
}',
|
||||
'headers' => [
|
||||
{{#headers}}
|
||||
'{{{key}}}': '{{{value}}}'{{^last}},{{/last}}
|
||||
{{/headers}}
|
||||
],
|
||||
]);
|
||||
|
||||
echo $response->getBody();
|
||||
@@ -0,0 +1,18 @@
|
||||
import requests
|
||||
|
||||
url = "{{{url}}}"
|
||||
|
||||
headers = {
|
||||
{{#headers}}
|
||||
'{{{key}}}': '{{{value}}}'{{^last}},{{/last}}
|
||||
{{/headers}}
|
||||
}
|
||||
|
||||
payload = {
|
||||
{{#body}}
|
||||
'{{{key}}}': '{{{value}}}'{{^last}},{{/last}}
|
||||
{{/body}}
|
||||
}
|
||||
|
||||
response = requests.{{{method}}}}(url, json=payload, headers=headers)
|
||||
print(response.text)
|
||||
Reference in new issue
Block a user