@mintlify/msft-sdk 1.1.61 → 1.1.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api-playground/ApiPlayground/Response/DownloadFileButton.js +6 -5
- package/dist/api-playground/ApiPlayground/Response/ResponseBody/CodeResponseContent.js +13 -12
- package/dist/api-playground/ApiPlayground/Response/ResponsePlaceholder.js +8 -7
- package/dist/api-playground/ApiPlayground/Response/ResponseTable.js +3 -2
- package/dist/api-playground/ApiPlayground/Response/ResponseTopbar.js +9 -8
- package/dist/api-playground/ApiPlayground/Response/index.js +4 -3
- package/dist/api-playground/ApiPlayground/components/AdditionalPropertyButton.js +42 -21
- package/dist/api-playground/ApiPlayground/components/ParamFieldWrapper.js +13 -9
- package/dist/api-playground/ApiPlayground/components/PlaygroundModalWrapper.js +6 -5
- package/dist/api-playground/ApiPlayground/components/SendPill.js +3 -2
- package/dist/api-playground/ApiPlayground/components/TypeDropdown.js +6 -5
- package/dist/api-playground/EndpointFields/ParamFields/ExampleDescription.js +3 -2
- package/dist/api-playground/EndpointFields/components/Description.js +6 -5
- package/dist/api-playground/EndpointFields/components/OptionDropdown.js +9 -8
- package/dist/api-playground/EndpointFields/components/SectionHeading.js +8 -7
- package/dist/api-playground-2/ApiExamples.js +19 -20
- package/dist/api-playground-2/ApiFields.js +20 -247
- package/dist/api-playground-2/EndpointHeader.js +59 -47
- package/dist/api-playground-2/OperationPage.js +70 -66
- package/dist/api-playground-2/Playground.js +67 -83
- package/dist/api-playground-2/SchemaPage.js +22 -9
- package/dist/api-playground-2/components/EndpointFields/Body.js +40 -0
- package/dist/api-playground-2/components/EndpointFields/Parameters.js +90 -0
- package/dist/api-playground-2/components/EndpointFields/Response.js +146 -0
- package/dist/api-playground-2/components/EndpointFields/Security.js +88 -0
- package/dist/api-playground-2/components/EndpointFields/fields/ArrayParamField.js +93 -0
- package/dist/api-playground-2/components/EndpointFields/fields/Enum.js +29 -11
- package/dist/api-playground-2/components/EndpointFields/fields/ObjectParamField.js +145 -0
- package/dist/api-playground-2/components/EndpointFields/fields/PrimitiveParamField.js +60 -48
- package/dist/api-playground-2/components/EndpointFields/fields/SchemaField.js +230 -0
- package/dist/api-playground-2/components/Example/GeneratedRequestExample.js +93 -89
- package/dist/api-playground-2/components/Example/GeneratedResponseExample.js +18 -17
- package/dist/api-playground-2/components/Example/RequestExample.js +92 -93
- package/dist/api-playground-2/components/Example/ResponseExample.js +19 -15
- package/dist/api-playground-2/components/Request/ParameterSection.js +20 -18
- package/dist/api-playground-2/components/Request/SecuritySection.js +53 -43
- package/dist/api-playground-2/components/Request/inputs/ArrayInput.js +89 -40
- package/dist/api-playground-2/components/Request/inputs/DifferentiatedInput.js +12 -12
- package/dist/api-playground-2/components/Request/inputs/FileInput.js +16 -15
- package/dist/api-playground-2/components/Request/inputs/InputContainer.js +76 -57
- package/dist/api-playground-2/components/Request/inputs/NumberInput.js +10 -9
- package/dist/api-playground-2/components/Request/inputs/ObjectInput.js +98 -80
- package/dist/api-playground-2/components/Request/inputs/OneOfInput.js +55 -47
- package/dist/api-playground-2/components/Request/inputs/SelectInput.js +18 -17
- package/dist/api-playground-2/components/Request/inputs/StringInput.js +19 -18
- package/dist/api-playground-2/components/Request/inputs/TextInput.js +12 -11
- package/dist/api-playground-2/components/SendPillWrapper.js +35 -0
- package/dist/api-playground-2/contexts/ApiPlaygroundContext.js +3 -5
- package/dist/api-playground-2/generators/createCookies.js +23 -0
- package/dist/api-playground-2/generators/createHeaders.js +53 -36
- package/dist/api-playground-2/generators/createQueryString.js +30 -0
- package/dist/api-playground-2/generators/generateAuthPlaceholder.js +14 -0
- package/dist/api-playground-2/generators/generateInteractiveCodeSample.js +27 -25
- package/dist/api-playground-2/generators/generateRequest.js +47 -51
- package/dist/api-playground-2/generators/generateResponseExampleMap.js +15 -11
- package/dist/api-playground-2/generators/generateSnippet.js +1 -1
- package/dist/api-playground-2/generators/generateSnippetMap.js +13 -11
- package/dist/api-playground-2/hooks/useCopyPathWithInputs.js +11 -11
- package/dist/api-playground-2/hooks/useInitializeInputs.js +185 -88
- package/dist/api-playground-2/hooks/usePlaygroundInputsStore.js +70 -25
- package/dist/api-playground-2/hooks/useSelectedBaseUrl.js +13 -0
- package/dist/api-playground-2/hooks/useSelectedExample.js +10 -0
- package/dist/api-playground-2/hooks/useSelectedRequestBodyContentType.js +12 -0
- package/dist/api-playground-2/hooks/useSelectedResponseContentType.js +12 -0
- package/dist/api-playground-2/hooks/useSelectedSecurityOption.js +31 -0
- package/dist/api-playground-2/hooks/useSendPlaygroundRequest.js +114 -101
- package/dist/api-playground-2/schemaGraph/addApiReferenceDataFromMdxAndDocsConfig.js +23 -32
- package/dist/api-playground-2/schemaGraph/addTypeLabelsToSchema.js +50 -0
- package/dist/api-playground-2/schemaGraph/addUniqueKeysToSchema.js +40 -24
- package/dist/api-playground-2/schemaGraph/getExampleBodyInputs.js +94 -0
- package/dist/api-playground-2/schemaGraph/getSchemaGraphOperationData.js +56 -50
- package/dist/api-playground-2/schemaGraph/processExamples.js +117 -52
- package/dist/api-playground-2/schemaGraph/processSchema.js +10 -0
- package/dist/api-playground-2/schemaGraph/processSecurityOptions.js +58 -28
- package/dist/api-playground-2/schemaGraph/reduceCompositions.js +220 -181
- package/dist/api-playground-2/schemaGraph/resolveOperationWithDependencies.js +128 -89
- package/dist/api-playground-2/schemaGraph/resolveSchemaWithDependencies.js +15 -16
- package/dist/api-playground-2/schemaGraph/sortSchemaByRequired.js +14 -12
- package/dist/api-playground-2/schemaGraph/utils.js +185 -147
- package/dist/common/guards.js +11 -19
- package/dist/components/Api/Expandable.js +10 -9
- package/dist/components/Api/Param.js +11 -13
- package/dist/components/Api/dropdown-menu.js +10 -9
- package/dist/components/content-components/code-group.js +4 -4
- package/dist/contexts/EndpointLocationContext.js +3 -3
- package/dist/hooks/useApiParamFieldOption.js +10 -0
- package/dist/hooks/useEndpoint.js +3 -3
- package/dist/hooks/useKeyboardShortcut.js +13 -13
- package/dist/hooks/useSendPlaygroundRequest.js +14 -146
- package/dist/httpsnippet/src/helpers/code-builder.js +27 -0
- package/dist/httpsnippet/src/helpers/escape.js +11 -0
- package/dist/httpsnippet/src/helpers/headers.js +13 -0
- package/dist/httpsnippet/src/helpers/reducer.js +7 -0
- package/dist/httpsnippet/src/helpers/shell.js +5 -0
- package/dist/httpsnippet/src/helpers/url-format.js +35 -0
- package/dist/httpsnippet/src/helpers/url-parse.js +76 -0
- package/dist/httpsnippet/src/index.js +157 -0
- package/dist/httpsnippet/src/targets/c/libcurl/client.js +22 -0
- package/dist/httpsnippet/src/targets/c/target.js +15 -0
- package/dist/httpsnippet/src/targets/clojure/clj_http/client.js +120 -0
- package/dist/httpsnippet/src/targets/clojure/target.js +14 -0
- package/dist/httpsnippet/src/targets/csharp/httpclient/client.js +76 -0
- package/dist/httpsnippet/src/targets/csharp/restsharp/client.js +63 -0
- package/dist/httpsnippet/src/targets/csharp/target.js +17 -0
- package/dist/httpsnippet/src/targets/go/native/client.js +24 -0
- package/dist/httpsnippet/src/targets/go/target.js +15 -0
- package/dist/httpsnippet/src/targets/http/http1.1/client.js +34 -0
- package/dist/httpsnippet/src/targets/http/target.js +14 -0
- package/dist/httpsnippet/src/targets/index.js +43 -0
- package/dist/httpsnippet/src/targets/java/asynchttp/client.js +23 -0
- package/dist/httpsnippet/src/targets/java/nethttp/client.js +28 -0
- package/dist/httpsnippet/src/targets/java/okhttp/client.js +23 -0
- package/dist/httpsnippet/src/targets/java/target.js +20 -0
- package/dist/httpsnippet/src/targets/java/unirest/client.js +23 -0
- package/dist/httpsnippet/src/targets/javascript/axios/client.js +50 -0
- package/dist/httpsnippet/src/targets/javascript/fetch/client.js +61 -0
- package/dist/httpsnippet/src/targets/javascript/jquery/client.js +51 -0
- package/dist/httpsnippet/src/targets/javascript/target.js +20 -0
- package/dist/httpsnippet/src/targets/javascript/xhr/client.js +49 -0
- package/dist/httpsnippet/src/targets/json/native/client.js +39 -0
- package/dist/httpsnippet/src/targets/json/target.js +14 -0
- package/dist/httpsnippet/src/targets/kotlin/okhttp/client.js +23 -0
- package/dist/httpsnippet/src/targets/kotlin/target.js +14 -0
- package/dist/httpsnippet/src/targets/node/axios/client.js +40 -0
- package/dist/httpsnippet/src/targets/node/fetch/client.js +68 -0
- package/dist/httpsnippet/src/targets/node/native/client.js +45 -0
- package/dist/httpsnippet/src/targets/node/target.js +19 -0
- package/dist/httpsnippet/src/targets/objc/helpers.js +27 -0
- package/dist/httpsnippet/src/targets/objc/nsurlsession/client.js +63 -0
- package/dist/httpsnippet/src/targets/objc/target.js +14 -0
- package/dist/httpsnippet/src/targets/ocaml/cohttp/client.js +32 -0
- package/dist/httpsnippet/src/targets/ocaml/target.js +14 -0
- package/dist/httpsnippet/src/targets/php/curl/client.js +85 -0
- package/dist/httpsnippet/src/targets/php/guzzle/client.js +57 -0
- package/dist/httpsnippet/src/targets/php/helpers.js +65 -0
- package/dist/httpsnippet/src/targets/php/http1/client.js +28 -0
- package/dist/httpsnippet/src/targets/php/http2/client.js +55 -0
- package/dist/httpsnippet/src/targets/php/target.js +21 -0
- package/dist/httpsnippet/src/targets/powershell/common.js +19 -0
- package/dist/httpsnippet/src/targets/powershell/restmethod/client.js +14 -0
- package/dist/httpsnippet/src/targets/powershell/target.js +16 -0
- package/dist/httpsnippet/src/targets/powershell/webrequest/client.js +14 -0
- package/dist/httpsnippet/src/targets/python/helpers.js +33 -0
- package/dist/httpsnippet/src/targets/python/requests/client.js +74 -0
- package/dist/httpsnippet/src/targets/python/target.js +15 -0
- package/dist/httpsnippet/src/targets/r/httr/client.js +46 -0
- package/dist/httpsnippet/src/targets/r/target.js +14 -0
- package/dist/httpsnippet/src/targets/ruby/native/client.js +37 -0
- package/dist/httpsnippet/src/targets/ruby/target.js +14 -0
- package/dist/httpsnippet/src/targets/shell/curl/client.js +92 -0
- package/dist/httpsnippet/src/targets/shell/httpie/client.js +56 -0
- package/dist/httpsnippet/src/targets/shell/target.js +19 -0
- package/dist/httpsnippet/src/targets/shell/wget/client.js +30 -0
- package/dist/httpsnippet/src/targets/swift/helpers.js +38 -0
- package/dist/httpsnippet/src/targets/swift/target.js +14 -0
- package/dist/httpsnippet/src/targets/swift/urlsession/client.js +59 -0
- package/dist/index.d.ts +65 -58
- package/dist/index.js +109 -111
- package/dist/openapi/generateTypeStringFromSchema.js +2 -31
- package/dist/styles.css +1 -1
- package/package.json +17 -4
- package/dist/api-playground/ApiPlayground/Request/BodySection.js +0 -64
- package/dist/api-playground/ApiPlayground/Request/ParameterSection.js +0 -32
- package/dist/api-playground/ApiPlayground/Request/PlaygroundModal.js +0 -201
- package/dist/api-playground/ApiPlayground/Request/SecuritySection.js +0 -146
- package/dist/api-playground/ApiPlayground/Request/ServerSection.js +0 -30
- package/dist/api-playground/ApiPlayground/Request/index.js +0 -43
- package/dist/api-playground/ApiPlayground/Request/inputs/ArrayInput.js +0 -93
- package/dist/api-playground/ApiPlayground/Request/inputs/DifferentiatedInput.js +0 -90
- package/dist/api-playground/ApiPlayground/Request/inputs/FileInput.js +0 -62
- package/dist/api-playground/ApiPlayground/Request/inputs/NullInput.js +0 -33
- package/dist/api-playground/ApiPlayground/Request/inputs/NumberInput.js +0 -61
- package/dist/api-playground/ApiPlayground/Request/inputs/ObjectChildren.js +0 -109
- package/dist/api-playground/ApiPlayground/Request/inputs/ObjectInput.js +0 -87
- package/dist/api-playground/ApiPlayground/Request/inputs/RecursiveInput.js +0 -61
- package/dist/api-playground/ApiPlayground/Request/inputs/SelectInput.js +0 -54
- package/dist/api-playground/ApiPlayground/Request/inputs/StringInput.js +0 -67
- package/dist/api-playground/ApiPlayground/Request/inputs/TextInput.js +0 -44
- package/dist/api-playground/ApiPlayground/components/EndpointsMenu.js +0 -42
- package/dist/api-playground/ApiPlayground/components/EndpointsMenuLink.js +0 -43
- package/dist/api-playground/ApiPlayground/components/EndpointsMenuSearch.js +0 -38
- package/dist/api-playground/ApiPlayground/components/InputContainer.js +0 -128
- package/dist/api-playground/ApiPlayground/components/InputSectionContainer.js +0 -59
- package/dist/api-playground/ApiPlayground/components/PathHeader.js +0 -162
- package/dist/api-playground/ApiPlayground/components/TrashButton.js +0 -26
- package/dist/api-playground/ApiPlayground/index.js +0 -67
- package/dist/api-playground/EndpointFields/ParamFields/PrimitiveParamField/Enum.js +0 -19
- package/dist/api-playground/EndpointFields/ParamFields/PrimitiveParamField/NumberMetadata.js +0 -18
- package/dist/api-playground/EndpointFields/ParamFields/PrimitiveParamField/StringMetadata.js +0 -28
- package/dist/api-playground/EndpointFields/ParamFields/PrimitiveParamField/index.js +0 -5
- package/dist/api-playground/EndpointFields/ParamFields/RecursiveParamField.js +0 -13
- package/dist/api-playground/EndpointFields/index.js +0 -7
- package/dist/api-playground-2/components/EndpointFields/EndpointSecurity.js +0 -87
- package/dist/api-playground-2/components/EndpointFields/fields/SimpleArrayParamField.js +0 -89
- package/dist/api-playground-2/components/EndpointFields/fields/SimpleObjectParamField.js +0 -121
- package/dist/api-playground-2/components/EndpointFields/fields/SimplePrimitiveParamField.js +0 -74
- package/dist/api-playground-2/components/EndpointFields/fields/SimpleSchemaField.js +0 -252
- package/dist/common/potentiallyParseOpenApiString.js +0 -24
- package/dist/common/replaceSlashIndex.js +0 -6
- package/dist/common/slugToTitle.js +0 -10
- package/dist/constants/prism-languages.js +0 -19
- package/dist/contexts/ApiPlaygroundInputsContext.js +0 -17
- package/dist/contexts/MDXContentContext.js +0 -17
- package/dist/hooks/useApiPlaygroundInputs.js +0 -6
- package/dist/hooks/useApiPlaygroundPrefillExamples.js +0 -39
- package/dist/hooks/useBaseUrlOptions.js +0 -18
- package/dist/hooks/useComponentSchemas.js +0 -9
- package/dist/hooks/useGenerateNextAdditionalProperties.js +0 -11
- package/dist/hooks/useGenerateNextItems.js +0 -11
- package/dist/hooks/useGenerateNextProperties.js +0 -11
- package/dist/hooks/useMDXContent.js +0 -6
- package/dist/hooks/useMDXContentController/useApiPlaygroundInputs.js +0 -9
- package/dist/hooks/useMDXContentController/useMDXContentCallbacks/useSetApiBaseIndexCallback.js +0 -15
- package/dist/hooks/useMDXContentController/useMDXContentCallbacks/useSetApiPlaygroundInputsCallback.js +0 -15
- package/dist/hooks/usePlaygroundSchemaOptions.js +0 -42
- package/dist/hooks/usePrefilledInputs/index.js +0 -65
- package/dist/hooks/usePrefilledInputs/storedServerVariables.js +0 -29
- package/dist/hooks/useSecurityOption.js +0 -10
- package/dist/hooks/useSetDefaultValue.js +0 -63
- package/dist/openapi/filterEnums.js +0 -20
- package/dist/openapi/generateNextAdditionalProperties.js +0 -7
- package/dist/openapi/generateNextItems.js +0 -7
- package/dist/openapi/generateNextProperties.js +0 -23
- package/dist/openapi/generateOptionLabels.js +0 -20
- package/dist/openapi/generateSimpleLabels.js +0 -4
- package/dist/openapi/getAuthFilteredSchemaArray.js +0 -18
- package/dist/paths/isEqualIgnoringLeadingSlash.js +0 -21
- package/dist/paths/optionallyRemoveLeadingSlash.js +0 -6
- package/dist/paths/optionallyRemoveTrailingSlash.js +0 -6
- package/dist/utils/api-playground/defaults.js +0 -15
- package/dist/utils/api-playground/paramFieldDefaults.js +0 -10
- package/dist/utils/api-reference/getFilteredSecurityOptions.js +0 -4
- package/dist/utils/api-reference/getNextPropertiesByType.js +0 -5
- package/dist/utils/flattenObject.js +0 -10
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { CodeBuilder as u } from "../../../helpers/code-builder.js";
|
|
2
|
+
import { escapeForDoubleQuotes as p } from "../../../helpers/escape.js";
|
|
3
|
+
const T = {
|
|
4
|
+
info: {
|
|
5
|
+
key: "libcurl",
|
|
6
|
+
title: "Libcurl",
|
|
7
|
+
link: "http://curl.haxx.se/libcurl",
|
|
8
|
+
description: "Simple REST and HTTP API Client for C",
|
|
9
|
+
extname: ".c"
|
|
10
|
+
},
|
|
11
|
+
convert: ({ method: l, fullUrl: n, headersObj: r, allHeaders: s, postData: o }) => {
|
|
12
|
+
const { push: e, blank: t, join: _ } = new u();
|
|
13
|
+
e("CURL *hnd = curl_easy_init();"), t(), e(`curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "${l.toUpperCase()}");`), e("curl_easy_setopt(hnd, CURLOPT_WRITEDATA, stdout);"), e(`curl_easy_setopt(hnd, CURLOPT_URL, "${n}");`);
|
|
14
|
+
const c = Object.keys(r);
|
|
15
|
+
return c.length && (t(), e("struct curl_slist *headers = NULL;"), c.forEach((i) => {
|
|
16
|
+
e(`headers = curl_slist_append(headers, "${i}: ${p(r[i])}");`);
|
|
17
|
+
}), e("curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);")), s.cookie && (t(), e(`curl_easy_setopt(hnd, CURLOPT_COOKIE, "${s.cookie}");`)), o.text && (t(), e(`curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, ${JSON.stringify(o.text)});`)), t(), e("CURLcode ret = curl_easy_perform(hnd);"), _();
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
export {
|
|
21
|
+
T as libcurl
|
|
22
|
+
};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { CodeBuilder as b } from "../../../helpers/code-builder.js";
|
|
2
|
+
import { getHeaderName as o, getHeader as y } from "../../../helpers/headers.js";
|
|
3
|
+
class m {
|
|
4
|
+
constructor(t) {
|
|
5
|
+
this.name = "", this.toString = () => `:${this.name}`, this.name = t;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
class w {
|
|
9
|
+
constructor(t) {
|
|
10
|
+
this.path = "", this.toString = () => `(clojure.java.io/file "${this.path}")`, this.path = t;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
const g = (e) => e === void 0 ? null : e === null ? "null" : e.constructor.name.toLowerCase(), j = (e) => e === void 0 ? !0 : g(e) === "object" ? Object.keys(e).length === 0 : !1, f = (e) => (Object.keys(e).filter((t) => j(e[t])).forEach((t) => {
|
|
14
|
+
delete e[t];
|
|
15
|
+
}), e), l = (e, t) => {
|
|
16
|
+
const c = " ".repeat(e);
|
|
17
|
+
return t.replace(/\n/g, `
|
|
18
|
+
${c}`);
|
|
19
|
+
}, p = (e) => {
|
|
20
|
+
switch (g(e)) {
|
|
21
|
+
case "string":
|
|
22
|
+
return `"${e.replace(/"/g, '\\"')}"`;
|
|
23
|
+
case "file":
|
|
24
|
+
return e.toString();
|
|
25
|
+
case "keyword":
|
|
26
|
+
return e.toString();
|
|
27
|
+
case "null":
|
|
28
|
+
return "nil";
|
|
29
|
+
case "regexp":
|
|
30
|
+
return `#"${e.source}"`;
|
|
31
|
+
case "object": {
|
|
32
|
+
const t = Object.keys(e).reduce((c, a) => {
|
|
33
|
+
const d = l(a.length + 2, p(e[a]));
|
|
34
|
+
return `${c}:${a} ${d}
|
|
35
|
+
`;
|
|
36
|
+
}, "").trim();
|
|
37
|
+
return `{${l(1, t)}}`;
|
|
38
|
+
}
|
|
39
|
+
case "array": {
|
|
40
|
+
const t = e.reduce((c, a) => `${c} ${p(a)}`, "").trim();
|
|
41
|
+
return `[${l(1, t)}]`;
|
|
42
|
+
}
|
|
43
|
+
default:
|
|
44
|
+
return e.toString();
|
|
45
|
+
}
|
|
46
|
+
}, x = {
|
|
47
|
+
info: {
|
|
48
|
+
key: "clj_http",
|
|
49
|
+
title: "clj-http",
|
|
50
|
+
link: "https://github.com/dakrone/clj-http",
|
|
51
|
+
description: "An idiomatic clojure http client wrapping the apache client.",
|
|
52
|
+
extname: ".clj"
|
|
53
|
+
},
|
|
54
|
+
convert: ({ queryObj: e, method: t, postData: c, url: a, allHeaders: d }, h) => {
|
|
55
|
+
const { push: i, join: u } = new b({ indent: h == null ? void 0 : h.indent }), $ = ["get", "post", "put", "delete", "patch", "head", "options"];
|
|
56
|
+
if (t = t.toLowerCase(), !$.includes(t))
|
|
57
|
+
return i("Method not supported"), u();
|
|
58
|
+
const r = {
|
|
59
|
+
headers: d,
|
|
60
|
+
"query-params": e
|
|
61
|
+
};
|
|
62
|
+
switch (c.mimeType) {
|
|
63
|
+
case "application/json":
|
|
64
|
+
{
|
|
65
|
+
r["content-type"] = new m("json"), r["form-params"] = c.jsonObj;
|
|
66
|
+
const n = o(r.headers, "content-type");
|
|
67
|
+
n && delete r.headers[n];
|
|
68
|
+
}
|
|
69
|
+
break;
|
|
70
|
+
case "application/x-www-form-urlencoded":
|
|
71
|
+
{
|
|
72
|
+
r["form-params"] = c.paramsObj;
|
|
73
|
+
const n = o(r.headers, "content-type");
|
|
74
|
+
n && delete r.headers[n];
|
|
75
|
+
}
|
|
76
|
+
break;
|
|
77
|
+
case "text/plain":
|
|
78
|
+
{
|
|
79
|
+
r.body = c.text;
|
|
80
|
+
const n = o(r.headers, "content-type");
|
|
81
|
+
n && delete r.headers[n];
|
|
82
|
+
}
|
|
83
|
+
break;
|
|
84
|
+
case "multipart/form-data": {
|
|
85
|
+
if (c.params) {
|
|
86
|
+
r.multipart = c.params.map((s) => s.fileName && !s.value ? {
|
|
87
|
+
name: s.name,
|
|
88
|
+
content: new w(s.fileName)
|
|
89
|
+
} : {
|
|
90
|
+
name: s.name,
|
|
91
|
+
content: s.value
|
|
92
|
+
});
|
|
93
|
+
const n = o(r.headers, "content-type");
|
|
94
|
+
n && delete r.headers[n];
|
|
95
|
+
}
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
switch (y(r.headers, "accept")) {
|
|
100
|
+
case "application/json":
|
|
101
|
+
{
|
|
102
|
+
r.accept = new m("json");
|
|
103
|
+
const n = o(r.headers, "accept");
|
|
104
|
+
n && delete r.headers[n];
|
|
105
|
+
}
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
if (i(`(require '[clj-http.client :as client])
|
|
109
|
+
`), j(f(r)))
|
|
110
|
+
i(`(client/${t} "${a}")`);
|
|
111
|
+
else {
|
|
112
|
+
const n = 11 + t.length + a.length, s = l(n, p(f(r)));
|
|
113
|
+
i(`(client/${t} "${a}" ${s})`);
|
|
114
|
+
}
|
|
115
|
+
return u();
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
export {
|
|
119
|
+
x as clj_http
|
|
120
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { CodeBuilder as g } from "../../../helpers/code-builder.js";
|
|
2
|
+
import { escapeForDoubleQuotes as m } from "../../../helpers/escape.js";
|
|
3
|
+
import { getHeader as y } from "../../../helpers/headers.js";
|
|
4
|
+
const H = (i) => {
|
|
5
|
+
let n = y(i, "accept-encoding");
|
|
6
|
+
if (!n)
|
|
7
|
+
return [];
|
|
8
|
+
const t = {
|
|
9
|
+
gzip: "DecompressionMethods.GZip",
|
|
10
|
+
deflate: "DecompressionMethods.Deflate"
|
|
11
|
+
}, r = [];
|
|
12
|
+
return typeof n == "string" && (n = [n]), n.forEach((a) => {
|
|
13
|
+
a.split(",").forEach((p) => {
|
|
14
|
+
const e = /\s*([^;\s]+)/.exec(p);
|
|
15
|
+
if (e) {
|
|
16
|
+
const c = t[e[1]];
|
|
17
|
+
c && r.push(c);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}), r;
|
|
21
|
+
}, M = {
|
|
22
|
+
info: {
|
|
23
|
+
key: "httpclient",
|
|
24
|
+
title: "HttpClient",
|
|
25
|
+
link: "https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient",
|
|
26
|
+
description: ".NET Standard HTTP Client",
|
|
27
|
+
extname: ".cs"
|
|
28
|
+
},
|
|
29
|
+
convert: ({ allHeaders: i, postData: n, method: t, fullUrl: r }, a) => {
|
|
30
|
+
var C, h;
|
|
31
|
+
const p = {
|
|
32
|
+
indent: " ",
|
|
33
|
+
...a
|
|
34
|
+
}, { push: e, join: c } = new g({ indent: p.indent });
|
|
35
|
+
e("using System.Net.Http.Headers;");
|
|
36
|
+
let d = "";
|
|
37
|
+
const f = !!i.cookie, l = H(i);
|
|
38
|
+
(f || l.length) && (d = "clientHandler", e("var clientHandler = new HttpClientHandler"), e("{"), f && e("UseCookies = false,", 1), l.length && e(`AutomaticDecompression = ${l.join(" | ")},`, 1), e("};")), e(`var client = new HttpClient(${d});`), e("var request = new HttpRequestMessage"), e("{");
|
|
39
|
+
const w = ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS", "TRACE"];
|
|
40
|
+
t = t.toUpperCase(), t && w.includes(t) ? t = `HttpMethod.${t[0]}${t.substring(1).toLowerCase()}` : t = `new HttpMethod("${t}")`, e(`Method = ${t},`, 1), e(`RequestUri = new Uri("${r}"),`, 1);
|
|
41
|
+
const u = Object.keys(i).filter((s) => {
|
|
42
|
+
switch (s.toLowerCase()) {
|
|
43
|
+
case "content-type":
|
|
44
|
+
case "content-length":
|
|
45
|
+
case "accept-encoding":
|
|
46
|
+
return !1;
|
|
47
|
+
default:
|
|
48
|
+
return !0;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
if (u.length && (e("Headers =", 1), e("{", 1), u.forEach((s) => {
|
|
52
|
+
e(`{ "${s}", "${m(i[s])}" },`, 2);
|
|
53
|
+
}), e("},", 1)), n.text) {
|
|
54
|
+
const s = n.mimeType;
|
|
55
|
+
switch (s) {
|
|
56
|
+
case "application/x-www-form-urlencoded":
|
|
57
|
+
e("Content = new FormUrlEncodedContent(new Dictionary<string, string>", 1), e("{", 1), (C = n.params) == null || C.forEach((o) => {
|
|
58
|
+
e(`{ "${o.name}", "${o.value}" },`, 2);
|
|
59
|
+
}), e("}),", 1);
|
|
60
|
+
break;
|
|
61
|
+
case "multipart/form-data":
|
|
62
|
+
e("Content = new MultipartFormDataContent", 1), e("{", 1), (h = n.params) == null || h.forEach((o) => {
|
|
63
|
+
e(`new StringContent(${JSON.stringify(o.value || "")})`, 2), e("{", 2), e("Headers =", 3), e("{", 3), o.contentType && e(`ContentType = new MediaTypeHeaderValue("${o.contentType}"),`, 4), e('ContentDisposition = new ContentDispositionHeaderValue("form-data")', 4), e("{", 4), e(`Name = "${o.name}",`, 5), o.fileName && e(`FileName = "${o.fileName}",`, 5), e("}", 4), e("}", 3), e("},", 2);
|
|
64
|
+
}), e("},", 1);
|
|
65
|
+
break;
|
|
66
|
+
default:
|
|
67
|
+
e(`Content = new StringContent(${JSON.stringify(n.text || "")})`, 1), e("{", 1), e("Headers =", 2), e("{", 2), e(`ContentType = new MediaTypeHeaderValue("${s}")`, 3), e("}", 2), e("}", 1);
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return e("};"), e("using (var response = await client.SendAsync(request))"), e("{"), e("response.EnsureSuccessStatusCode();", 1), e("var body = await response.Content.ReadAsStringAsync();", 1), e("Console.WriteLine(body);", 1), e("}"), c();
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
export {
|
|
75
|
+
M as httpclient
|
|
76
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { CodeBuilder as m } from "../../../helpers/code-builder.js";
|
|
2
|
+
import { escapeForDoubleQuotes as a } from "../../../helpers/escape.js";
|
|
3
|
+
function p(n) {
|
|
4
|
+
return n[0].toUpperCase() + n.slice(1).toLowerCase();
|
|
5
|
+
}
|
|
6
|
+
const T = {
|
|
7
|
+
info: {
|
|
8
|
+
key: "restsharp",
|
|
9
|
+
title: "RestSharp",
|
|
10
|
+
link: "http://restsharp.org/",
|
|
11
|
+
description: "Simple REST and HTTP API Client for .NET",
|
|
12
|
+
extname: ".cs",
|
|
13
|
+
installation: () => "dotnet add package RestSharp"
|
|
14
|
+
},
|
|
15
|
+
convert: ({ method: n, fullUrl: d, headersObj: i, cookies: u, postData: e, uriObj: s }) => {
|
|
16
|
+
const { push: t, join: l } = new m();
|
|
17
|
+
if (!["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"].includes(
|
|
18
|
+
n.toUpperCase()
|
|
19
|
+
))
|
|
20
|
+
return "Method not supported";
|
|
21
|
+
t(`using RestSharp;
|
|
22
|
+
|
|
23
|
+
`), t(`var options = new RestClientOptions("${d}");`), t("var client = new RestClient(options);"), t('var request = new RestRequest("");');
|
|
24
|
+
const o = e.mimeType && e.mimeType === "multipart/form-data";
|
|
25
|
+
switch (o && t("request.AlwaysMultipartFormData = true;"), Object.keys(i).forEach((r) => {
|
|
26
|
+
if (e.mimeType && r.toLowerCase() === "content-type" && e.text) {
|
|
27
|
+
o && e.boundary && t(`request.FormBoundary = "${e.boundary}";`);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
t(`request.AddHeader("${r}", "${a(i[r])}");`);
|
|
31
|
+
}), u.forEach(({ name: r, value: c }) => {
|
|
32
|
+
t(`request.AddCookie("${r}", "${a(c)}", "${s.pathname}", "${s.host}");`);
|
|
33
|
+
}), e.mimeType) {
|
|
34
|
+
case "multipart/form-data":
|
|
35
|
+
if (!e.params) break;
|
|
36
|
+
e.params.forEach((r) => {
|
|
37
|
+
r.fileName ? t(`request.AddFile("${r.name}", "${r.fileName}");`) : t(`request.AddParameter("${r.name}", "${r.value}");`);
|
|
38
|
+
});
|
|
39
|
+
break;
|
|
40
|
+
case "application/x-www-form-urlencoded":
|
|
41
|
+
if (!e.params) break;
|
|
42
|
+
e.params.forEach((r) => {
|
|
43
|
+
t(`request.AddParameter("${r.name}", "${r.value}");`);
|
|
44
|
+
});
|
|
45
|
+
break;
|
|
46
|
+
case "application/json": {
|
|
47
|
+
if (!e.text) break;
|
|
48
|
+
const r = JSON.stringify(e.text);
|
|
49
|
+
t(`request.AddJsonBody(${r}, false);`);
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
default:
|
|
53
|
+
if (!e.text) break;
|
|
54
|
+
t(`request.AddStringBody("${e.text}", "${e.mimeType}");`);
|
|
55
|
+
}
|
|
56
|
+
return t(`var response = await client.${p(n)}Async(request);
|
|
57
|
+
`), t(`Console.WriteLine("{0}", response.Content);
|
|
58
|
+
`), l();
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
export {
|
|
62
|
+
T as restsharp
|
|
63
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { httpclient as t } from "./httpclient/client.js";
|
|
2
|
+
import { restsharp as r } from "./restsharp/client.js";
|
|
3
|
+
const p = {
|
|
4
|
+
info: {
|
|
5
|
+
key: "csharp",
|
|
6
|
+
title: "C#",
|
|
7
|
+
default: "restsharp",
|
|
8
|
+
cli: "dotnet"
|
|
9
|
+
},
|
|
10
|
+
clientsById: {
|
|
11
|
+
httpclient: t,
|
|
12
|
+
restsharp: r
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
p as csharp
|
|
17
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { CodeBuilder as q } from "../../../helpers/code-builder.js";
|
|
2
|
+
import { escapeForDoubleQuotes as k } from "../../../helpers/escape.js";
|
|
3
|
+
const C = {
|
|
4
|
+
info: {
|
|
5
|
+
key: "native",
|
|
6
|
+
title: "NewRequest",
|
|
7
|
+
link: "http://golang.org/pkg/net/http/#NewRequest",
|
|
8
|
+
description: "Golang HTTP client request",
|
|
9
|
+
extname: ".go"
|
|
10
|
+
},
|
|
11
|
+
convert: ({ postData: n, method: u, allHeaders: o, fullUrl: m }, g = {}) => {
|
|
12
|
+
const { blank: i, push: e, join: $ } = new q({ indent: " " }), { showBoilerplate: s = !0, checkErrors: a = !1, printBody: l = !0, timeout: c = -1 } = g, r = a ? "err" : "_", t = s ? 1 : 0, f = () => {
|
|
13
|
+
a && (e("if err != nil {", t), e("panic(err)", t + 1), e("}", t));
|
|
14
|
+
};
|
|
15
|
+
s && (e("package main"), i(), e("import ("), e('"fmt"', t), c > 0 && e('"time"', t), n.text && e('"strings"', t), e('"net/http"', t), l && e('"io"', t), e(")"), i(), e("func main() {"), i());
|
|
16
|
+
const p = c > 0, d = p, y = d ? "client" : "http.DefaultClient";
|
|
17
|
+
return d && (e("client := http.Client{", t), p && e(`Timeout: time.Duration(${c} * time.Second),`, t + 1), e("}", t), i()), e(`url := "${m}"`, t), i(), n.text ? (e(`payload := strings.NewReader(${JSON.stringify(n.text)})`, t), i(), e(`req, ${r} := http.NewRequest("${u}", url, payload)`, t), i()) : (e(`req, ${r} := http.NewRequest("${u}", url, nil)`, t), i()), f(), Object.keys(o).length && (Object.keys(o).forEach((h) => {
|
|
18
|
+
e(`req.Header.Add("${h}", "${k(o[h])}")`, t);
|
|
19
|
+
}), i()), e(`res, ${r} := ${y}.Do(req)`, t), f(), l && (i(), e("defer res.Body.Close()", t), e(`body, ${r} := io.ReadAll(res.Body)`, t), f()), i(), l && e("fmt.Println(string(body))", t), s && (i(), e("}")), $();
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
C as native
|
|
24
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { CodeBuilder as m } from "../../../helpers/code-builder.js";
|
|
2
|
+
const i = `\r
|
|
3
|
+
`, y = {
|
|
4
|
+
info: {
|
|
5
|
+
key: "http1.1",
|
|
6
|
+
title: "HTTP/1.1",
|
|
7
|
+
link: "https://tools.ietf.org/html/rfc7230",
|
|
8
|
+
description: "HTTP/1.1 request string in accordance with RFC 7230",
|
|
9
|
+
extname: null
|
|
10
|
+
},
|
|
11
|
+
convert: ({ method: h, fullUrl: a, uriObj: c, httpVersion: l, allHeaders: r, postData: n }, u) => {
|
|
12
|
+
const o = {
|
|
13
|
+
absoluteURI: !1,
|
|
14
|
+
autoContentLength: !0,
|
|
15
|
+
autoHost: !0,
|
|
16
|
+
...u
|
|
17
|
+
}, { blank: g, push: t, join: p } = new m({ indent: "", join: i }), d = o.absoluteURI ? a : c.path;
|
|
18
|
+
t(`${h} ${d} ${l}`);
|
|
19
|
+
const s = Object.keys(r);
|
|
20
|
+
if (s.forEach((e) => {
|
|
21
|
+
const C = e.toLowerCase().replace(/(^|-)(\w)/g, (L) => L.toUpperCase());
|
|
22
|
+
t(`${C}: ${r[e]}`);
|
|
23
|
+
}), o.autoHost && !s.includes("host") && t(`Host: ${c.host}`), o.autoContentLength && n.text && !s.includes("content-length")) {
|
|
24
|
+
const e = Buffer.byteLength(n.text, "ascii").toString();
|
|
25
|
+
t(`Content-Length: ${e}`);
|
|
26
|
+
}
|
|
27
|
+
g();
|
|
28
|
+
const f = p(), $ = n.text || "";
|
|
29
|
+
return `${f}${i}${$}`;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
export {
|
|
33
|
+
y as http11
|
|
34
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { c as o } from "./c/target.js";
|
|
2
|
+
import { clojure as r } from "./clojure/target.js";
|
|
3
|
+
import { csharp as m } from "./csharp/target.js";
|
|
4
|
+
import { go as t } from "./go/target.js";
|
|
5
|
+
import { http as p } from "./http/target.js";
|
|
6
|
+
import { java as i } from "./java/target.js";
|
|
7
|
+
import { javascript as f } from "./javascript/target.js";
|
|
8
|
+
import { json as s } from "./json/target.js";
|
|
9
|
+
import { kotlin as a } from "./kotlin/target.js";
|
|
10
|
+
import { node as c } from "./node/target.js";
|
|
11
|
+
import { objc as e } from "./objc/target.js";
|
|
12
|
+
import { ocaml as l } from "./ocaml/target.js";
|
|
13
|
+
import { php as h } from "./php/target.js";
|
|
14
|
+
import { powershell as j } from "./powershell/target.js";
|
|
15
|
+
import { python as n } from "./python/target.js";
|
|
16
|
+
import { r as b } from "./r/target.js";
|
|
17
|
+
import { ruby as g } from "./ruby/target.js";
|
|
18
|
+
import { shell as u } from "./shell/target.js";
|
|
19
|
+
import { swift as v } from "./swift/target.js";
|
|
20
|
+
const M = {
|
|
21
|
+
c: o,
|
|
22
|
+
clojure: r,
|
|
23
|
+
csharp: m,
|
|
24
|
+
go: t,
|
|
25
|
+
http: p,
|
|
26
|
+
java: i,
|
|
27
|
+
javascript: f,
|
|
28
|
+
json: s,
|
|
29
|
+
kotlin: a,
|
|
30
|
+
node: c,
|
|
31
|
+
objc: e,
|
|
32
|
+
ocaml: l,
|
|
33
|
+
php: h,
|
|
34
|
+
powershell: j,
|
|
35
|
+
python: n,
|
|
36
|
+
r: b,
|
|
37
|
+
ruby: g,
|
|
38
|
+
shell: u,
|
|
39
|
+
swift: v
|
|
40
|
+
};
|
|
41
|
+
export {
|
|
42
|
+
M as targets
|
|
43
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CodeBuilder as a } from "../../../helpers/code-builder.js";
|
|
2
|
+
import { escapeForDoubleQuotes as y } from "../../../helpers/escape.js";
|
|
3
|
+
const d = {
|
|
4
|
+
info: {
|
|
5
|
+
key: "asynchttp",
|
|
6
|
+
title: "AsyncHttp",
|
|
7
|
+
link: "https://github.com/AsyncHttpClient/async-http-client",
|
|
8
|
+
description: "Asynchronous Http and WebSocket Client library for Java",
|
|
9
|
+
extname: ".java"
|
|
10
|
+
},
|
|
11
|
+
convert: ({ method: i, allHeaders: e, postData: n, fullUrl: c }, s) => {
|
|
12
|
+
const p = {
|
|
13
|
+
indent: " ",
|
|
14
|
+
...s
|
|
15
|
+
}, { blank: r, push: t, join: l } = new a({ indent: p.indent });
|
|
16
|
+
return t("AsyncHttpClient client = new DefaultAsyncHttpClient();"), t(`client.prepare("${i.toUpperCase()}", "${c}")`), Object.keys(e).forEach((o) => {
|
|
17
|
+
t(`.setHeader("${o}", "${y(e[o])}")`, 1);
|
|
18
|
+
}), n.text && t(`.setBody(${JSON.stringify(n.text)})`, 1), t(".execute()", 1), t(".toCompletableFuture()", 1), t(".thenAccept(System.out::println)", 1), t(".join();", 1), r(), t("client.close();"), l();
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
d as asynchttp
|
|
23
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { CodeBuilder as u } from "../../../helpers/code-builder.js";
|
|
2
|
+
import { escapeForDoubleQuotes as a } from "../../../helpers/escape.js";
|
|
3
|
+
const c = {
|
|
4
|
+
info: {
|
|
5
|
+
key: "nethttp",
|
|
6
|
+
title: "java.net.http",
|
|
7
|
+
link: "https://openjdk.java.net/groups/net/httpclient/intro.html",
|
|
8
|
+
description: "Java Standardized HTTP Client API",
|
|
9
|
+
extname: ".java"
|
|
10
|
+
},
|
|
11
|
+
convert: ({ allHeaders: e, fullUrl: r, method: n, postData: o }, i) => {
|
|
12
|
+
const p = {
|
|
13
|
+
indent: " ",
|
|
14
|
+
...i
|
|
15
|
+
}, { push: t, join: d } = new u({ indent: p.indent });
|
|
16
|
+
return t("HttpRequest request = HttpRequest.newBuilder()"), t(`.uri(URI.create("${r}"))`, 2), Object.keys(e).forEach((s) => {
|
|
17
|
+
t(`.header("${s}", "${a(e[s])}")`, 2);
|
|
18
|
+
}), o.text ? t(
|
|
19
|
+
`.method("${n.toUpperCase()}", HttpRequest.BodyPublishers.ofString(${JSON.stringify(o.text)}))`,
|
|
20
|
+
2
|
|
21
|
+
) : t(`.method("${n.toUpperCase()}", HttpRequest.BodyPublishers.noBody())`, 2), t(".build();", 2), t(
|
|
22
|
+
"HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());"
|
|
23
|
+
), t("System.out.println(response.body());"), d();
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
export {
|
|
27
|
+
c as nethttp
|
|
28
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CodeBuilder as T } from "../../../helpers/code-builder.js";
|
|
2
|
+
import { escapeForDoubleQuotes as c } from "../../../helpers/escape.js";
|
|
3
|
+
const b = {
|
|
4
|
+
info: {
|
|
5
|
+
key: "okhttp",
|
|
6
|
+
title: "OkHttp",
|
|
7
|
+
link: "http://square.github.io/okhttp/",
|
|
8
|
+
description: "An HTTP Request Client Library",
|
|
9
|
+
extname: ".java"
|
|
10
|
+
},
|
|
11
|
+
convert: ({ postData: t, method: i, fullUrl: s, allHeaders: n }, p) => {
|
|
12
|
+
const d = {
|
|
13
|
+
indent: " ",
|
|
14
|
+
...p
|
|
15
|
+
}, { push: e, blank: o, join: u } = new T({ indent: d.indent }), l = ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD"], y = ["POST", "PUT", "DELETE", "PATCH"];
|
|
16
|
+
return e("OkHttpClient client = new OkHttpClient();"), o(), t.text && (t.boundary ? e(`MediaType mediaType = MediaType.parse("${t.mimeType}; boundary=${t.boundary}");`) : e(`MediaType mediaType = MediaType.parse("${t.mimeType}");`), e(`RequestBody body = RequestBody.create(mediaType, ${JSON.stringify(t.text)});`)), e("Request request = new Request.Builder()"), e(`.url("${s}")`, 1), l.includes(i.toUpperCase()) ? y.includes(i.toUpperCase()) ? t.text ? e(`.${i.toLowerCase()}(body)`, 1) : e(`.${i.toLowerCase()}(null)`, 1) : e(`.${i.toLowerCase()}()`, 1) : t.text ? e(`.method("${i.toUpperCase()}", body)`, 1) : e(`.method("${i.toUpperCase()}", null)`, 1), Object.keys(n).forEach((r) => {
|
|
17
|
+
e(`.addHeader("${r}", "${c(n[r])}")`, 1);
|
|
18
|
+
}), e(".build();", 1), o(), e("Response response = client.newCall(request).execute();"), u();
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
b as okhttp
|
|
23
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { asynchttp as t } from "./asynchttp/client.js";
|
|
2
|
+
import { nethttp as o } from "./nethttp/client.js";
|
|
3
|
+
import { okhttp as r } from "./okhttp/client.js";
|
|
4
|
+
import { unirest as i } from "./unirest/client.js";
|
|
5
|
+
const n = {
|
|
6
|
+
info: {
|
|
7
|
+
key: "java",
|
|
8
|
+
title: "Java",
|
|
9
|
+
default: "unirest"
|
|
10
|
+
},
|
|
11
|
+
clientsById: {
|
|
12
|
+
asynchttp: t,
|
|
13
|
+
nethttp: o,
|
|
14
|
+
okhttp: r,
|
|
15
|
+
unirest: i
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
n as java
|
|
20
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CodeBuilder as u } from "../../../helpers/code-builder.js";
|
|
2
|
+
import { escapeForDoubleQuotes as a } from "../../../helpers/escape.js";
|
|
3
|
+
const m = {
|
|
4
|
+
info: {
|
|
5
|
+
key: "unirest",
|
|
6
|
+
title: "Unirest",
|
|
7
|
+
link: "http://unirest.io/java.html",
|
|
8
|
+
description: "Lightweight HTTP Request Client Library",
|
|
9
|
+
extname: ".java"
|
|
10
|
+
},
|
|
11
|
+
convert: ({ method: t, allHeaders: n, postData: s, fullUrl: i }, r) => {
|
|
12
|
+
const p = {
|
|
13
|
+
indent: " ",
|
|
14
|
+
...r
|
|
15
|
+
}, { join: c, push: e } = new u({ indent: p.indent });
|
|
16
|
+
return ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"].includes(t.toUpperCase()) ? e(`HttpResponse<String> response = Unirest.${t.toLowerCase()}("${i}")`) : e(`HttpResponse<String> response = Unirest.customMethod("${t.toUpperCase()}","${i}")`), Object.keys(n).forEach((o) => {
|
|
17
|
+
e(`.header("${o}", "${a(n[o])}")`, 1);
|
|
18
|
+
}), s.text && e(`.body(${JSON.stringify(s.text)})`, 1), e(".asString();", 1), c();
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
m as unirest
|
|
23
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import h from "stringify-object";
|
|
2
|
+
import { CodeBuilder as x } from "../../../helpers/code-builder.js";
|
|
3
|
+
const u = {
|
|
4
|
+
info: {
|
|
5
|
+
key: "axios",
|
|
6
|
+
title: "Axios",
|
|
7
|
+
link: "https://github.com/axios/axios",
|
|
8
|
+
description: "Promise based HTTP client for the browser and node.js",
|
|
9
|
+
extname: ".js",
|
|
10
|
+
installation: () => "npm install axios --save"
|
|
11
|
+
},
|
|
12
|
+
convert: ({ allHeaders: s, method: t, url: c, queryObj: i, postData: o }, m) => {
|
|
13
|
+
const d = {
|
|
14
|
+
indent: " ",
|
|
15
|
+
...m
|
|
16
|
+
}, { blank: a, push: e, join: f, addPostProcessor: l } = new x({ indent: d.indent });
|
|
17
|
+
e("import axios from 'axios';"), a();
|
|
18
|
+
const r = {
|
|
19
|
+
method: t,
|
|
20
|
+
url: c
|
|
21
|
+
};
|
|
22
|
+
switch (Object.keys(i).length && (r.params = i), Object.keys(s).length && (r.headers = s), o.mimeType) {
|
|
23
|
+
case "application/x-www-form-urlencoded":
|
|
24
|
+
o.params && (e("const encodedParams = new URLSearchParams();"), o.params.forEach((n) => {
|
|
25
|
+
e(`encodedParams.set('${n.name}', '${n.value}');`);
|
|
26
|
+
}), a(), r.data = "encodedParams,", l((n) => n.replace(/'encodedParams,'/, "encodedParams,")));
|
|
27
|
+
break;
|
|
28
|
+
case "application/json":
|
|
29
|
+
o.jsonObj && (r.data = o.jsonObj);
|
|
30
|
+
break;
|
|
31
|
+
case "multipart/form-data":
|
|
32
|
+
if (!o.params)
|
|
33
|
+
break;
|
|
34
|
+
e("const form = new FormData();"), o.params.forEach((n) => {
|
|
35
|
+
e(`form.append('${n.name}', '${n.value || n.fileName || ""}');`);
|
|
36
|
+
}), a(), r.data = "[form]";
|
|
37
|
+
break;
|
|
38
|
+
default:
|
|
39
|
+
o.text && (r.data = o.text);
|
|
40
|
+
}
|
|
41
|
+
const p = h(r, {
|
|
42
|
+
indent: " ",
|
|
43
|
+
inlineCharacterLimit: 80
|
|
44
|
+
}).replace('"[form]"', "form");
|
|
45
|
+
return e(`const options = ${p};`), a(), e("axios"), e(".request(options)", 1), e(".then(res => console.log(res.data))", 1), e(".catch(err => console.error(err));", 1), f();
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
export {
|
|
49
|
+
u as axios
|
|
50
|
+
};
|