@redocly/openapi-docs 3.14.0-next.11 → 3.14.0-next.13
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 +1541 -1528
- 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/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/types/open-api.d.ts +9 -0
- package/package.json +5 -4
|
@@ -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/types/open-api.d.ts
CHANGED
|
@@ -314,6 +314,8 @@ export interface OpenAPISecurityScheme extends ParsedDescription {
|
|
|
314
314
|
scheme?: string;
|
|
315
315
|
bearerFormat: string;
|
|
316
316
|
'x-defaultClientId'?: string;
|
|
317
|
+
deprecated?: boolean;
|
|
318
|
+
oauth2MetadataUrl?: string;
|
|
317
319
|
flows: {
|
|
318
320
|
implicit?: {
|
|
319
321
|
refreshUrl?: string;
|
|
@@ -321,6 +323,13 @@ export interface OpenAPISecurityScheme extends ParsedDescription {
|
|
|
321
323
|
authorizationUrl: string;
|
|
322
324
|
'x-defaultClientId'?: string;
|
|
323
325
|
};
|
|
326
|
+
deviceAuthorization?: {
|
|
327
|
+
deviceAuthorizationUrl: string;
|
|
328
|
+
scopes: Record<string, string>;
|
|
329
|
+
tokenUrl: string;
|
|
330
|
+
refreshUrl?: string;
|
|
331
|
+
'x-defaultClientId'?: string;
|
|
332
|
+
};
|
|
324
333
|
password?: {
|
|
325
334
|
refreshUrl?: string;
|
|
326
335
|
scopes: Record<string, string>;
|
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.13",
|
|
4
4
|
"description": "Redocly OpenAPI Docs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"url-template": "^2.0.8",
|
|
37
37
|
"util": "~0.12.5",
|
|
38
38
|
"web-vitals": "3.3.1",
|
|
39
|
-
"@redocly/config": "0.
|
|
40
|
-
"@redocly/replay": "0.17.0-next.
|
|
39
|
+
"@redocly/config": "0.35.0",
|
|
40
|
+
"@redocly/replay": "0.17.0-next.12"
|
|
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.9"
|
|
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",
|