mirror of
https://github.com/netbirdio/docs.git
synced 2026-04-16 07:26:35 +00:00
switch requests examples to version with values
This commit is contained in:
@@ -68,13 +68,13 @@ curl -X <%- operation.operation.toUpperCase() %> <%- operation.fullPath %> \\
|
||||
-H 'Accept: application/json' \\<% }; %>
|
||||
<% if(operation.requestBody?.content && operation.requestBody?.content['application/json']){ -%>
|
||||
-H 'Content-Type: application/json' \\
|
||||
--data-raw '<%- JSON.stringify(components.get(operation.requestBody?.content['application/json'].schema.$ref?.split('/').pop())?.schema, null, 2) %>'<% }; %>
|
||||
--data-raw '<%- JSON.stringify(components.get(operation.requestBody?.content['application/json'].schema.$ref?.split('/').pop())?.example, null, 2) %>'<% }; %>
|
||||
\`\`\`
|
||||
|
||||
\`\`\`js
|
||||
const axios = require('axios');
|
||||
<% if(operation.requestBody?.content && operation.requestBody?.content['application/json']){ -%>
|
||||
let data = JSON.stringify(<%- JSON.stringify(components.get(operation.requestBody?.content['application/json'].schema.$ref?.split('/').pop())?.schema, null, 2) %>);<% }; -%>
|
||||
let data = JSON.stringify(<%- JSON.stringify(components.get(operation.requestBody?.content['application/json'].schema.$ref?.split('/').pop())?.example, null, 2) %>);<% }; -%>
|
||||
|
||||
let config = {
|
||||
method: '<%- operation.operation.toLowerCase() %>',
|
||||
@@ -104,7 +104,7 @@ import json
|
||||
|
||||
url = "<%- operation.fullPath %>"
|
||||
<% if(operation.requestBody?.content && operation.requestBody?.content['application/json']){ -%>
|
||||
payload = json.dumps(<%- JSON.stringify(components.get(operation.requestBody?.content['application/json'].schema.$ref?.split('/').pop())?.schema, null, 2) %>)<% }; -%>
|
||||
payload = json.dumps(<%- JSON.stringify(components.get(operation.requestBody?.content['application/json'].schema.$ref?.split('/').pop())?.example, null, 2) %>)<% }; -%>
|
||||
|
||||
headers = {
|
||||
<% if(operation.requestBody?.content && operation.requestBody?.content['application/json']){ -%>'Content-Type': 'application/json',<% }; %>
|
||||
@@ -132,7 +132,7 @@ func main() {
|
||||
url := "<%- operation.fullPath %>"
|
||||
method := "<%- operation.operation.toUpperCase() %>"
|
||||
<% if(operation.requestBody?.content && operation.requestBody?.content['application/json']){ %>
|
||||
payload := strings.NewReader(\`<%- JSON.stringify(components.get(operation.requestBody?.content['application/json'].schema.$ref?.split('/').pop())?.schema, null, 2) %>\`)<% }; -%>
|
||||
payload := strings.NewReader(\`<%- JSON.stringify(components.get(operation.requestBody?.content['application/json'].schema.$ref?.split('/').pop())?.example, null, 2) %>\`)<% }; -%>
|
||||
|
||||
client := &http.Client {
|
||||
}
|
||||
@@ -178,7 +178,7 @@ request = Net::HTTP::<%- operation.operation.slice(0,1).toUpperCase() + operatio
|
||||
<% if(operation.responseList[0].content && operation.responseList[0].content['application/json']){ -%>request["Accept"] = "application/json"<% }; %>
|
||||
request["Authorization"] = "Token <TOKEN>"
|
||||
<% if(operation.requestBody?.content && operation.requestBody?.content['application/json']){ %>
|
||||
request.body = JSON.dump(<%- JSON.stringify(components.get(operation.requestBody?.content['application/json'].schema.$ref?.split('/').pop())?.schema, null, 2) %>)<% }; -%>
|
||||
request.body = JSON.dump(<%- JSON.stringify(components.get(operation.requestBody?.content['application/json'].schema.$ref?.split('/').pop())?.example, null, 2) %>)<% }; -%>
|
||||
|
||||
response = https.request(request)
|
||||
puts response.read_body
|
||||
@@ -189,7 +189,7 @@ OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
<% if(operation.requestBody?.content && operation.requestBody?.content['application/json']){ -%>
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
RequestBody body = RequestBody.create(mediaType, '<%- JSON.stringify(components.get(operation.requestBody?.content['application/json'].schema.$ref?.split('/').pop())?.schema, null, 2) %>');<% }; %>
|
||||
RequestBody body = RequestBody.create(mediaType, '<%- JSON.stringify(components.get(operation.requestBody?.content['application/json'].schema.$ref?.split('/').pop())?.example, null, 2) %>');<% }; %>
|
||||
Request request = new Request.Builder()
|
||||
.url("<%- operation.fullPath %>")
|
||||
.method("<%- operation.operation.toUpperCase() %>"<% if(operation.requestBody?.content && operation.requestBody?.content['application/json']){ -%>, body<% }; %>)
|
||||
@@ -215,7 +215,7 @@ curl_setopt_array($curl, array(
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => '<%- operation.operation.toUpperCase() %>',
|
||||
<% if(operation.requestBody?.content && operation.requestBody?.content['application/json']){ %>
|
||||
CURLOPT_POSTFIELDS =>'<%- JSON.stringify(components.get(operation.requestBody?.content['application/json'].schema.$ref?.split('/').pop())?.schema, null, 2) %>',<% }; %>
|
||||
CURLOPT_POSTFIELDS =>'<%- JSON.stringify(components.get(operation.requestBody?.content['application/json'].schema.$ref?.split('/').pop())?.example, null, 2) %>',<% }; %>
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
<% if(operation.requestBody?.content && operation.requestBody?.content['application/json']){ -%>'Content-Type: application/json',<% }; %>
|
||||
<% if(operation.responseList[0].content && operation.responseList[0].content['application/json']){ -%>'Accept: application/json',<% }; %>
|
||||
|
||||
Reference in New Issue
Block a user