@redocly/openapi-docs 3.14.0-next.12 → 3.14.0-next.14
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/redocly-openapi-docs.min.js +1618 -1583
- package/lib/components/ContentItem/ContentItem.js +1 -1
- package/lib/components/RedoclyOpenAPIDocs/Error.d.ts +3 -0
- package/lib/components/RedoclyOpenAPIDocs/Error.js +25 -0
- package/lib/components/RedoclyOpenAPIDocs/RedoclyOpenAPIDocsStandalone.js +1 -1
- package/lib/components/Security/OAuthFlow.js +1 -1
- package/lib/components/Security/SecurityButton.js +14 -7
- package/lib/components/Security/SecurityFlow.d.ts +1 -1
- package/lib/components/Security/SecurityFlow.js +10 -5
- package/lib/components/ServerList/ServerDescriptionTooltip.d.ts +4 -0
- package/lib/components/ServerList/ServerDescriptionTooltip.js +1 -0
- package/lib/components/ServerList/ServerList.js +14 -9
- package/lib/components/ServerListDropdown/ServerListDropdown.js +1 -1
- package/lib/services/code-samples/generator.d.ts +9 -2
- package/lib/services/code-samples/generator.js +1 -1
- package/lib/services/code-samples/httpsnippet/helpers/device-auth-snippets.d.ts +25 -0
- package/lib/services/code-samples/httpsnippet/helpers/device-auth-snippets.js +1 -0
- package/lib/services/code-samples/httpsnippet/targets/csharp/httpclient.js +2 -2
- package/lib/services/code-samples/httpsnippet/targets/csharpNewtonsoft/httpclient.js +2 -2
- package/lib/services/code-samples/httpsnippet/targets/go/native.js +3 -3
- package/lib/services/code-samples/httpsnippet/targets/java/httpclient.js +3 -3
- package/lib/services/code-samples/httpsnippet/targets/java8/apachehttp.js +2 -2
- package/lib/services/code-samples/httpsnippet/targets/javascript/fetch.js +1 -1
- package/lib/services/code-samples/httpsnippet/targets/node/fetch.js +1 -1
- package/lib/services/code-samples/httpsnippet/targets/php/curl.js +5 -5
- package/lib/services/code-samples/httpsnippet/targets/python/requests.js +5 -5
- package/lib/services/code-samples/httpsnippet/targets/r/httr.js +1 -1
- package/lib/services/code-samples/httpsnippet/targets/ruby/native.js +1 -1
- package/lib/services/code-samples/httpsnippet/targets/shell/curl.js +7 -6
- package/lib/standalone.js +1 -1
- package/lib/types/open-api.d.ts +10 -0
- package/lib/utils/helpers.d.ts +2 -0
- package/lib/utils/helpers.js +4 -4
- package/lib/utils/loadAndBundleSpec.js +1 -1
- package/package.json +4 -3
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{CodeBuilder as
|
|
2
|
-
`).forEach(a=>{const s=a.replace(/"/g,'\\"');e.push(3,`"${s}", `)}),e.push(2,");"),e.push(2,"%s.setEntity(new StringEntity(payload));",e.var("request")));break}return p.withWrapper&&(e.push(2,`String ${e.var("response")} = EntityUtils.toString(httpClient.execute(request).getEntity());`),e.blank(),e.push(2,"System.out.println(response);"),e.push(1,"}"),e.push("}")),e.join();function o(a,s){for(const[r,u]of Object.entries(a))l(u)?(e.push(s,'.put("%s", new JSONObject()',r),o(u,s+1),e.push(s,")")):e.push(s,'.put("%s", %s)',r,m(u))}},
|
|
1
|
+
import{CodeBuilder as d}from"../../helpers/code-builder.js";import{HTTPSnippet as j}from"../../index.js";import{isEmptyObject as y,normalizeMimeType as w}from"../../../../utils.js";import{capitalizeFirst as A}from"../../../generator.js";import{Lang as C}from"../../helpers/constants.js";import{buildUrlExpression as v,printUrlVariablesDeclarations as N}from"../../helpers/code-helpers.js";import{MediaTypes as n}from"../../../../../constants.js";import{buildJava8DeviceAuthorizationCodeSnippet as k}from"../../helpers/device-auth-snippets.js";const x=function(t,i,{target:h,client:E}){const p=Object.assign({indent:" ",withWrapper:!0},i),e=new d({indentation:p.indent,variablesPrefix:p.variablesPrefix,capitalize:!0,lang:C.JAVA8}),c=O(t.method);if(p.withComments&&D(e),p.withImports&&L(e,t),p.withWrapper&&(e.push("public class App {"),e.push(1,"public static void main(String[] args ) throws java.io.IOException {"),e.push(2,"HttpClient httpClient = HttpClientBuilder.create().build();"),e.blank()),t.securityOAuth2ExtraCalls?.length){const a=t.securityOAuth2ExtraCalls?.[0],s=new j(a).convert(h,E,{...p,withImports:!1,withWrapper:!1,withComments:!1,variablesPrefix:"oauth2"});e.push(s),e.push(2,"JSONObject %s = new JSONObject(EntityUtils.toString(httpClient.execute(%s).getEntity()));","oauth2Response","oauth2Request"),a.flowType==="deviceAuthorization"?k(e,{tokenUrl:a.tokenUrl??"YOUR_TOKEN_URL",clientId:a.clientId??"YOUR_CLIENT_ID",level:2}):(e.push(2,'String accessToken = %s.getString("access_token");',"oauth2Response"),e.blank())}N(t,e,2);const S=v(t,e);e.push(2,`%s ${e.var("request")} = new %s(%s);`,c,c,S);const f=Object.keys(t.allHeaders);if(f.length&&!(t.postData&&t.postData.mimeType==n.MULTIPART)&&f.forEach(a=>{const s=a.toLowerCase()==="authorization";e.push(2,'%s.setHeader("%s", %s);',e.var("request"),a,t.securityOAuth2ExtraCalls?.length&&s?'"Bearer " + accessToken':`"${t.allHeaders[a]}"`)}),t.basicAuth){const{username:a,password:s}=t.basicAuth;e.push(2,`String encodedString = Base64.getEncoder().encodeToString("${a}:${s}".getBytes());`),e.push(2,'%s.setHeader("%s", "%s"+encodedString);',e.var("request"),"Authorization","Basic ")}if(t.postData)switch(w(t.postData.mimeType)){case n.URL_ENCODED:t.postData.params&&(e.blank(),e.push(2,"List<NameValuePair> params = new ArrayList<NameValuePair>();"),t.postData.params.forEach(a=>{e.push(2,'params.add(new BasicNameValuePair("%s", "%s"));',a.name,a.value)}),e.push(2,"%s.setEntity(new UrlEncodedFormEntity(params));",e.var("request")),e.blank());break;case n.MULTIPART:t.postData.params&&(e.push(2,"MultipartEntity reqEntity = new MultipartEntity();"),t.postData.params.forEach(a=>{e.push(2,'reqEntity.addPart("%s", %s);',a.name,b(a.value)?`new StringBody("${a.value}")`:a.value)}),e.push(2,"%s.setEntity(reqEntity);",e.var("request")));break;case n.JSON:if(t.postData.jsonObj){e.push(2,"JSONObject payload = new JSONObject();");for(const[a,s]of Object.entries(t.postData.jsonObj))Array.isArray(s)?(e.push(2,'payload.put("%s", new JSONArray()',a),s.forEach(r=>{l(r)?(e.push(3,".put(new JSONObject()"),o(r,4),e.push(3,")")):e.push(3,".put(%s)",m(r))}),e.push(2,");")):l(s)?(e.push(2,'payload.put("%s", new JSONObject()%s',a,y(s)?");":""),o(s,3),y(s)||e.push(2,");")):e.push(2,'payload.put("%s", %s);',a,m(s));e.push(2,"%s.setEntity(new StringEntity(payload.toString()));",e.var("request"))}break;case n.XML:t.postData.text&&(e.push(2,'String payload = String.join("\\n"'),t.postData.text.trim().split(`
|
|
2
|
+
`).forEach(a=>{const s=a.replace(/"/g,'\\"');e.push(3,`"${s}", `)}),e.push(2,");"),e.push(2,"%s.setEntity(new StringEntity(payload));",e.var("request")));break}return p.withWrapper&&(e.push(2,`String ${e.var("response")} = EntityUtils.toString(httpClient.execute(request).getEntity());`),e.blank(),e.push(2,"System.out.println(response);"),e.push(1,"}"),e.push("}")),e.join();function o(a,s){for(const[r,u]of Object.entries(a))l(u)?(e.push(s,'.put("%s", new JSONObject()',r),o(u,s+1),e.push(s,")")):e.push(s,'.put("%s", %s)',r,m(u))}},I={key:"apachehttp",title:"Apache http",link:"https://hc.apache.org/httpcomponents-client-4.5.x/",description:"Apache HttpClient"};var M=x;function D(t){t.push("/**"),t.push(" * Requires JDK >= 8"),t.push(" *"),t.push(" * Requires Apache HttpComponents Client >= 4.3.5"),t.push(" * See here for installation details:"),t.push(" * https://search.maven.org/artifact/org.apache.httpcomponents/httpcomponents-client"),t.push(" *"),t.push(' * Requires package "junit4"'),t.push(" * See here for installation details:"),t.push(" * https://junit.org/junit4"),t.push(" *"),t.push(' * Requires package "org.json" >= 20180130'),t.push(" * See here for installation details:"),t.push(" * https://search.maven.org/artifact/org.json/json"),t.push(" */"),t.blank()}function L(t,i){t.push("import org.apache.http.util.EntityUtils;"),t.push("import org.apache.http.NameValuePair;"),t.push("import org.apache.http.client.HttpClient;"),t.push("import org.apache.http.client.entity.UrlEncodedFormEntity;"),i.method&&g(t,i.method),i.securityOAuth2ExtraCalls?.length&&i.securityOAuth2ExtraCalls?.[0].method.toLowerCase()!==i.method.toLowerCase()&&g(t,i.securityOAuth2ExtraCalls?.[0].method),t.push("import org.apache.http.impl.client.HttpClientBuilder;"),t.push("import org.apache.http.message.BasicNameValuePair;"),t.push("import org.apache.http.entity.StringEntity;"),t.push("import org.json.JSONObject;"),t.push("import org.json.JSONArray;"),t.push("import java.util.ArrayList;"),t.push("import java.util.List;"),t.push("import org.apache.http.entity.mime.MultipartEntity;"),t.push("import org.apache.http.entity.mime.content.StringBody;"),i.basicAuth&&t.push("import java.util.Base64;"),t.blank()}function g(t,i){const h=O(i);t.push(`import org.apache.http.client.methods.${h};`)}function O(t){return"Http"+A(t.toLowerCase())}function b(t){return Object.prototype.toString.call(t)==="[object String]"}function l(t){const i=typeof t;return i==="function"||i==="object"&&!!t}function m(t){return b(t)?JSON.stringify(t):t??"JSONObject.NULL"}export{M as default,I as info};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import r from"stringify-object";import{CodeBuilder as v}from"../../helpers/code-builder.js";import{addIndentation as o,getPreserveTransformer as
|
|
1
|
+
import r from"stringify-object";import{CodeBuilder as v}from"../../helpers/code-builder.js";import{addIndentation as o,getPreserveTransformer as O,buildUrlExpression as y,printUrlVariablesDeclarations as $}from"../../helpers/code-helpers.js";import{normalizeMimeType as h}from"../../../../utils.js";import{HTTPSnippet as A}from"../../index.js";import{Lang as D}from"../../helpers/constants.js";import{MediaTypes as s}from"../../../../../constants.js";import{buildJSDeviceAuthorizationCodeSnippet as g}from"../../helpers/device-auth-snippets.js";const C=function(t,m,{target:c,client:u}){const i={indent:" ",credentials:null,...m},e=new v({indentation:i.indent,variablesPrefix:i.variablesPrefix,capitalize:!0,lang:D.JAVASCRIPT}),a={method:t.method.toUpperCase()};Object.keys(t.headersObj).length&&(a.headers=t.headersObj);let l=!1;if(i.withComments&&j(e),t.securityOAuth2ExtraCalls?.length){const n=t.securityOAuth2ExtraCalls?.[0],p=new A(n).convert(c,u,{...i,withImports:!1,withComments:!1,variablesPrefix:"oAuth2"});e.push(p),e.blank(),n.flowType==="deviceAuthorization"&&g(e,{tokenUrl:n.tokenUrl??"YOUR_TOKEN_URL",clientId:n.clientId??"YOUR_CLIENT_ID",level:0}),a.headers=a.headers||{},a.headers.Authorization="'Bearer ' + accessToken",l=!0}i.credentials!==null&&(a.credentials=i.credentials);const d=Object.getOwnPropertyNames(t.queryObj).length;if(d&&e.push(`const ${e.var("query")} = new URLSearchParams(${r(t.queryObj,{indent:i.indent,inlineCharacterLimit:25})}).toString();`).blank(),t.postData)switch(h(t.postData.mimeType)){case s.URL_ENCODED:a.body=t.postData.paramsObj?`new URLSearchParams(${e.var("formData")}).toString()`:t.postData.text,t.postData.paramsObj&&e.push(`const ${e.var("formData")} = ${o(r(t.postData.paramsObj,{indent:i.indent,inlineCharacterLimit:25}),{level:0,firstLine:!1})};`).blank();break;case s.JSON:t.postData.jsonObj&&(a.body=`JSON.stringify(${o(r(t.postData.jsonObj,{indent:i.indent,inlineCharacterLimit:25}),{level:1,firstLine:!1})})`);break;case s.MULTIPART:e.push(`const ${e.var("form")} = new FormData();`),delete a?.headers?.["Content-Type"],t.postData.params.forEach(function(n){e.push(`${e.var("form")}.append(%s, %s);`,JSON.stringify(n.name),JSON.stringify(n.value||n.fileName||""))}),a.body=e.var("form"),e.blank();break;default:t.postData.text&&(a.body=`\`${o(t.postData.text,{level:2,indent:i.indent,firstLine:!1}).trim()}\``)}const f=a.headers&&a.headers.Accept&&h(a.headers.Accept)===s.JSON||h(t.postData?.mimeType)===s.JSON;if(t.basicAuth){const{username:n,password:p}=t.basicAuth;a.headers=a.headers||{},a.headers.Authorization=`'Basic ' + btoa('${n}:${p}')`,l=!0}$(t,e);const b=y(t,e);return e.push(`const ${e.var("resp")} = await fetch(`).push(1,"`"+b+(d?"?${"+e.var("query")+"}":"")+"`,").push(o(r(a,{indent:i.indent,inlineCharacterLimit:25,transform:O({body:!0,authorizationHeader:l})}),{level:1,indent:i.indent})).push(");").blank(),t.allResponseCodes?.includes("204")?(e.push("if (resp.status === 204) {").push(1,"console.log('success');").push("} else {"),e.push(1,`const ${e.var("data")} = await ${e.var("resp")}.${f?"json()":"text()"};`).push(1,`console.log(${e.var("data")});`).push("}")):e.push(`const ${e.var("data")} = await ${e.var("resp")}.${f?"json()":"text()"};`).push(`console.log(${e.var("data")});`),e.join()};function j(t){t.push("/**"),t.push(" * Requires ES8-compatible browser: https://caniuse.com/async-functions"),t.push(" */"),t.blank()}const N={key:"fetch",title:"fetch",link:"https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch",description:"Perform asynchronous HTTP requests with the Fetch API"};var I=C;export{I as default,N as info};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import p from"stringify-object";import{CodeBuilder as y}from"../../helpers/code-builder.js";import{addIndentation as o,getPreserveTransformer as w,buildUrlExpression as k,printUrlVariablesDeclarations as D}from"../../helpers/code-helpers.js";import{Lang as $}from"../../helpers/constants.js";import{normalizeMimeType as f}from"../../../../utils.js";import{HTTPSnippet as g}from"../../index.js";import{MediaTypes as l}from"../../../../../constants.js";import{buildJSDeviceAuthorizationCodeSnippet as j}from"../../helpers/device-auth-snippets.js";const C=function(t,u,{target:b,client:v}){const s=Object.assign({indent:" ",showBoilerplate:!0,level:1},u),{level:a}=s;let d=!1;const e=new y({indentation:s.indent,variablesPrefix:s.variablesPrefix,capitalize:!0,lang:$.NODEJS});s.withComments&&S(e),s.withImports&&(e.push("import fetch from 'node-fetch';"),e.blank()),s.showBoilerplate&&e.push("async function run() {");const i={method:t.method.toUpperCase()};Object.keys(t.headersObj).length&&(i.headers=t.headersObj);let h=!1;if(t.securityOAuth2ExtraCalls?.length){const n=t.securityOAuth2ExtraCalls?.[0],r=new g(n).convert(b,v,{...s,withImports:!1,withComments:!1,variablesPrefix:"oAuth2",showBoilerplate:!1,level:1});e.push(r),e.blank(),n.flowType==="deviceAuthorization"&&j(e,{tokenUrl:n.tokenUrl??"YOUR_TOKEN_URL",clientId:n.clientId??"YOUR_CLIENT_ID",level:a}),i.headers=i.headers||{},i.headers.Authorization="'Bearer ' + accessToken",h=!0}const m=Object.getOwnPropertyNames(t.queryObj).length;if(m&&e.push(a,`const ${e.var("query")} = new URLSearchParams(${o(p(t.queryObj,{indent:s.indent,inlineCharacterLimit:25}),{level:a,indent:s.indent,firstLine:!1})}).toString();`).blank(),t.postData)switch(f(t.postData.mimeType)){case l.URL_ENCODED:i.body=t.postData.paramsObj?`new URLSearchParams(${e.var("formData")}).toString()`:t.postData.text,t.postData.paramsObj&&e.push(a,`const ${e.var("formData")} = ${o(p(t.postData.paramsObj,{indent:s.indent,inlineCharacterLimit:25}),{level:a,firstLine:!1})};`).blank();break;case l.JSON:t.postData.jsonObj&&(i.body=`JSON.stringify(${o(p(t.postData.jsonObj,{indent:s.indent,inlineCharacterLimit:25}),{level:a,firstLine:!1})})`);break;case l.MULTIPART:delete i?.headers?.["Content-Type"],s.withImports&&e.unshift("import FormData from 'form-data';"),e.push(a,`const ${e.var("form")} = new FormData();`),t.postData.params.forEach(function(n){if(!n.fileName&&!n.fileName&&!n.contentType){e.push(a,"form.append('"+n.name+"','"+n.value+"');");return}n.fileName&&(d=!0,e.blank(),e.push(a,`${e.var("form")}.append('" + param.name + "', fs.createReadStream('" + param.fileName + "'));`))}),i.body=e.var("form"),e.blank();break;default:t.postData.text&&(i.body=`\`${o(t.postData.text,{level:a+1,indent:s.indent,firstLine:!1}).trim()}\``)}if(t.cookies.length){let n="";t.cookies.forEach(function(r){n=n+encodeURIComponent(r.name)+"="+encodeURIComponent(r.value)+"; "}),n=n.trim(),i.headers||(i.headers={}),i.headers.cookie=n}if(t.basicAuth){const{username:n,password:r}=t.basicAuth;i.headers=i.headers||{},i.headers.Authorization=`'Basic ' + Buffer.from('${n}:${r}').toString('base64')`,h=!0}d&&s.withImports&&e.unshift("import fs from 'fs';");const c=i.headers&&i.headers.Accept&&f(i.headers.Accept)===l.JSON||f(t.postData?.mimeType)===l.JSON;D(t,e,a);const O=k(t,e);return e.push(a,`const ${e.var("resp")} = await fetch(`).push(a+1,"`"+O+(m?"?${"+e.var("query")+"}":"")+"`,").push(a+1,o(p(i,{indent:s.indent,inlineCharacterLimit:25,transform:w({body:!0,authorizationHeader:h})}),{level:a+1,indent:s.indent,firstLine:!1})).push(a,");").blank(),t.allResponseCodes?.includes("204")?(e.push(a,"if (resp.status === 204) {").push(a+1,"console.log('success');").push(a,"} else {"),e.push(a+1,`const ${e.var("data")} = await ${e.var("resp")}.${c?"json()":"text()"};`).push(a+1,`console.log(${e.var("data")});`).push(a,"}")):e.push(a,`const ${e.var("data")} = await ${e.var("resp")}.${c?"json()":"text()"};`).push(a,`console.log(${e.var("data")});`),s.showBoilerplate&&e.push("}").blank().push("run();"),e.join().replace(/"fs\.createReadStream\(\\"(.+)\\"\)"/,'fs.createReadStream("$1")')};function S(t){t.push("/**"),t.push(" * Requires Node.js >= 14"),t.push(" *"),t.push(' * Requires module "node-fetch" >= 2.6.1'),t.push(" * See here for installation details:"),t.push(" * https://www.npmjs.com/package/node-fetch"),t.push(" */"),t.blank()}const E={key:"fetch",title:"Fetch",link:"https://github.com/bitinn/node-fetch",description:"Simplified HTTP node-fetch client"};var P=C;export{P as default,E as info};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{format as
|
|
2
|
-
`).join("");
|
|
3
|
-
${e});`).blank();break}case T.URL_ENCODED:{const e=a.postData.params.map(({name:
|
|
4
|
-
${
|
|
5
|
-
`+
|
|
1
|
+
import{format as m}from"util";import{CodeBuilder as P}from"../../helpers/code-builder.js";import{HTTPSnippet as v}from"../../index.js";import{Lang as _}from"../../helpers/constants.js";import{buildUrlExpression as E,printUrlVariablesDeclarations as g}from"../../helpers/code-helpers.js";import{startCase as j}from"../../helpers/lodash-int.js";import{normalizeMimeType as A}from"../../../../utils.js";import{MediaTypes as T}from"../../../../../constants.js";import{objectToPhpArray as R}from"./utils.js";import{buildPHPDeviceAuthorizationCodeSnippet as L}from"../../helpers/device-auth-snippets.js";function b(a,c){return c?`$${c}${j(a)}`:`$${a}`}const x=function(a,c,{target:U,client:k}){const n={showBoilerplate:!0,checkErrors:!1,printBody:!0,indent:" ",noTags:!0,shortTags:!1,maxRedirects:10,namedErrors:!1,closingTag:!1,...c};let i,h=!1;const t=new P({indentation:n.indent,capitalize:!0,lang:_.PHP}),r=a.securityOAuth2ExtraCalls?.[0],o=b("curl",n.variablesPrefix),y=b("response",n.variablesPrefix),d=b("error",n.variablesPrefix);if(n.noTags||t.push(n.shortTags?"<?":"<?php").blank(),r){const e="oAuth2",s=new v(r).convert(U,k,{...n,showBoilerplate:!1,variablesPrefix:e});t.push(s),t.blank(),r.flowType==="deviceAuthorization"&&L(t,{tokenUrl:r.tokenUrl??"YOUR_TOKEN_URL",clientId:r.clientId??"YOUR_CLIENT_ID",level:0});const u=r.flowType==="deviceAuthorization"?"$accessToken":`${b("response",e)}->access_token`;a.allHeaders.Authorization=`Bearer " . ${u}`}const $=Object.keys(a.headersObj).sort().map(function(e){return e==="Authorization"&&r?m('"%s: %s',e,a.allHeaders.Authorization):m('"%s: %s"',e,a.headersObj[e])});if(a.basicAuth){const{username:e,password:s}=a.basicAuth;$.push(`"Authorization: Basic " . base64_encode("${e}:${s}")`)}n.showBoilerplate&&t.push("/**").push(" * Requires libcurl").push(" */").blank(),g(a,t);let l="";if(Object.keys(a.queryObj||{}).length){const e=R(a.queryObj||{},{indent:n.indent});l="$query",t.push(`${l} = ${e};`).blank()}if(t.push(`${o} = curl_init();`),t.blank(),a.postData)switch(A(a.postData.mimeType)){case T.JSON:{const e=R(a.postData.jsonObj||{},{indent:n.indent});h=!0,i="json_encode($payload)",t.push(`$payload = ${e};`).blank();break}case T.MULTIPART:{const e=a.postData.params.map(({name:s,value:u})=>`${n.indent}"${s}" => "${u}",
|
|
2
|
+
`).join("");h=!0,i="$payload",t.push(`$payload = array(
|
|
3
|
+
${e});`).blank();break}case T.URL_ENCODED:{const e=a.postData.params.map(({name:s,value:u})=>`${s}=${u}`).join("&");h=!0,i="$payload",t.push(`$payload = "${e}";`).blank();break}default:i=a.postData.text;break}let p=E(a,t);l&&(p.endsWith('"')?p=p.slice(0,-1)+`?" . http_build_query(${l})`:p+=` . "?" . http_build_query(${l})`);const C=[{escape:!h,name:"CURLOPT_POSTFIELDS",value:i},{escape:!0,name:"CURLOPT_PORT",value:a.uriObj.port},{escape:!1,name:"CURLOPT_URL",value:p},{escape:!1,name:"CURLOPT_RETURNTRANSFER",value:"true"},{escape:!0,name:"CURLOPT_CUSTOMREQUEST",value:a.method.toUpperCase()}];t.push(`curl_setopt_array(${o}, [`);const f=new P({indentation:n.indent,lineJoin:`
|
|
4
|
+
${n.indent}`,variablesPrefix:n.variablesPrefix,capitalize:!0,lang:_.PHP});$.length&&f.push("CURLOPT_HTTPHEADER => [").push(1,$.join(`,
|
|
5
|
+
`+n.indent+n.indent)).push("],"),C.forEach(function(e){[null,void 0,""].includes(e.value)||f.push(m("%s => %s,",e.name,e.escape?JSON.stringify(e.value):e.value))});const O=a.cookies.map(function(e){return encodeURIComponent(e.name)+"="+encodeURIComponent(e.value)});return O.length&&f.push(m('CURLOPT_COOKIE => "%s",',O.join("; "))),t.push(1,f.join()).push("]);").blank().push(`${y} = curl_exec(${o});`).push(`${d} = curl_error(${o});`).blank().push(`curl_close(${o});`).blank().push(`if (${d}) {`),n.namedErrors?t.push(1,`echo array_flip(get_defined_constants(true)["curl"])[${d}];`):t.push(1,`echo "cURL Error #:" . ${d};`),t.push("} else {").push(1,`echo ${y};`).push("}"),!n.noTags&&n.closingTag&&t.blank().push("?>"),t.join()},M={key:"curl",title:"cURL",link:"http://php.net/manual/en/book.curl.php",description:"PHP with ext-curl"};var F=x;export{F as default,M as info};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{format as
|
|
2
|
-
${
|
|
1
|
+
import{format as D}from"util";import{CodeBuilder as k}from"../../helpers/code-builder.js";import{normalizeMimeType as T}from"../../../../utils.js";import{addIndentation as L,buildUrlExpression as j,printUrlVariablesDeclarations as A}from"../../helpers/code-helpers.js";import{HTTPSnippet as x}from"../../index.js";import{Lang as E}from"../../helpers/constants.js";import{MediaTypes as l}from"../../../../../constants.js";import{buildPythonDeviceAuthorizationCodeSnippet as R}from"../../helpers/device-auth-snippets.js";const g=function(e,d,{target:w,client:m}){const s=Object.assign({indent:" "},d),{level:f=0}=s,t=new k({indentation:s.indent,variablesPrefix:s.variablesPrefix,lang:E.PYTHON}),O=e.securityOAuth2ExtraCalls?.some(a=>a.flowType==="deviceAuthorization");s.withComments&&q(t),s.withImports&&(t.push("import requests"),O&&t.push("import time"),t.blank());let y=!1,i=e.allHeaders;if(e.securityOAuth2ExtraCalls?.length){const a=e.securityOAuth2ExtraCalls?.[0],n=new x(a).convert(w,m,{...s,withImports:!1,withComments:!1,variablesPrefix:"oauth2_"});t.push(n),t.blank(),a.flowType==="deviceAuthorization"&&R(t,{tokenUrl:a.tokenUrl??"YOUR_TOKEN_URL",clientId:a.clientId??"YOUR_CLIENT_ID",level:f}),i=i||{},i.Authorization='"Bearer " + access_token',y=!0}A(e,t),t.push(`${t.var("url").toLowerCase()} = %s`,j(e,t)).blank();let b;Object.keys(e.queryObj||{}).length&&(b="query = "+_(e.queryObj,s.indent),t.push(b).blank());let p,h;const C=T(e.postData?.mimeType);if(e.postData)switch(C){case l.URL_ENCODED:p=e.postData.paramsObj?`${L(_(e.postData.paramsObj,s.indent),{level:0,firstLine:!1})}`:e.postData.text;break;case l.JSON:e.postData.jsonObj&&(p=L(_(e.postData.jsonObj,s.indent),{level:0,firstLine:!1}));break;case l.MULTIPART:const a=[];if(e.postData.params)for(const n of e.postData.params)a.push(`"${n.name}": "${n.value}"`);a.length&&(h=`data = {
|
|
2
|
+
${a.map(v=>` ${v}`).join(`,
|
|
3
3
|
`)}
|
|
4
|
-
}`),
|
|
5
|
-
${L(
|
|
6
|
-
'''`)}
|
|
4
|
+
}`),h&&t.push(h).blank();break;default:e.postData.text&&(p=`'''
|
|
5
|
+
${L(e.postData.text.trim(),{level:1,indent:s.indent,firstLine:!0})}
|
|
6
|
+
'''`)}p&&t.push(`${t.var("payload").toLowerCase()} = %s`,p).blank();let r;const u=Object.keys(i).length,$=(a,n)=>a==="Authorization"&&y?n:`"${n}"`;if(u===1)for(r in i)t.push(`${t.var("headers").toLowerCase()} = {"${r}": ${$(r,i[r])}}`).blank();else if(u>1){let a=1;t.push(`${t.var("headers").toLowerCase()} = {`);for(r in i)a++!==u?t.push(1,`"${r}": ${$(r,i[r])},`):t.push(1,`"${r}": ${$(r,i[r])}`);t.push(0,"}").blank()}const c=e.method.toLowerCase();let o=D(`${t.var("response").toLowerCase()} = requests.${c}(${t.var("url").toLowerCase()}`);if(C===l.MULTIPART&&h&&(o+=", data=data"),p){const a=C===l.JSON?"json":"data";o+=`, ${a}=${t.var("payload").toLowerCase()}`}return u>0&&(o+=`, headers=${t.var("headers").toLowerCase()}`),b&&(o+=`, params=${t.var("query").toLowerCase()}`),e.basicAuth&&(o+=`, auth=('${e.basicAuth.username}','${e.basicAuth.password}')`),o+=")",t.push(o).blank(),e.allResponseCodes?.includes("204")?t.push("if response.status_code == 204:").push(f+1,'print("success")').push("else:").push(f+1,`${t.var("data").toLowerCase()} = ${t.var("response").toLowerCase()}.json()`).push(f+1,`print(${t.var("data").toLowerCase()})`):t.push(`${t.var("data").toLowerCase()} = ${t.var("response").toLowerCase()}.json()`).push(`print(${t.var("data").toLowerCase()})`),t.join()};var M=g;function q(e){e.push('"""'),e.push("Requires python >= 3"),e.blank(),e.push('Requires module "requests" >= 2.25.1'),e.push("See here for installation details:"),e.push(" https://requests.readthedocs.io/"),e.push('"""'),e.blank()}function _(e,d){return JSON.stringify(e,function(m,s){return m&&typeof s=="boolean"?s?"__REDOCLY_<True>__":"__REDOCLY_<False>__":s===null?"__REDOCLY_<None>__":s},d).replace(/"__REDOCLY_<(\w+)>__"/g,"$1")}export{M as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{CodeBuilder as k}from"../../helpers/code-builder.js";import{buildUrlExpression as
|
|
1
|
+
import{CodeBuilder as k}from"../../helpers/code-builder.js";import{buildUrlExpression as D,printUrlVariablesDeclarations as v}from"../../helpers/code-helpers.js";import{Lang as x}from"../../helpers/constants.js";import{HTTPSnippet as O}from"../../index.js";import{normalizeMimeType as T}from"../../../../utils.js";import{MediaTypes as p}from"../../../../../constants.js";import{postDataToRListBody as b,objectToRString as f}from"./utils.js";import{buildRDeviceAuthorizationCodeSnippet as _}from"../../helpers/device-auth-snippets.js";const n=1,w=function(a,c,{target:m,client:u}){const i=Object.assign({indent:" ",showBoilerplate:!0,printBody:!0},c),t=new k({indentation:i.indent,variablesPrefix:i.variablesPrefix,lang:x.R}),$=a.method.toUpperCase(),l=a.securityOAuth2ExtraCalls?.[0];if(i.showBoilerplate&&t.push("library(httr)").blank(),l){const e="oauth2_",o=new O(l).convert(m,u,{...i,variablesPrefix:e,showBoilerplate:!1}),h=`${e}data_req`;t.push(o),l.flowType==="deviceAuthorization"?_(t,{tokenUrl:l.tokenUrl??"YOUR_TOKEN_URL",clientId:l.clientId??"YOUR_CLIENT_ID",level:0,responseVariable:h}):(t.push(`access_token = content(${h}, "parsed")$access_token`),t.blank()),a.allHeaders.Authorization='paste("Bearer", access_token)'}let r,s="";if(a?.postData)switch(T(a?.postData?.mimeType)){case p.URL_ENCODED:{r="form",s=t.var("body");const e=b(a.postData.params,i);t.push(`${s} <- list(${e})`).blank();break}case p.JSON:{r="json",s=t.var("body");const e=f(a.postData.jsonObj,i);t.push(`${s} = '${e}'`).blank();break}case p.MULTIPART:{r="multipart",s=t.var("body");const e=b(a.postData.params,i);t.push(`${s} <- list(${e})`).blank();break}default:a.postData?.text&&(s=t.var("body"),r="raw",t.push(`${s} = ${f(a.postData?.text)}`).blank())}v(a,t),Object.keys({...a.pathParameters,...a.serverVariables}).length&&t.blank().push("# create you own operator").push('"%&%" <- function(x, y)paste0(x,y)').blank();const y=D(a,t);t.push(`url = ${y}`).blank();const d=t.var("data_req");if(t.push(`${d} <- ${$}(`),t.push(n,"url,"),a.basicAuth){const{username:e,password:o}=a.basicAuth;t.push(n,`authenticate("${e}", "${o}")`)}if(Object.keys(a.allHeaders).length){const e=`${Object.keys(a.allHeaders).map(o=>`"${o}" = ${a.allHeaders[o].startsWith("paste")?a.allHeaders[o]:`"${a.allHeaders[o]}"`}`).join(", ")}`;e&&t.push(n,`add_headers(${e}),`)}return s&&(t.push(n,`body = ${s},`),t.push(n,`encode = "${r}",`)),t.push(n,"verbose()"),t.push(")"),i.printBody&&t.blank().push(`content(${d}${r==="raw"?', "text"':""})`),t.join()};var E=w;export{E as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import l from"stringify-object";import{CodeBuilder as
|
|
1
|
+
import l from"stringify-object";import{CodeBuilder as m}from"../../helpers/code-builder.js";import{HTTPSnippet as T}from"../../index.js";import{Lang as $}from"../../helpers/constants.js";import{buildUrlExpression as O,printUrlVariablesDeclarations as v}from"../../helpers/code-helpers.js";import{normalizeMimeType as d}from"../../../../utils.js";import{MediaTypes as n}from"../../../../../constants.js";import{buildRubyDeviceAuthorizationCodeSnippet as y}from"../../helpers/device-auth-snippets.js";const E=1;function _(t={},o){return d(t.mimeType)===o}const H=function(t,o,{target:f,client:b}){const p=t.method.toUpperCase(),i=t.securityOAuth2ExtraCalls?.[0],r={capitalize:!0,showBoilerplate:!0,indent:" ",...o},e=new m({indentation:r.indent,variablesPrefix:r.variablesPrefix,capitalize:r.capitalize,lang:$.RUBY});r.showBoilerplate&&(e.push("require 'uri'").push("require 'net/http'"),t.uriObj.protocol==="https:"&&e.push("require 'openssl'"),(_(t.postData,n.JSON)||i)&&e.unshift("require 'json'"),e.blank()),Object.keys(t.allHeaders).length&&Object.keys(t.allHeaders).forEach(a=>{t.allHeaders[a]=`'${t.allHeaders[a]}'`});const c=["GET","POST","HEAD","DELETE","PATCH","PUT","OPTIONS","COPY","LOCK","UNLOCK","MOVE","TRACE"],h=p.charAt(0)+p.substring(1).toLowerCase();if(c.indexOf(p)<0&&e.push("class Net::HTTP::%s < Net::HTTPRequest",h).push(" METHOD = '%s'",p.toUpperCase()).push(" REQUEST_HAS_BODY = '%s'",t.postData?.text?"true":"false").push(" RESPONSE_HAS_BODY = true").push("end").blank(),i){const a="oAuth2",s=new T(i).convert(f,b,{...r,variablesPrefix:a,showBoilerplate:!1}),u=`${a}${r.capitalize?"Response":"response"}`;e.push(s),i.flowType==="deviceAuthorization"?y(e,{tokenUrl:i.tokenUrl??"YOUR_TOKEN_URL",clientId:i.clientId??"YOUR_CLIENT_ID",level:0,responseVariable:u,capitalize:r.capitalize}):(e.push(`access_token = JSON.parse(${u}.body)['access_token']`),e.blank()),t.allHeaders.Authorization='"Bearer " + access_token'}if(v(t,e),e.push(`${e.var("url")} = URI(${O(t,e)})`),Object.getOwnPropertyNames(t.queryObj).length&&(e.push(`${e.var("params")} = ${l(t.queryObj,{indent:r.indent,inlineCharacterLimit:25})}`),e.push(`${e.var("url")}.query = URI.encode_www_form(${e.var("params")})`)),e.blank().push(`${e.var("http")} = Net::HTTP.new(${e.var("url")}.host, ${e.var("url")}.port)`),t.uriObj.protocol==="https:"&&e.push(`${e.var("http")}.use_ssl = true`),e.blank().push(`${e.var("request")} = Net::HTTP::%s.new(${e.var("url")})`,h),Object.keys(t.allHeaders).length&&Object.keys(t.allHeaders).forEach(a=>{t.allHeaders[a]!==`'${n.MULTIPART}'`&&e.push(`${e.var("request")}['%s'] = %s`,a,t.allHeaders[a])}),t?.postData){const a={};switch(d(t?.postData?.mimeType)){case n.URL_ENCODED:t.postData.params.forEach(s=>{a[s.name]=s.value}),e.push(`${e.var("request")}.body = URI.encode_www_form(${l(a,{indent:r.indent,inlineCharacterLimit:25})})`);break;case n.JSON:e.push(`${e.var("request")}.body = ${l(t.postData.jsonObj,{indent:r.indent,inlineCharacterLimit:25}).replace(/null/g,"nil")}.to_json`);break;case n.MULTIPART:t.postData.params&&(e.push(`${e.var("form_data")} = [`),t.postData.params.forEach(s=>{e.push(E,`['${s.name}', '${s.value}'],`)}),e.push("]")),e.push(`${e.var("request")}.set_form(${e.var("form_data")}, '${n.MULTIPART}')`);break;default:t.postData?.text&&e.push(`${e.var("request")}.body = ${JSON.stringify(t.postData?.text)}`)}}if(t.basicAuth){const{username:a,password:s}=t.basicAuth;e.push(`${e.var("request")}.basic_auth('${a}', '${s}')`)}return e.blank().push(`${e.var("response")} = ${e.var("http")}.request(${e.var("request")})`).push(`puts ${e.var("response")}.read_body`).blank(),e.join()},j={key:"native",title:"net::http",link:"http://ruby-doc.org/stdlib-2.2.1/libdoc/net/http/rdoc/Net/HTTP.html",description:"Ruby HTTP client"};var N=H;export{N as default,j as info};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import{format as
|
|
2
|
-
`+
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import{format as r}from"util";import{CodeBuilder as f}from"../../helpers/code-builder.js";import n from"../../helpers/shell.js";import{addIndentation as u,buildUrlExpression as T}from"../../helpers/code-helpers.js";import{normalizeMimeType as A}from"../../../../utils.js";import{HTTPSnippet as C}from"../../index.js";import{MediaTypes as p}from"../../../../../constants.js";import{buildShellDeviceAuthorizationCodeSnippet as E}from"../../helpers/device-auth-snippets.js";const D=function(e,m,{target:c,client:b}){const t=Object.assign({indent:" ",short:!1,binary:!1},m),a=new f({indentation:t.indent,lineJoin:t.indent?` \\
|
|
2
|
+
`+t.indent:" "}),s=e.securityOAuth2ExtraCalls?.[0];let l="",h="";if(s&&(l=new C(s).convert(c,b,{...t,withComments:!1}),s.flowType==="deviceAuthorization")){l="OAUTH2_RESPONSE=$("+l.replace(/^curl -i/,"curl -s")+")";const i=new f({indentation:t.indent});E(i,{tokenUrl:s.tokenUrl??"YOUR_TOKEN_URL",clientId:s.clientId??"YOUR_CLIENT_ID",level:0,short:t.short}),h=i.join()}a.push(0,"curl -i %s %s",t.short?"-X":"--request",e.method.toUpperCase()),e.basicAuth&&a.push(r("-u %s:%s",e.basicAuth.username,e.basicAuth.password));const y=T(e,a);if(a.push(r("%s%s",t.short?"":"--url ",n.quote(y))),e.httpVersion==="HTTP/1.0"&&a.push(t.short?"-0":"--http1.0"),Object.keys(e.headersObj).sort().forEach(function(i){let o=e.headersObj[i];s?.flowType==="deviceAuthorization"&&i.toLowerCase()==="authorization"&&o==="Bearer <YOUR_TOKEN_HERE>"&&(o="Bearer $ACCESS_TOKEN");const O=r("%s: %s",i,o);a.push("%s %s",t.short?"-H":"--header",n.quote(O))}),e.allHeaders.cookie&&a.push("%s %s",t.short?"-b":"--cookie",n.quote(e.allHeaders.cookie)),e.postData)switch(A(e.postData.mimeType)){case p.MULTIPART:e.postData.params.map(function(i){let o;i.fileName?o=r("%s=@%s",i.name,i.fileName):o=r("%s=%s",i.name,i.value),a.push("%s %s",t.short?"-F":"--form",n.quote(o))});break;case p.URL_ENCODED:e.postData.params?e.postData.params.map(function(i){a.push("%s %s",t.binary?"--data-binary":t.short?"-d":"--data",n.quote(r("%s=%s",i.name,i.value)))}):a.push("%s %s",t.binary?"--data-binary":t.short?"-d":"--data",n.quote(e.postData.text));break;case p.JSON:e.postData.jsonObj&&a.push("%s %s",t.binary?"--data-binary":t.short?"-d":"--data",u(n.quote(JSON.stringify(e.postData.jsonObj,null,t.indent)),{level:1,indent:t.indent,firstLine:!1}));break;default:e.postData.text&&a.push("%s %s",t.binary?"--data-binary":t.short?"-d":"--data",u(n.quote(e.postData.text),{level:1,indent:t.indent,firstLine:!1}))}let d="";return t.withComments&&(d=`# Requires curl >= 7.2
|
|
3
|
+
`,s?.flowType==="deviceAuthorization"&&(d+=`# Requires jq for JSON parsing
|
|
4
|
+
`),d+=`
|
|
5
|
+
`),d+(l?l+`
|
|
6
|
+
`:"")+(h?h+`
|
|
7
|
+
`:"")+a.join()},L={key:"curl",title:"curl",link:"http://curl.haxx.se/",description:"cURL is a command line tool and library for transferring data with URL syntax"};var S=D;export{S as default,L as info};
|
package/lib/standalone.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as i}from"react/jsx-runtime";import{createElement as p}from"react";import{createRoot as u,hydrateRoot as m}from"react-dom/client";import{querySelector as a}from"./utils/dom.js";import{RedoclyOpenAPIDocs as l}from"./components/RedoclyOpenAPIDocs/RedoclyOpenAPIDocs.js";import{RedoclyOpenAPIDocsStandalone as f}from"./components/RedoclyOpenAPIDocs/RedoclyOpenAPIDocsStandalone.js";import{setSecurityDetails as v,setSecurityDetailsVariants as V}from"./utils/security-details.js";import{setParameterValue as D}from"./utils/parameters.js";function _(t){const
|
|
1
|
+
import{jsx as i}from"react/jsx-runtime";import{createElement as p}from"react";import{createRoot as u,hydrateRoot as m}from"react-dom/client";import{querySelector as a}from"./utils/dom.js";import{RedoclyOpenAPIDocs as l}from"./components/RedoclyOpenAPIDocs/RedoclyOpenAPIDocs.js";import{RedoclyOpenAPIDocsStandalone as f}from"./components/RedoclyOpenAPIDocs/RedoclyOpenAPIDocsStandalone.js";import{setSecurityDetails as v,setSecurityDetailsVariants as V}from"./utils/security-details.js";import{setParameterValue as D}from"./utils/parameters.js";function _(t){const e={},o=t.attributes;for(let r=0;r<o.length;r++){const n=o[r];e[n.name]=n.value}return e}function d(t){const e=_(t),o={};for(const r in e){const n=r.replace(/-(.)/g,(c,s)=>s.toUpperCase());o[n]=e[r]}return o}function N(t,e=document.querySelector("redoc")){m(e,i(l,{store:t}))}function E(t,e={},o=a("redoc")){if(o===null)throw new Error('"element" argument is not provided and <redoc> tag is not found on the page');const{router:r,...n}=e;let c,s;typeof t=="string"?c=t:typeof t=="object"&&(s=t),u(o).render(p(f,{definition:s,definitionUrl:c,options:{...n,...d(o)},router:r??"hash"},["Loading..."]))}const b=__REDOCLY_API_REFERENCE_VERSION__,C=__REDOCLY_API_REFERENCE_REVISION__;function R(){const t=a("redoc");if(!t)return;const e=t.getAttribute("spec-url");e&&E(e,{},t)}R();export{N as hydrate,E as init,C as revision,D as setParameterValue,v as setSecurityDetails,V as setSecurityDetailsVariants,b as version};
|
package/lib/types/open-api.d.ts
CHANGED
|
@@ -47,6 +47,7 @@ export interface XSEO {
|
|
|
47
47
|
export interface OpenAPIServer extends ParsedDescription {
|
|
48
48
|
url: string;
|
|
49
49
|
description?: string;
|
|
50
|
+
name?: string;
|
|
50
51
|
variables?: OpenAPIServerVariables;
|
|
51
52
|
}
|
|
52
53
|
export interface OpenAPIServerVariables {
|
|
@@ -314,6 +315,8 @@ export interface OpenAPISecurityScheme extends ParsedDescription {
|
|
|
314
315
|
scheme?: string;
|
|
315
316
|
bearerFormat: string;
|
|
316
317
|
'x-defaultClientId'?: string;
|
|
318
|
+
deprecated?: boolean;
|
|
319
|
+
oauth2MetadataUrl?: string;
|
|
317
320
|
flows: {
|
|
318
321
|
implicit?: {
|
|
319
322
|
refreshUrl?: string;
|
|
@@ -321,6 +324,13 @@ export interface OpenAPISecurityScheme extends ParsedDescription {
|
|
|
321
324
|
authorizationUrl: string;
|
|
322
325
|
'x-defaultClientId'?: string;
|
|
323
326
|
};
|
|
327
|
+
deviceAuthorization?: {
|
|
328
|
+
deviceAuthorizationUrl: string;
|
|
329
|
+
scopes: Record<string, string>;
|
|
330
|
+
tokenUrl: string;
|
|
331
|
+
refreshUrl?: string;
|
|
332
|
+
'x-defaultClientId'?: string;
|
|
333
|
+
};
|
|
324
334
|
password?: {
|
|
325
335
|
refreshUrl?: string;
|
|
326
336
|
scopes: Record<string, string>;
|
package/lib/utils/helpers.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { OpenAPIServer } from '../types/open-api';
|
|
1
2
|
/**
|
|
2
3
|
* Maps over array passing `isLast` bool to iterator as the second argument
|
|
3
4
|
*/
|
|
@@ -42,5 +43,6 @@ export declare function getWindowReferenceOptions<T>(option: string): T | null;
|
|
|
42
43
|
export declare function getJsUrl(): string;
|
|
43
44
|
export declare const normalizeText: (text?: string | GenericObject) => string;
|
|
44
45
|
export declare const getValueFromMdParsedExtension: (item: GenericObject, key: "description" | "summary" | "x-summary" | "x-enumDescriptions") => any;
|
|
46
|
+
export declare function getServerDisplayName(server: OpenAPIServer): string | undefined;
|
|
45
47
|
export declare function isLastInArray(arr: Array<unknown>, index: number): boolean;
|
|
46
48
|
export declare function isLastProperty(obj: object, key: string): boolean;
|
package/lib/utils/helpers.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import{isObject as i,isString as a}from"@redocly/theme/core/openapi";import{isNamedDefinition as f}from"./openapi.js";import{JsonPointer as l}from"./JsonPointer.js";import{urlParse as u}from"./url.js";import{IS_BROWSER as c}from"./dom.js";function O(r,
|
|
1
|
+
import{isObject as i,isString as a}from"@redocly/theme/core/openapi";import{isNamedDefinition as f}from"./openapi.js";import{JsonPointer as l}from"./JsonPointer.js";import{urlParse as u}from"./url.js";import{IS_BROWSER as c}from"./dom.js";function O(r,e){const t=[];for(let n=0;n<r.length-1;n++)t.push(e(r[n],!1));return r.length!==0&&t.push(e(r[r.length-1],!0)),t}function y(r,e){const t={};for(const n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=e(r[n],n,r));return t}function A(r,e){const t=[],n=o=>{for(const s of o)t.push(s),s[e]&&n(s[e])};return n(r),t}function p(r){return r.endsWith("/")?r.substring(0,r.length-1):r}function b(r){return!isNaN(parseFloat(r))&&isFinite(r)}function E(r,e,t){const n=new RegExp(`(^|\\n)#\\s?${e}\\s*\\n`,"i"),o=new RegExp(`((\\n|^)#\\s*${e}\\s*(\\n|$)(?:.|\\n)*?)(\\n#|$)`,"i");if(n.test(r))return r.replace(o,`$1
|
|
2
2
|
|
|
3
|
-
${
|
|
3
|
+
${t}
|
|
4
4
|
$4`);{const s=r===""||r.endsWith(`
|
|
5
5
|
|
|
6
6
|
`)?"":r.endsWith(`
|
|
7
7
|
`)?`
|
|
8
8
|
`:`
|
|
9
9
|
|
|
10
|
-
`;return`${r}${s}# ${
|
|
10
|
+
`;return`${r}${s}# ${e}
|
|
11
11
|
|
|
12
|
-
${
|
|
12
|
+
${t}`}}const R=r=>Array.isArray(r)&&r.some(e=>i(e)),W=r=>r.filter(e=>!!e),C=r=>i(r)&&!Array.isArray(r);function d(r){return/(?:^[a-z][a-z0-9+.-]*:|\/\/)/i.test(r)}function I(r,e){let t;if(e.startsWith("//"))t=`${u(r,!0)?.protocol||"https:"}${e}`;else if(d(e))t=e;else if(!e.startsWith("/"))t=p(r)+"/"+e;else{const n=u(r);n?(n.pathname=e,t=n.toString()):t=e}return p(t)}function N(r){return r.charAt(0).toUpperCase()+r.slice(1)}function L(r){try{if(!r)return"";const e=new URL(r);return e.search="",e.hash="",e.toString()}catch{return r}}function M(r){return r.replace(/["\\]/g,"\\$&")}function P(r){return r.replace(/&#(\d+);/g,(e,t)=>String.fromCharCode(parseInt(t,10))).replace(/&/g,"&").replace(/"/g,'"')}function T(r){return r&&r.replace(/#/g,"_").toLowerCase()}function j(r,e){return e||f(r)&&l.baseName(r)||""}function z(r={},e,t){return typeof e=="string"&&(e=e.split(".")),e.reduce((n,o)=>n&&n[o]?n[o]:t,r)}function x(r){return(...e)=>e.filter(Boolean).join(r)}const D=x(".");function F(r){return c?window?.REFERENCE_DOCS_OPTIONS?.[r]:null}function _(){if(!c)return"";const r=+new Date+Math.random();try{return(!document.currentScript||!(document.currentScript.async||document.currentScript.defer))&&document.write(`<script id="dummy${r}"></script>`),(document.getElementById("dummy"+r)?.previousSibling).src}catch{return""}}const B=r=>a(r)?r:r?.raw,H=(r,e)=>{const t=r?.[`x-parsed-md-${e}`]||r?.[e];if(!t)return;if(!r?.[`x-parsed-md-${e}`]&&e!=="x-enumDescriptions")return r?.[e];if(e!=="x-enumDescriptions")return m(r,e);let n={};for(const o in t)o.startsWith("x-parsed-md")||(n[o]=t?.[`x-parsed-md-${o}`]||t?.[o]);return Object.keys(n).length?n:t};function U(r){return r.name||r.description}function m(r,e){const t=r?.[`x-parsed-md-${e}`]||r?.[e];return t?.raw?t:{result:t?.result||r?.[e]?.result||r?.[e],raw:r?.[e]}}function V(r,e){return e===r.length-1}function v(r,e){const t=Object.keys(r);return t.indexOf(e)===t.length-1}export{E as appendToMdHeading,W as deleteEmptyArrayItem,D as dottedString,M as escapeHTMLAttrChars,A as flattenByProp,z as get,_ as getJsUrl,U as getServerDisplayName,H as getValueFromMdParsedExtension,F as getWindowReferenceOptions,d as isAbsoluteUrl,R as isArrayOfObjects,V as isLastInArray,v as isLastProperty,C as isMergeableObject,b as isNumeric,x as joinStringFactory,y as mapValues,O as mapWithLast,B as normalizeText,L as removeQueryStringAndHash,I as resolveUrl,T as sanitizeItemId,p as stripTrailingSlash,N as titleize,P as unescapeHTMLChars,j as useSchemaTitle};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{bundle as a,loadConfig as r}from"@redocly/openapi-core";import{combineUrls as s}from"@redocly/theme/core/openapi";import{convertSwagger2OpenAPI as c}from"./convertSwagger2OpenAPI.js";import{IS_BROWSER as t}from"./dom.js";import{REDOCLY_CONFIG_FILE as f}from"../constants.js";async function w(){const o=t?window.location.origin:typeof globalThis.process<"u"?globalThis.process.cwd():"";try{return(await r({configPath:s(o,f)}))?.resolvedConfig.openapi||{}}catch
|
|
1
|
+
import{bundle as a,loadConfig as r}from"@redocly/openapi-core";import{combineUrls as s}from"@redocly/theme/core/openapi";import{convertSwagger2OpenAPI as c}from"./convertSwagger2OpenAPI.js";import{IS_BROWSER as t}from"./dom.js";import{REDOCLY_CONFIG_FILE as f}from"../constants.js";async function w(){const o=t?window.location.origin:typeof globalThis.process<"u"?globalThis.process.cwd():"";try{return(await r({configPath:s(o,f)}))?.resolvedConfig.openapi||{}}catch{return{}}}async function b(o){const n=await r(),e={config:n,base:t?window.location.origin:typeof globalThis.process<"u"?globalThis.process.cwd():""};t&&(n.resolve.http.customFetch=globalThis.fetch),typeof o=="object"&&o!==null?e.doc=d(o):e.ref=o;const{bundle:{parsed:i}}=await a(e);return i.swagger!==void 0?c(i):i}function d(o){return{source:{absoluteRef:""},parsed:o}}export{b as loadAndBundleDefinition,w as loadOpenapiConfig};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/openapi-docs",
|
|
3
|
-
"version": "3.14.0-next.
|
|
3
|
+
"version": "3.14.0-next.14",
|
|
4
4
|
"description": "Redocly OpenAPI Docs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"util": "~0.12.5",
|
|
38
38
|
"web-vitals": "3.3.1",
|
|
39
39
|
"@redocly/config": "0.35.0",
|
|
40
|
-
"@redocly/replay": "0.17.0-next.
|
|
40
|
+
"@redocly/replay": "0.17.0-next.13"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@jest/globals": "29.5.0",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"typescript": "5.6.2",
|
|
76
76
|
"url": "~0.11.0",
|
|
77
77
|
"vite": "6.3.6",
|
|
78
|
-
"@redocly/theme": "0.58.0-next.
|
|
78
|
+
"@redocly/theme": "0.58.0-next.10"
|
|
79
79
|
},
|
|
80
80
|
"scripts": {
|
|
81
81
|
"start": "npm run copy-highlight-hook && vite",
|
|
@@ -84,6 +84,7 @@
|
|
|
84
84
|
"build:standalone": "vite build && node scripts/minify.js dist",
|
|
85
85
|
"prepare:community-source": "npx tsx scripts/prepare-community-source.ts --",
|
|
86
86
|
"prepare:community-source-only": "npm run prepare:community-source --ignore /src/* private-readme.md",
|
|
87
|
+
"prepare:community-dependencies": "npx tsx scripts/prepare-community-dependencies.ts",
|
|
87
88
|
"test": "npm run prepare:community-source && cd redoc && npm install && npm run lint && npm run unit && cd ../ && jest -w 2",
|
|
88
89
|
"test:update": "jest -u",
|
|
89
90
|
"test:watch": "jest --watch",
|