@redocly/openapi-docs 3.17.0-next.2 → 3.17.0-next.4
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 +1998 -1863
- package/lib/components/PayloadSamples/ExampleValue.js +1 -1
- package/lib/components/Replay/utils.js +1 -1
- package/lib/components/SchemaDefinition/SchemaDefinition.js +2 -4
- package/lib/components/TagItem/OperationNavigationItems.js +5 -4
- package/lib/components/TagItem/TagItem.js +35 -9
- package/lib/jotai/operation.d.ts +1 -1
- package/lib/jotai/operation.js +1 -1
- package/lib/models/example.js +1 -1
- package/lib/models/mediaType.js +1 -1
- package/lib/services/code-samples/generator.js +1 -1
- package/lib/services/code-samples/httpsnippet/index.js +1 -1
- 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 +9 -5
- package/lib/services/code-samples/httpsnippet/targets/python/requests.js +8 -5
- package/lib/services/code-samples/httpsnippet/targets/r/httr.js +7 -1
- package/lib/services/code-samples/httpsnippet/targets/ruby/native.js +1 -1
- package/lib/services/code-samples/httpsnippet/targets/shell/curl.js +6 -6
- package/lib/types/open-api.d.ts +2 -0
- package/package.json +11 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
import h from"stringify-object";import{CodeBuilder as
|
|
1
|
+
import h from"stringify-object";import{CodeBuilder as C}from"../../helpers/code-builder.js";import{addIndentation as o,getPreserveTransformer as j,buildUrlExpression as x,printUrlVariablesDeclarations as R}from"../../helpers/code-helpers.js";import{Lang as T}from"../../helpers/constants.js";import{normalizeMimeType as c}from"../../../../utils.js";import{HTTPSnippet as L}from"../../index.js";import{MediaTypes as p}from"../../../../../constants.js";import{buildJSDeviceAuthorizationCodeSnippet as N}from"../../helpers/device-auth-snippets.js";const A=function(t,y,{target:g,client:D}){const s=Object.assign({indent:" ",showBoilerplate:!0,level:1},y),{level:a}=s;let f=!1;const e=new C({indentation:s.indent,variablesPrefix:s.variablesPrefix,capitalize:!0,lang:T.NODEJS});s.withComments&&U(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 m=!1;if(t.securityOAuth2ExtraCalls?.length){const n=t.securityOAuth2ExtraCalls?.[0],r=new L(n).convert(g,D,{...s,withImports:!1,withComments:!1,variablesPrefix:"oAuth2",showBoilerplate:!1,level:1});e.push(r),e.blank(),n.flowType==="deviceAuthorization"&&N(e,{tokenUrl:n.tokenUrl??"YOUR_TOKEN_URL",clientId:n.clientId??"YOUR_CLIENT_ID",level:a}),i.headers=i.headers||{},i.headers.Authorization="'Bearer ' + accessToken",m=!0}const u=Object.getOwnPropertyNames(t.queryObj).length;if(u&&e.push(a,`const ${e.var("query")} = new URLSearchParams(${o(h(t.queryObj,{indent:s.indent,inlineCharacterLimit:25}),{level:a,indent:s.indent,firstLine:!1})}).toString();`).blank(),t.postData)switch(c(t.postData.mimeType)){case p.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(h(t.postData.paramsObj,{indent:s.indent,inlineCharacterLimit:25}),{level:a,firstLine:!1})};`).blank();break;case p.JSON:t.postData.jsonObj&&(i.body=`JSON.stringify(${o(h(t.postData.jsonObj,{indent:s.indent,inlineCharacterLimit:25}),{level:a,firstLine:!1})})`);break;case p.MULTIPART:if(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?.length>0)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&&(f=!0,e.blank(),e.push(a,`${e.var("form")}.append('${n.name}', fs.createReadStream('${n.fileName}'));`))});else if(t.postData.text){const n=t.postData.text,r=n.match(/^--([^\r\n]+)/);if(r){const k=r[1];n.split(new RegExp(`--${k.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?:--)?`,"g")).filter(l=>l.trim().length>0).forEach(l=>{const d=l.match(/Content-Disposition:\s*form-data;\s*name="([^"]+)"(?:;\s*filename="([^"]+)")?/i);if(d){const $=d[1],v=d[2],O=l.match(/\r?\n\r?\n([\s\S]*?)(?:\r?\n)?$/),S=O?O[1].trim():"";v?(f=!0,e.blank(),e.push(a,`${e.var("form")}.append('${$}', fs.createReadStream('${v}'));`)):e.push(a,`${e.var("form")}.append('${$}', '${S.replace(/'/g,"\\'")}');`)}})}else e.push(a,`${e.var("form")}.append('data', ${JSON.stringify(t.postData.text)});`)}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')`,m=!0}f&&s.withImports&&e.unshift("import fs from 'fs';");const b=i.headers&&i.headers.Accept&&c(i.headers.Accept)===p.JSON||c(t.postData?.mimeType)===p.JSON;R(t,e,a);const w=x(t,e);return e.push(a,`const ${e.var("resp")} = await fetch(`).push(a+1,"`"+w+(u?"?${"+e.var("query")+"}":"")+"`,").push(a+1,o(h(i,{indent:s.indent,inlineCharacterLimit:25,transform:j({body:!0,authorizationHeader:m})}),{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")}.${b?"json()":"text()"};`).push(a+1,`console.log(${e.var("data")});`).push(a,"}")):e.push(a,`const ${e.var("data")} = await ${e.var("resp")}.${b?"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 U(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 F={key:"fetch",title:"Fetch",link:"https://github.com/bitinn/node-fetch",description:"Simplified HTTP node-fetch client"};var H=A;export{H as default,F as info};
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import{format as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
${
|
|
5
|
-
|
|
1
|
+
import{format as T}from"util";import{CodeBuilder as D}from"../../helpers/code-builder.js";import{HTTPSnippet as w}from"../../index.js";import{Lang as C}from"../../helpers/constants.js";import{buildUrlExpression as N,printUrlVariablesDeclarations as z}from"../../helpers/code-helpers.js";import{startCase as S}from"../../helpers/lodash-int.js";import{normalizeMimeType as H}from"../../../../utils.js";import{MediaTypes as R}from"../../../../../constants.js";import{objectToPhpArray as v}from"./utils.js";import{buildPHPDeviceAuthorizationCodeSnippet as I}from"../../helpers/device-auth-snippets.js";function y(e,d){return d?`$${d}${S(e)}`:`$${e}`}const V=function(e,d,{target:E,client:L}){const t={showBoilerplate:!0,checkErrors:!1,printBody:!0,indent:" ",noTags:!0,shortTags:!1,maxRedirects:10,namedErrors:!1,closingTag:!1,...d};let r,l=!1;const n=new D({indentation:t.indent,capitalize:!0,lang:C.PHP}),o=e.securityOAuth2ExtraCalls?.[0],p=y("curl",t.variablesPrefix),O=y("response",t.variablesPrefix),f=y("error",t.variablesPrefix);if(t.noTags||n.push(t.shortTags?"<?":"<?php").blank(),o){const a="oAuth2",s=new w(o).convert(E,L,{...t,showBoilerplate:!1,variablesPrefix:a});n.push(s),n.blank(),o.flowType==="deviceAuthorization"&&I(n,{tokenUrl:o.tokenUrl??"YOUR_TOKEN_URL",clientId:o.clientId??"YOUR_CLIENT_ID",level:0});const i=o.flowType==="deviceAuthorization"?"$accessToken":`${y("response",a)}->access_token`;e.allHeaders.Authorization=`Bearer " . ${i}`}const g=Object.keys(e.headersObj).sort().map(function(a){return a==="Authorization"&&o?T('"%s: %s',a,e.allHeaders.Authorization):T('"%s: %s"',a,e.headersObj[a])});if(e.basicAuth){const{username:a,password:s}=e.basicAuth;g.push(`"Authorization: Basic " . base64_encode("${a}:${s}")`)}t.showBoilerplate&&n.push("/**").push(" * Requires libcurl").push(" */").blank(),z(e,n);let c="";if(Object.keys(e.queryObj||{}).length){const a=v(e.queryObj||{},{indent:t.indent});c="$query",n.push(`${c} = ${a};`).blank()}if(n.push(`${p} = curl_init();`),n.blank(),e.postData)switch(H(e.postData.mimeType)){case R.JSON:{const a=v(e.postData.jsonObj||{},{indent:t.indent});l=!0,r="json_encode($payload)",n.push(`$payload = ${a};`).blank();break}case R.MULTIPART:{if(e.postData.params&&e.postData.params.length>0){const a=e.postData.params.map(({name:s,value:i,fileName:$})=>$?`${t.indent}"${s}" => new CURLFile("${$}"),
|
|
2
|
+
`:`${t.indent}"${s}" => "${i}",
|
|
3
|
+
`).join("");l=!0,r="$payload",n.push(`$payload = array(
|
|
4
|
+
${a});`).blank()}else if(e.postData.text){const a=e.postData.text,s=a.match(/^--([^\r\n]+)/);if(s){const i=s[1],$=a.split(new RegExp(`--${i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?:--)?`,"g")).filter(h=>h.trim().length>0),b=[];$.forEach(h=>{const P=h.match(/Content-Disposition:\s*form-data;\s*name="([^"]+)"(?:;\s*filename="([^"]+)")?/i);if(P){const _=P[1],k=P[2],x=h.match(/\r?\n\r?\n([\s\S]*?)(?:\r?\n)?$/),A=(x?x[1].trim():"").replace(/\\/g,"\\\\").replace(/"/g,'\\"');k?b.push(`${t.indent}"${_}" => new CURLFile("${k}"),
|
|
5
|
+
`):b.push(`${t.indent}"${_}" => "${A}",
|
|
6
|
+
`)}}),b.length>0?(l=!0,r="$payload",n.push(`$payload = array(
|
|
7
|
+
${b.join("")});`).blank()):r=`"${e.postData.text.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}else r=`"${e.postData.text.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}break}case R.URL_ENCODED:{const a=e.postData.params.length?e.postData.params.map(({name:s,value:i})=>`${s}=${i}`).join("&"):`${e.postData.text}`;l=!0,r="$payload",n.push(`$payload = "${a}";`).blank();break}default:r=e.postData.text;break}let u=N(e,n);c&&(u.endsWith('"')?u=u.slice(0,-1)+`?" . http_build_query(${c})`:u+=` . "?" . http_build_query(${c})`);const j=[{escape:!l,name:"CURLOPT_POSTFIELDS",value:r},{escape:!0,name:"CURLOPT_PORT",value:e.uriObj.port},{escape:!1,name:"CURLOPT_URL",value:u},{escape:!1,name:"CURLOPT_RETURNTRANSFER",value:"true"},{escape:!0,name:"CURLOPT_CUSTOMREQUEST",value:e.method.toUpperCase()}];n.push(`curl_setopt_array(${p}, [`);const m=new D({indentation:t.indent,lineJoin:`
|
|
8
|
+
${t.indent}`,variablesPrefix:t.variablesPrefix,capitalize:!0,lang:C.PHP});g.length&&m.push("CURLOPT_HTTPHEADER => [").push(1,g.join(`,
|
|
9
|
+
`+t.indent+t.indent)).push("],"),j.forEach(function(a){[null,void 0,""].includes(a.value)||m.push(T("%s => %s,",a.name,a.escape?JSON.stringify(a.value):a.value))});const U=e.cookies.map(function(a){return encodeURIComponent(a.name)+"="+encodeURIComponent(a.value)});return U.length&&m.push(T('CURLOPT_COOKIE => "%s",',U.join("; "))),n.push(1,m.join()).push("]);").blank().push(`${O} = curl_exec(${p});`).push(`${f} = curl_error(${p});`).blank().push(`curl_close(${p});`).blank().push(`if (${f}) {`),t.namedErrors?n.push(1,`echo array_flip(get_defined_constants(true)["curl"])[${f}];`):n.push(1,`echo "cURL Error #:" . ${f};`),n.push("} else {").push(1,`echo ${O};`).push("}"),!t.noTags&&t.closingTag&&n.blank().push("?>"),n.join()},Z={key:"curl",title:"cURL",link:"http://php.net/manual/en/book.curl.php",description:"PHP with ext-curl"};var ee=V;export{ee as default,Z as info};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import{format as
|
|
2
|
-
|
|
1
|
+
import{format as R}from"util";import{CodeBuilder as q}from"../../helpers/code-builder.js";import{normalizeMimeType as N}from"../../../../utils.js";import{addIndentation as v,buildUrlExpression as I,printUrlVariablesDeclarations as P}from"../../helpers/code-helpers.js";import{HTTPSnippet as U}from"../../index.js";import{Lang as z}from"../../helpers/constants.js";import{MediaTypes as h}from"../../../../../constants.js";import{buildPythonDeviceAuthorizationCodeSnippet as M}from"../../helpers/device-auth-snippets.js";const S=function(t,c,{target:g,client:b}){const s=Object.assign({indent:" "},c),{level:u=0}=s,e=new q({indentation:s.indent,variablesPrefix:s.variablesPrefix,lang:z.PYTHON}),x=t.securityOAuth2ExtraCalls?.some(a=>a.flowType==="deviceAuthorization");s.withComments&&Y(e),s.withImports&&(e.push("import requests"),x&&e.push("import time"),e.blank());let T=!1,r=t.allHeaders;if(t.securityOAuth2ExtraCalls?.length){const a=t.securityOAuth2ExtraCalls?.[0],o=new U(a).convert(g,b,{...s,withImports:!1,withComments:!1,variablesPrefix:"oauth2_"});e.push(o),e.blank(),a.flowType==="deviceAuthorization"&&M(e,{tokenUrl:a.tokenUrl??"YOUR_TOKEN_URL",clientId:a.clientId??"YOUR_CLIENT_ID",level:u}),r=r||{},r.Authorization='"Bearer " + access_token',T=!0}P(t,e),e.push(`${e.var("url").toLowerCase()} = %s`,I(t,e)).blank();let C;Object.keys(t.queryObj||{}).length&&(C="query = "+O(t.queryObj,s.indent),e.push(C).blank());let p,m;const y=N(t.postData?.mimeType);if(t.postData)switch(y){case h.URL_ENCODED:p=t.postData.paramsObj?`${v(O(t.postData.paramsObj,s.indent),{level:0,firstLine:!1})}`:`"${t.postData.text}"`;break;case h.JSON:t.postData.jsonObj&&(p=v(O(t.postData.jsonObj,s.indent),{level:0,firstLine:!1}));break;case h.MULTIPART:const a=[],o=[];if(t.postData.params&&t.postData.params.length>0)for(const n of t.postData.params)n.fileName?o.push(`"${n.name}": ("${n.fileName}", open("${n.fileName}", "rb"))`):a.push(`"${n.name}": "${n.value}"`);else if(t.postData.text){const n=t.postData.text,f=n.match(/^--([^\r\n]+)/);if(f){const L=f[1];n.split(new RegExp(`--${L.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?:--)?`,"g")).filter($=>$.trim().length>0).forEach($=>{const w=$.match(/Content-Disposition:\s*form-data;\s*name="([^"]+)"(?:;\s*filename="([^"]+)")?/i);if(w){const j=w[1],_=w[2],k=$.match(/\r?\n\r?\n([\s\S]*?)(?:\r?\n)?$/),E=(k?k[1].trim():"").replace(/\\/g,"\\\\").replace(/"/g,'\\"');_?o.push(`"${j}": ("${_}", open("${_}", "rb"))`):a.push(`"${j}": "${E}"`)}})}else{const L=t.postData.text.replace(/\\/g,"\\\\").replace(/"/g,'\\"');a.push(`"data": "${L}"`)}}if(o.length){const n=o.map(f=>` ${f}`).join(`,
|
|
2
|
+
`);e.push(`files = {
|
|
3
|
+
${n}
|
|
4
|
+
}`).blank()}a.length&&(m=`data = {
|
|
5
|
+
${a.map(f=>` ${f}`).join(`,
|
|
3
6
|
`)}
|
|
4
|
-
}`),
|
|
5
|
-
${
|
|
6
|
-
'''`)}p&&
|
|
7
|
+
}`),m&&e.push(m).blank();break;default:t.postData.text&&(p=`'''
|
|
8
|
+
${v(t.postData.text.trim(),{level:1,indent:s.indent,firstLine:!0})}
|
|
9
|
+
'''`)}p&&e.push(`${e.var("payload").toLowerCase()} = %s`,p).blank();let i;const d=Object.keys(r).length,D=(a,o)=>a==="Authorization"&&T?o:`"${o}"`;if(d===1)for(i in r)e.push(`${e.var("headers").toLowerCase()} = {"${i}": ${D(i,r[i])}}`).blank();else if(d>1){let a=1;e.push(`${e.var("headers").toLowerCase()} = {`);for(i in r)a++!==d?e.push(1,`"${i}": ${D(i,r[i])},`):e.push(1,`"${i}": ${D(i,r[i])}`);e.push(0,"}").blank()}const A=t.method.toLowerCase();let l=R(`${e.var("response").toLowerCase()} = requests.${A}(${e.var("url").toLowerCase()}`);if(y===h.MULTIPART&&(m&&(l+=", data=data"),e.join().includes("files = {")&&(l+=", files=files")),p){const a=y===h.JSON?"json":"data";l+=`, ${a}=${e.var("payload").toLowerCase()}`}return d>0&&(l+=`, headers=${e.var("headers").toLowerCase()}`),C&&(l+=`, params=${e.var("query").toLowerCase()}`),t.basicAuth&&(l+=`, auth=('${t.basicAuth.username}','${t.basicAuth.password}')`),l+=")",e.push(l).blank(),t.allResponseCodes?.includes("204")?e.push("if response.status_code == 204:").push(u+1,'print("success")').push("else:").push(u+1,`${e.var("data").toLowerCase()} = ${e.var("response").toLowerCase()}.json()`).push(u+1,`print(${e.var("data").toLowerCase()})`):e.push(`${e.var("data").toLowerCase()} = ${e.var("response").toLowerCase()}.json()`).push(`print(${e.var("data").toLowerCase()})`),e.join()};var Z=S;function Y(t){t.push('"""'),t.push("Requires python >= 3"),t.blank(),t.push('Requires module "requests" >= 2.25.1'),t.push("See here for installation details:"),t.push(" https://requests.readthedocs.io/"),t.push('"""'),t.blank()}function O(t,c){return JSON.stringify(t,function(b,s){return b&&typeof s=="boolean"?s?"__REDOCLY_<True>__":"__REDOCLY_<False>__":s===null?"__REDOCLY_<None>__":s},c).replace(/"__REDOCLY_<(\w+)>__"/g,"$1")}export{Z as default};
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
import{CodeBuilder as
|
|
1
|
+
import{CodeBuilder as _}from"../../helpers/code-builder.js";import{buildUrlExpression as P,printUrlVariablesDeclarations as j}from"../../helpers/code-helpers.js";import{Lang as O}from"../../helpers/constants.js";import{HTTPSnippet as C}from"../../index.js";import{normalizeMimeType as E}from"../../../../utils.js";import{MediaTypes as f}from"../../../../../constants.js";import{postDataToRListBody as R,objectToRString as D}from"./utils.js";import{buildRDeviceAuthorizationCodeSnippet as U}from"../../helpers/device-auth-snippets.js";const p=1,A=function(a,x,{target:g,client:y}){const o=Object.assign({indent:" ",showBoilerplate:!0,printBody:!0},x),t=new _({indentation:o.indent,variablesPrefix:o.variablesPrefix,lang:O.R}),k=a.method.toUpperCase(),d=a.securityOAuth2ExtraCalls?.[0];if(o.showBoilerplate&&t.push("library(httr)").blank(),d){const e="oauth2_",n=new C(d).convert(g,y,{...o,variablesPrefix:e,showBoilerplate:!1}),i=`${e}data_req`;t.push(n),d.flowType==="deviceAuthorization"?U(t,{tokenUrl:d.tokenUrl??"YOUR_TOKEN_URL",clientId:d.clientId??"YOUR_CLIENT_ID",level:0,responseVariable:i}):(t.push(`access_token = content(${i}, "parsed")$access_token`),t.blank()),a.allHeaders.Authorization='paste("Bearer", access_token)'}let l,s="";if(a?.postData)switch(E(a?.postData?.mimeType)){case f.URL_ENCODED:{if(s=t.var("body"),a.postData.params.length){l="form";const e=R(a.postData.params,o);t.push(`${s} <- list(${e})`).blank()}else a.postData.text&&(l="raw",t.push(`${s} <- "${a.postData.text}"`).blank());break}case f.JSON:{l="json",s=t.var("body");const e=D(a.postData.jsonObj,o);t.push(`${s} = '${e}'`).blank();break}case f.MULTIPART:{if(l="multipart",s=t.var("body"),a.postData.params&&a.postData.params.length>0){const e=[];a.postData.params.forEach(i=>{i.fileName?e.push(`${o.indent}${i.name} = upload_file("${i.fileName}")`):e.push(`${o.indent}${i.name} = "${i.value}"`)});const n=`
|
|
2
|
+
`+e.join(`,
|
|
3
|
+
`)+`
|
|
4
|
+
`;t.push(`${s} <- list(${n})`).blank()}else if(a.postData.text){const e=a.postData.text,n=e.match(/^--([^\r\n]+)/);if(n){const i=n[1],w=e.split(new RegExp(`--${i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?:--)?`,"g")).filter(r=>r.trim().length>0),h=[];if(w.forEach(r=>{const c=r.match(/Content-Disposition:\s*form-data;\s*name="([^"]+)"(?:;\s*filename="([^"]+)")?/i);if(c){const b=c[1],m=c[2],u=r.match(/\r?\n\r?\n([\s\S]*?)(?:\r?\n)?$/),T=(u?u[1].trim():"").replace(/\\/g,"\\\\").replace(/"/g,'\\"');m?h.push(`${o.indent}${b} = upload_file("${m}")`):h.push(`${o.indent}${b} = "${T}"`)}}),h.length>0){const r=`
|
|
5
|
+
`+h.join(`,
|
|
6
|
+
`)+`
|
|
7
|
+
`;t.push(`${s} <- list(${r})`).blank()}else{l="raw";const r=a.postData.text.replace(/\\/g,"\\\\").replace(/"/g,'\\"');t.push(`${s} <- "${r}"`).blank()}}else{l="raw";const i=a.postData.text.replace(/\\/g,"\\\\").replace(/"/g,'\\"');t.push(`${s} <- "${i}"`).blank()}}break}default:a.postData?.text&&(s=t.var("body"),l="raw",t.push(`${s} = ${D(a.postData?.text)}`).blank())}j(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 v=P(a,t);t.push(`url = ${v}`).blank();const $=t.var("data_req");if(t.push(`${$} <- ${k}(`),t.push(p,"url,"),a.basicAuth){const{username:e,password:n}=a.basicAuth;t.push(p,`authenticate("${e}", "${n}")`)}if(Object.keys(a.allHeaders).length){const e=`${Object.keys(a.allHeaders).map(n=>`"${n}" = ${a.allHeaders[n].startsWith("paste")?a.allHeaders[n]:`"${a.allHeaders[n]}"`}`).join(", ")}`;e&&t.push(p,`add_headers(${e}),`)}return s&&(t.push(p,`body = ${s},`),t.push(p,`encode = "${l}",`)),t.push(p,"verbose()"),t.push(")"),o.printBody&&t.blank().push(`content(${$}${l==="raw"?', "text"':""})`),t.join()};var z=A;export{z as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import c from"stringify-object";import{CodeBuilder as g}from"../../helpers/code-builder.js";import{HTTPSnippet as H}from"../../index.js";import{Lang as P}from"../../helpers/constants.js";import{buildUrlExpression as q,printUrlVariablesDeclarations as U}from"../../helpers/code-helpers.js";import{normalizeMimeType as O}from"../../../../utils.js";import{MediaTypes as p}from"../../../../../constants.js";import{buildRubyDeviceAuthorizationCodeSnippet as k}from"../../helpers/device-auth-snippets.js";const h=1;function w(t={},u){return O(t.mimeType)===u}const C=function(t,u,{target:y,client:D}){const l=t.method.toUpperCase(),n=t.securityOAuth2ExtraCalls?.[0],r={capitalize:!0,showBoilerplate:!0,indent:" ",...u},e=new g({indentation:r.indent,variablesPrefix:r.variablesPrefix,capitalize:r.capitalize,lang:P.RUBY});r.showBoilerplate&&(e.push("require 'uri'").push("require 'net/http'"),t.uriObj.protocol==="https:"&&e.push("require 'openssl'"),(w(t.postData,p.JSON)||n)&&e.unshift("require 'json'"),e.blank()),Object.keys(t.allHeaders).length&&Object.keys(t.allHeaders).forEach(a=>{t.allHeaders[a]=`'${t.allHeaders[a]}'`});const E=["GET","POST","HEAD","DELETE","PATCH","PUT","OPTIONS","COPY","LOCK","UNLOCK","MOVE","TRACE"],m=l.charAt(0)+l.substring(1).toLowerCase();if(E.indexOf(l)<0&&e.push("class Net::HTTP::%s < Net::HTTPRequest",m).push(" METHOD = '%s'",l.toUpperCase()).push(" REQUEST_HAS_BODY = '%s'",t.postData?.text?"true":"false").push(" RESPONSE_HAS_BODY = true").push("end").blank(),n){const a="oAuth2",i=new H(n).convert(y,D,{...r,variablesPrefix:a,showBoilerplate:!1}),s=`${a}${r.capitalize?"Response":"response"}`;e.push(i),n.flowType==="deviceAuthorization"?k(e,{tokenUrl:n.tokenUrl??"YOUR_TOKEN_URL",clientId:n.clientId??"YOUR_CLIENT_ID",level:0,responseVariable:s,capitalize:r.capitalize}):(e.push(`access_token = JSON.parse(${s}.body)['access_token']`),e.blank()),t.allHeaders.Authorization='"Bearer " + access_token'}if(U(t,e),e.push(`${e.var("url")} = URI(${q(t,e)})`),Object.getOwnPropertyNames(t.queryObj).length&&(e.push(`${e.var("params")} = ${c(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")})`,m),Object.keys(t.allHeaders).length&&Object.keys(t.allHeaders).forEach(a=>{t.allHeaders[a]!==`'${p.MULTIPART}'`&&e.push(`${e.var("request")}['%s'] = %s`,a,t.allHeaders[a])}),t?.postData){const a={};switch(O(t?.postData?.mimeType)){case p.URL_ENCODED:t.postData.params.length?(t.postData.params.forEach(s=>{a[s.name]=s.value}),e.push(`${e.var("request")}.body = URI.encode_www_form(${c(a,{indent:r.indent,inlineCharacterLimit:25})})`)):t.postData.text&&e.push(`${e.var("request")}.body = "${t.postData.text}"`);break;case p.JSON:e.push(`${e.var("request")}.body = ${c(t.postData.jsonObj,{indent:r.indent,inlineCharacterLimit:25}).replace(/null/g,"nil")}.to_json`);break;case p.MULTIPART:let i=!1;if(t.postData.params&&t.postData.params.length>0)e.push(`${e.var("form_data")} = [`),t.postData.params.forEach(s=>{s.fileName?e.push(h,`['${s.name}', File.open('${s.fileName}', 'rb')],`):e.push(h,`['${s.name}', '${s.value}'],`)}),e.push("]"),i=!0;else if(t.postData.text){const s=t.postData.text,b=s.match(/^--([^\r\n]+)/);if(b){const f=b[1],_=s.split(new RegExp(`--${f.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?:--)?`,"g")).filter(o=>o.trim().length>0);e.push(`${e.var("form_data")} = [`),_.forEach(o=>{const d=o.match(/Content-Disposition:\s*form-data;\s*name="([^"]+)"(?:;\s*filename="([^"]+)")?/i);if(d){const $=d[1],T=d[2],v=o.match(/\r?\n\r?\n([\s\S]*?)(?:\r?\n)?$/),x=(v?v[1].trim():"").replace(/\\/g,"\\\\").replace(/'/g,"\\'");T?e.push(h,`['${$}', File.open('${T}', 'rb')],`):e.push(h,`['${$}', '${x}'],`)}}),e.push("]"),i=!0}else{const f=t.postData.text.replace(/\\/g,"\\\\").replace(/'/g,"\\'");e.push(`${e.var("request")}.body = '${f}'`);break}}i&&e.push(`${e.var("request")}.set_form(${e.var("form_data")}, '${p.MULTIPART}')`);break;default:t.postData?.text&&e.push(`${e.var("request")}.body = ${JSON.stringify(t.postData?.text)}`)}}if(t.basicAuth){const{username:a,password:i}=t.basicAuth;e.push(`${e.var("request")}.basic_auth('${a}', '${i}')`)}return e.blank().push(`${e.var("response")} = ${e.var("http")}.request(${e.var("request")})`).push(`puts ${e.var("response")}.read_body`).blank(),e.join()},V={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 Y=C;export{Y as default,V as info};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{format as
|
|
2
|
-
`+t.indent:" "}),
|
|
3
|
-
`,
|
|
4
|
-
`),
|
|
5
|
-
`),
|
|
1
|
+
import{format as n}from"util";import{CodeBuilder as D}from"../../helpers/code-builder.js";import o from"../../helpers/shell.js";import{addIndentation as x,buildUrlExpression as R}from"../../helpers/code-helpers.js";import{normalizeMimeType as U}from"../../../../utils.js";import{HTTPSnippet as w}from"../../index.js";import{MediaTypes as c}from"../../../../../constants.js";import{buildShellDeviceAuthorizationCodeSnippet as N}from"../../helpers/device-auth-snippets.js";const g=function(e,T,{target:E,client:C}){const t=Object.assign({indent:" ",short:!1,binary:!1},T),s=new D({indentation:t.indent,lineJoin:t.indent?` \\
|
|
2
|
+
`+t.indent:" "}),r=e.securityOAuth2ExtraCalls?.[0];let l="",h="";if(r&&(l=new w(r).convert(E,C,{...t,withComments:!1}),r.flowType==="deviceAuthorization")){l="OAUTH2_RESPONSE=$("+l.replace(/^curl -i/,"curl -s")+")";const a=new D({indentation:t.indent});N(a,{tokenUrl:r.tokenUrl??"YOUR_TOKEN_URL",clientId:r.clientId??"YOUR_CLIENT_ID",level:0,short:t.short}),h=a.join()}s.push(0,"curl -i %s %s",t.short?"-X":"--request",e.method.toUpperCase()),e.basicAuth&&s.push(n("-u %s:%s",e.basicAuth.username,e.basicAuth.password));const A=R(e,s);if(s.push(n("%s%s",t.short?"":"--url ",o.quote(A))),e.httpVersion==="HTTP/1.0"&&s.push(t.short?"-0":"--http1.0"),Object.keys(e.headersObj).sort().forEach(function(a){let i=e.headersObj[a];r?.flowType==="deviceAuthorization"&&a.toLowerCase()==="authorization"&&i==="Bearer <YOUR_TOKEN_HERE>"&&(i="Bearer $ACCESS_TOKEN");const f=n("%s: %s",a,i);s.push("%s %s",t.short?"-H":"--header",o.quote(f))}),e.allHeaders.cookie&&s.push("%s %s",t.short?"-b":"--cookie",o.quote(e.allHeaders.cookie)),e.postData)switch(U(e.postData.mimeType)){case c.MULTIPART:if(e.postData?.params?.length>0)e.postData.params.map(function(a){let i;a.fileName?i=n("%s=@%s",a.name,a.fileName):i=n("%s=%s",a.name,a.value),s.push("%s %s",t.short?"-F":"--form",o.quote(i))});else if(e.postData.text){const a=e.postData.text,i=a.match(/^--([^\r\n]+)/);if(i){const f=i[1];a.split(new RegExp(`--${f.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?:--)?`,"g")).filter(d=>d.trim().length>0).forEach(d=>{const m=d.match(/Content-Disposition:\s*form-data;\s*name="([^"]+)"(?:;\s*filename="([^"]+)")?/i);if(m){const b=m[1],y=m[2],O=d.match(/\r?\n\r?\n([\s\S]*?)(?:\r?\n)?$/),q=O?O[1].trim():"";let u;y?u=n("%s=@%s",b,y):u=n("%s=%s",b,q);const v=n("'%s'",u.replace(/'/g,"'\\''"));s.push("%s %s",t.short?"-F":"--form",v)}})}else s.push("%s %s",t.binary?"--data-binary":t.short?"-d":"--data",o.quote(e.postData.text))}break;case c.URL_ENCODED:e.postData?.params?.length>0?e.postData.params.map(function(a){s.push("%s %s",t.binary?"--data-binary":t.short?"-d":"--data",o.quote(n("%s=%s",a.name,a.value)))}):s.push("%s %s",t.binary?"--data-binary":t.short?"-d":"--data",o.quote(e.postData.text));break;case c.JSON:e.postData.jsonObj&&s.push("%s %s",t.binary?"--data-binary":t.short?"-d":"--data",x(o.quote(JSON.stringify(e.postData.jsonObj,null,t.indent)),{level:1,indent:t.indent,firstLine:!1}));break;default:e.postData.text&&s.push("%s %s",t.binary?"--data-binary":t.short?"-d":"--data",x(o.quote(e.postData.text),{level:1,indent:t.indent,firstLine:!1}))}let p="";return t.withComments&&(p=`# Requires curl >= 7.2
|
|
3
|
+
`,r?.flowType==="deviceAuthorization"&&(p+=`# Requires jq for JSON parsing
|
|
4
|
+
`),p+=`
|
|
5
|
+
`),p+(l?l+`
|
|
6
6
|
`:"")+(h?h+`
|
|
7
|
-
`:"")+
|
|
7
|
+
`:"")+s.join()},M={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 $=g;export{$ as default,M as info};
|
package/lib/types/open-api.d.ts
CHANGED
|
@@ -142,6 +142,8 @@ export interface OpenAPIExample extends ParsedDescriptionWithSummary {
|
|
|
142
142
|
value: any;
|
|
143
143
|
summary?: string;
|
|
144
144
|
description?: string;
|
|
145
|
+
dataValue?: any;
|
|
146
|
+
serializedValue?: string;
|
|
145
147
|
externalValue?: string;
|
|
146
148
|
}
|
|
147
149
|
export interface XMLObject {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/openapi-docs",
|
|
3
|
-
"version": "3.17.0-next.
|
|
3
|
+
"version": "3.17.0-next.4",
|
|
4
4
|
"description": "Redocly OpenAPI Docs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -15,17 +15,19 @@
|
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"@redocly/theme": ">=0.61.0-next.0",
|
|
18
|
-
"react": "
|
|
19
|
-
"react-dom": "
|
|
18
|
+
"react": "19.2.3",
|
|
19
|
+
"react-dom": "19.2.3",
|
|
20
20
|
"styled-components": "^4.1.1 || ^5.3.11 || ^6.0.0"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@markdoc/markdoc": "0.5.2",
|
|
24
|
-
"@redocly/openapi-core": "2.
|
|
24
|
+
"@redocly/openapi-core": "2.14.3",
|
|
25
25
|
"deepmerge": "^4.2.2",
|
|
26
26
|
"dompurify": "3.2.7",
|
|
27
27
|
"fast-deep-equal": "^3.1.3",
|
|
28
|
+
"fast-xml-parser": "5.2.5",
|
|
28
29
|
"jotai": "^2.12.5",
|
|
30
|
+
"jotai-family": "^1.0.1",
|
|
29
31
|
"json-pointer": "^0.6.2",
|
|
30
32
|
"openapi-sampler": "1.6.2",
|
|
31
33
|
"react-router-dom": "^6.21.1",
|
|
@@ -37,7 +39,7 @@
|
|
|
37
39
|
"util": "~0.12.5",
|
|
38
40
|
"web-vitals": "3.3.1",
|
|
39
41
|
"@redocly/config": "0.41.1",
|
|
40
|
-
"@redocly/replay": "0.20.0-next.
|
|
42
|
+
"@redocly/replay": "0.20.0-next.4"
|
|
41
43
|
},
|
|
42
44
|
"devDependencies": {
|
|
43
45
|
"@shikijs/transformers": "1.24.0",
|
|
@@ -51,7 +53,7 @@
|
|
|
51
53
|
"@types/react-dom": "^19.2.3",
|
|
52
54
|
"@types/styled-components": "5.1.34",
|
|
53
55
|
"@vitejs/plugin-react": "5.1.1",
|
|
54
|
-
"@vitest/coverage-v8": "
|
|
56
|
+
"@vitest/coverage-v8": "4.0.10",
|
|
55
57
|
"esbuild": "0.27.0",
|
|
56
58
|
"jest-styled-components": "7.2.0",
|
|
57
59
|
"js-yaml": "4.1.1",
|
|
@@ -59,8 +61,8 @@
|
|
|
59
61
|
"outdent": "0.8.0",
|
|
60
62
|
"path-browserify": "1.0.1",
|
|
61
63
|
"prettier-2": "npm:prettier@2.8.8",
|
|
62
|
-
"react": "
|
|
63
|
-
"react-dom": "
|
|
64
|
+
"react": "19.2.3",
|
|
65
|
+
"react-dom": "19.2.3",
|
|
64
66
|
"rimraf": "5.0.7",
|
|
65
67
|
"rollup-plugin-bundle-stats": "^4.20.2",
|
|
66
68
|
"shiki": "1.24.4",
|
|
@@ -70,7 +72,7 @@
|
|
|
70
72
|
"url": "~0.11.0",
|
|
71
73
|
"vite": "7.2.6",
|
|
72
74
|
"vitest": "4.0.10",
|
|
73
|
-
"@redocly/theme": "0.61.0-next.
|
|
75
|
+
"@redocly/theme": "0.61.0-next.3"
|
|
74
76
|
},
|
|
75
77
|
"scripts": {
|
|
76
78
|
"start": "npm run copy-highlight-hook && vite",
|