@redocly/reference-docs 2.42.4 → 2.43.0
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/bin/cli/commands/redocly-docs-cli.min.js +5 -5
- package/bin/cli/commands/redocly-docs-cli.min.js.LICENSE.txt +1 -1
- package/dist/console.redocly-reference-docs.min.js +57 -57
- package/dist/oauth2-redirect.js +1 -1
- package/dist/redocly-reference-docs.min.js +99 -99
- package/lib/components/console/Console.js +1 -1
- package/lib/components/console/utils.d.ts +3 -2
- package/lib/components/console/utils.js +1 -1
- package/lib/services/ProStore.js +1 -1
- package/lib/services/code-samples/generator.js +1 -1
- package/lib/services/history/PushStateHistoryService.js +1 -1
- package/lib/types.d.ts +4 -0
- package/lib-esm/components/console/Console.js +1 -1
- package/lib-esm/components/console/utils.d.ts +3 -2
- package/lib-esm/components/console/utils.js +1 -1
- package/lib-esm/services/ProStore.js +1 -1
- package/lib-esm/services/code-samples/generator.js +1 -1
- package/lib-esm/services/history/PushStateHistoryService.js +1 -1
- package/lib-esm/types.d.ts +4 -0
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign}from"tslib";import{parse as parseQueryString,stringify as stringifyQueryString}from"query-string";import*as Sampler from"openapi-sampler";import merge from"deepmerge";import{toJS}from"mobx";import{deleteEmptyArrayItem,isArrayOfObjects,serializeParameterValue}from"../../redoc-lib";import{getSecurityDetails,getParameterValue}from"../../utils";import{normalizeMimeType,arrayMergeStrategy}from"../utils";import{MediaTypes}from"../../types";import{l}from"../../redoc-lib/src/services/Labels";import{HTTPSnippet}from"./httpsnippet";import StringUtility from"./httpsnippet/helpers/string-utility";function mapOperationToHAR(e,t){var a,r,i,n,s,o,l,u,p,d,c=t.exampleName,m=void 0===c?"":c,v=t.skipOptionalParameters,h=void 0!==v&&v,f=t.withOAuth2Call,y=void 0!==f&&f,g=t.spec,O=t.generatedPayloadSamplesMaxDepth,S=void 0===O?8:O,
|
|
1
|
+
import{__assign}from"tslib";import{parse as parseQueryString,stringify as stringifyQueryString}from"query-string";import*as Sampler from"openapi-sampler";import merge from"deepmerge";import{toJS}from"mobx";import{deleteEmptyArrayItem,isArrayOfObjects,serializeParameterValue}from"../../redoc-lib";import{getSecurityDetails,getParameterValue}from"../../utils";import{normalizeMimeType,arrayMergeStrategy}from"../utils";import{MediaTypes}from"../../types";import{l}from"../../redoc-lib/src/services/Labels";import{HTTPSnippet}from"./httpsnippet";import StringUtility from"./httpsnippet/helpers/string-utility";function mapOperationToHAR(e,t){var a,r,i,n,s,o,l,u,p,d,c=t.exampleName,m=void 0===c?"":c,v=t.skipOptionalParameters,h=void 0!==v&&v,f=t.withOAuth2Call,y=void 0!==f&&f,g=t.spec,O=t.generatedPayloadSamplesMaxDepth,S=void 0===O?8:O,T=t.pathParams,_=void 0===T?{}:T,C=t.properties,E=void 0===C?{}:C,b=getSecurityData(null===(a=e.security)||void 0===a?void 0:a[0],y),A=b.securityHeaders,P=b.securityCookies,R=b.securityQueries,w=b.securityOAuth2ExtraCalls,D=b.basicAuth,k=null===(i=null===(r=e.requestBody)||void 0===r?void 0:r.content)||void 0===i?void 0:i.active,q={skipNonRequired:h,skipReadOnly:!0,maxSampleDepth:S},H={path:toJS(null===(n=null==e?void 0:e.requestValues)||void 0===n?void 0:n.path),cookie:toJS(null===(s=null==e?void 0:e.requestValues)||void 0===s?void 0:s.cookie),header:toJS(null===(o=null==e?void 0:e.requestValues)||void 0===o?void 0:o.header),query:toJS(null===(l=null==e?void 0:e.requestValues)||void 0===l?void 0:l.query),body:toJS(null===(u=null==e?void 0:e.requestValues)||void 0===u?void 0:u.body)},M=!1,x=e.parameters.filter((function(e){return"header"===e.in})).filter((function(e){return!(h&&!e.required)})).map((function(e){var t;return{name:e.name,value:(null===(t=H.header)||void 0===t?void 0:t[e.name])||getParameterValue("header",e.name)||serializeParameterValue(e,Sampler.sample(e.schema.rawSchema,q,g))}})).map((function(e){return(null==k?void 0:k.name)&&"content-type"===e.name.toLowerCase()&&(M=!0,e.value=k.name),e})).concat(A);!M&&(null==k?void 0:k.name)&&x.unshift({name:"Content-Type",value:null==k?void 0:k.name});var N,U=e.parameters.filter((function(e){return"cookie"===e.in})).filter((function(e){return!(h&&!e.required)})).map((function(e){return parseQueryString(serializeParameterValue(e,Sampler.sample(e.schema.rawSchema,q,g)))})).reduce((function(e,t){for(var a,r=0,i=Object.entries(t);r<i.length;r++){var n=i[r],s=n[0],o=n[1];e.push({name:s,value:String((null===(a=H.cookie)||void 0===a?void 0:a[s])||o)})}return e}),[]).concat(P),j=e.parameters.filter((function(e){return"query"===e.in})).filter((function(e){return!(h&&!e.required)})).map((function(e){return parseQueryString(serializeParameterValue(e,Sampler.sample(e.schema.rawSchema,q,g)))})).reduce((function(e,t){for(var a,r,i,n=0,s=Object.entries(t);n<s.length;n++){var o=s[n],l=o[0],u=o[1];e.push({name:l,value:isArrayOfObjects(null===(a=H.query)||void 0===a?void 0:a[l])&&JSON.stringify(deleteEmptyArrayItem(null===(r=H.query)||void 0===r?void 0:r[l]))||String((null===(i=H.query)||void 0===i?void 0:i[l])||u)})}return e}),[]).concat(R),z=null===(p=e.activeServer)||void 0===p?void 0:p.url.replace(/\/$/,""),V=e.path.replace(/^\//,""),I=z.split("#")[0]+"/"+V,J=e.parameters.filter((function(e){return"path"===e.in})).reduce((function(e,t){var a,r=t.in,i=t.name;return e[i]=(null===(a=H.path)||void 0===a?void 0:a[i])||_[i]||getParameterValue(r,i),e}),{}),L=null===(d=null==k?void 0:k.examples)||void 0===d?void 0:d[m],Y=(null==k?void 0:k.examples)||{},Q=Object.values(Y)[0],B=H.body||(null==L?void 0:L.value)||(null==Q?void 0:Q.value)||(null==k?void 0:k.schema)&&Sampler.sample(null==k?void 0:k.schema.rawSchema,q,g),K=null==k?void 0:k.name.toLowerCase(),F=[];switch(normalizeMimeType(K)){case MediaTypes.JSON:case MediaTypes.XML:N=JSON.stringify(getDataRequest(B,E));break;case MediaTypes.URL_ENCODED:case MediaTypes.MULTIPART:N=stringifyQueryString(getDataRequest(B,E)),F=objectToHarParams(getDataRequest(B,E));break;default:N=String(B||"")}var G=N?{mimeType:(null==k?void 0:k.name)||MediaTypes.OCTET_STREAM,text:N,params:F}:void 0,X=e.responses.map((function(e){return e.code}));return{method:e.httpVerb,url:I,httpVersion:"HTTP/1.1",cookies:U,headers:x,queryString:j,postData:G,headersSize:-1,bodySize:-1,securityOAuth2ExtraCalls:w,basicAuth:D,pathParameters:J,serverVariables:e.activeServer.variables,allResponseCodes:X}}var defaultOptions={withImports:!0,withComments:!1},langToSnippetConfig={curl:{code:"shell",defaultTarget:"curl",defaultOptions:__assign(__assign({},defaultOptions),{short:!0})},JavaScript:{code:"javascript",defaultTarget:"fetch",defaultOptions:__assign(__assign({},defaultOptions),{withImports:!1})},"Node.js":{code:"node",defaultTarget:"fetch",defaultOptions:__assign({},defaultOptions)},Python:{code:"python",defaultTarget:"requests",defaultOptions:__assign({},defaultOptions)},"Java8+Apache":{code:"java8",defaultTarget:"apachehttp",defaultOptions:__assign({},defaultOptions)},Java:{code:"java",defaultTarget:"httpclient",defaultOptions:__assign({},defaultOptions)},"C#":{code:"csharp",defaultTarget:"httpclient",defaultOptions:__assign({},defaultOptions)},Go:{code:"go",defaultTarget:"http.DefaultClient",defaultOptions:__assign({},defaultOptions)},PHP:{code:"php",defaultTarget:"curl",defaultOptions:__assign({},defaultOptions)},Ruby:{code:"ruby",defaultTarget:"net::http",defaultOptions:__assign({},defaultOptions)},R:{code:"r",defaultTarget:"httr",defaultOptions:__assign({},defaultOptions)}};export function getCodeSample(e){var t=e.lang,a=e.operation,r=e.exampleName,i=e.pathParams,n=e.properties,s=e.options,o=void 0===s?{}:s;try{var l=mapOperationToHAR(a,{exampleName:r,pathParams:i,properties:n,skipOptionalParameters:o.skipOptionalParameters,withOAuth2Call:o.withOAuth2Call,spec:o.spec,generatedPayloadSamplesMaxDepth:o.generatedPayloadSamplesMaxDepth}),u=new HTTPSnippet(l);return langToSnippetConfig[t]?u.convert(langToSnippetConfig[t].code,langToSnippetConfig[t].defaultTarget,__assign(__assign({},langToSnippetConfig[t].defaultOptions),o)):"Language is not supported."}catch(e){return console.error(e),"Failed to generate code sample."}}function getSecurityData(e,t){for(var a,r,i,n,s={securityHeaders:[],securityCookies:[],securityQueries:[],securityOAuth2ExtraCalls:[],basicAuth:void 0},o=0,u=(null==e?void 0:e.schemes)||[];o<u.length;o++){var p=u[o],d=getSecurityDetails(p.id);switch(p.type){case"openIdConnect":null===(a=s.securityHeaders)||void 0===a||a.push({name:"Authorization",value:"Bearer <YOUR_TOKEN_HERE>"});break;case"oauth2":var c=d.token?(d.token.token_type||"Bearer")+" "+d.token.access_token:"Bearer <YOUR_TOKEN_HERE>";p.flows.clientCredentials&&t?s.securityOAuth2ExtraCalls.push(getOAuth2ClientCredsCallHar(p.flows.clientCredentials,p.scopes,d)):p.flows.password&&t&&s.securityOAuth2ExtraCalls.push(getOAuth2PasswordCallHar(p.flows.password,p.scopes,d)),null===(r=s.securityHeaders)||void 0===r||r.push({name:"Authorization",value:c});break;case"apiKey":var m=d.raw||"YOUR_API_KEY_HERE";"header"===p.in&&(null===(i=s.securityHeaders)||void 0===i||i.push({name:p.name,value:m})),"cookie"===p.in&&s.securityCookies.push({name:p.name,value:m}),"query"===p.in&&s.securityQueries.push({name:p.name,value:m});break;case"http":"basic"===p.scheme?s.basicAuth={username:d.username||"<"+StringUtility.toSnakeCase(l("tryItAuthBasicUsername"))+">",password:d.password||"<"+StringUtility.toSnakeCase(l("tryItAuthBasicPassword"))+">"}:null===(n=s.securityHeaders)||void 0===n||n.push({name:"Authorization",value:capitalizeFirst(p.scheme||"bearer")+" <YOUR_"+(p.bearerFormat||"TOKEN")+"_HERE>"})}}return s}function getOAuth2PasswordCallHar(e,t,a){return{method:"POST",url:e.tokenUrl,httpVersion:"HTTP/1.1",headers:[{name:"Content-Type",value:MediaTypes.URL_ENCODED},{name:"Accept",value:MediaTypes.JSON}],queryString:[],postData:{mimeType:MediaTypes.URL_ENCODED,text:"",params:[{name:"grant_type",value:"password"},{name:"client_id",value:a.client_id||"YOUR_CLIENT_ID"},{name:"client_secret",value:a.client_secret||"YOUR_CLIENT_SECRET"},{name:"username",value:a.username||"<username>"},{name:"password",value:a.password||"<password>"},t.length?{name:"scope",value:t.join(" ")}:void 0].filter(isDefined)},cookies:[],headersSize:-1,bodySize:-1,securityOAuth2ExtraCalls:[]}}function getOAuth2ClientCredsCallHar(e,t,a){return{method:"POST",url:e.tokenUrl,httpVersion:"HTTP/1.1",headers:[{name:"Content-Type",value:MediaTypes.URL_ENCODED},{name:"Accept",value:MediaTypes.JSON}],queryString:[],postData:{mimeType:MediaTypes.URL_ENCODED,text:"",params:[{name:"grant_type",value:"client_credentials"},{name:"client_id",value:a.client_id||"YOUR_CLIENT_ID"},{name:"client_secret",value:a.client_secret||"YOUR_CLIENT_SECRET"},t.length?{name:"scope",value:t.join(" ")}:void 0].filter(isDefined)},cookies:[],headersSize:-1,bodySize:-1,securityOAuth2ExtraCalls:[]}}function getDataRequest(e,t){if(e){if("object"==typeof e)return merge(e,t,{arrayMerge:arrayMergeStrategy});try{return merge(JSON.parse(e),t,{arrayMerge:arrayMergeStrategy})}catch(e){return!1}}return!1}function objectToHarParams(e,t){void 0===t&&(t="");for(var a=[],r=0,i=Object.entries(e);r<i.length;r++){var n=i[r],s=n[0],o=n[1],l=t?t+"["+s+"]":s;"object"==typeof o&&null!==o?a.push.apply(a,objectToHarParams(o,l)):a.push({name:l,value:String(o)})}return a}export function isDefined(e){return void 0!==e}export function capitalizeFirst(e){return e.charAt(0).toUpperCase()+e.slice(1)}
|
|
2
2
|
//# sourceMappingURL=generator.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__decorate}from"tslib";import{bind,debounce}from"decko";import EventEmitter from"eventemitter3";import{IS_BROWSER}from"../../redoc-lib";import{isSameHash,joinWithSeparator}from"./helpers";var PushStateHistoryService=function(){function e(e,t){var i=this;Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"multispec",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_emiter",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"basePath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"markdownItemsPagination",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pagination",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"emit",{enumerable:!0,configurable:!0,writable:!0,value:function(){i._emiter.emit("popstate",i.currentId)}});var r=e.routingBasePath;this.markdownItemsPagination=e.markdownItemsPagination,this.pagination=e.pagination,this.basePath=r.endsWith("/")?r.substring(0,r.length-1):r,this.basePath.startsWith("/")&&(this.basePath=this.basePath.substring(1)),this._emiter=new EventEmitter,this.bind()}return Object.defineProperty(e.prototype,"currentId",{get:function(){if(!IS_BROWSER)return"";var e=decodeURIComponent(window.location.hash.substr(1)),t=window.location.pathname.substring(1);
|
|
1
|
+
import{__decorate}from"tslib";import{bind,debounce}from"decko";import EventEmitter from"eventemitter3";import{IS_BROWSER}from"../../redoc-lib";import{isSameHash,joinWithSeparator}from"./helpers";var PushStateHistoryService=function(){function e(e,t){var i=this;Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"multispec",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_emiter",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"basePath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"markdownItemsPagination",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pagination",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"emit",{enumerable:!0,configurable:!0,writable:!0,value:function(){i._emiter.emit("popstate",i.currentId)}});var r=e.routingBasePath;this.markdownItemsPagination=e.markdownItemsPagination,this.pagination=e.pagination,this.basePath=r.endsWith("/")?r.substring(0,r.length-1):r,this.basePath.startsWith("/")&&(this.basePath=this.basePath.substring(1)),this._emiter=new EventEmitter,this.bind()}return Object.defineProperty(e.prototype,"currentId",{get:function(){if(!IS_BROWSER)return"";var e=decodeURIComponent(window.location.hash.substr(1)),t=window.location.pathname.substring(1);return t.startsWith(this.basePath+"/")&&(t=t.substring(this.basePath.length+1)),t.endsWith("/")&&(t=t.substring(0,t.length-1)),(null==e?void 0:e.startsWith("section/"))||(null==e?void 0:e.startsWith("operation/"))?joinWithSeparator(t,e):t?"item"===this.pagination&&e.startsWith(this.options.deepLinkPrefix)?joinWithSeparator(t,e,this.options.deepLinkPrefix):joinWithSeparator(t,e):e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"makeUrl",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var i,r="";return IS_BROWSER&&(r=window.location.search),(i=e.startsWith("/")?"/"+joinWithSeparator(this.basePath,e.substring(1),"/"):e)+r?joinWithSeparator(i+r,t,"#"):"#"+t}}),Object.defineProperty(e.prototype,"generateDeepLink",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return t?t+("item"===this.options.pagination?"#":"")+this.options.deepLinkPrefix+e:null}}),Object.defineProperty(e.prototype,"linkForId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(void 0===e&&(e=""),""===e)return this.makeUrl("/","");var t="";if(this.multispec&&(t="/"+e.split("/")[0],e=e.split("/").slice(1).join("/")),e.startsWith("operation/")){if(this.multispec&&IS_BROWSER){var i=window.location.pathname.substring(1);i.startsWith(this.basePath)&&(i=i.substring(this.basePath.length)).startsWith("/")&&(i=i.substring(1));var r="/"+i.split("/")[0];return t===r?this.makeUrl("",e):this.makeUrl(i.replace(r,t),e)}return this.makeUrl("",e)}var n,a=t,o="";if(e.startsWith("section/")||!e){var s=(e||"").split("/")[1];s&&"section"===this.markdownItemsPagination?(a=t+"/section/"+s,o=e):(a=t+"/",o=e)}if(e.startsWith("group/")){var l=e.match(/group\/(.*)\/(paths\/.*\/\w+|operation\/[^/]*)/);if(l)a=t+"/group/"+l[1],o=l[2]||"";else a=t+"/"+e,o=""}"section"===this.pagination&&e.startsWith("tag/")&&(a=t+"/"+(n=e.split("/")).slice(0,2).join("/"),o=n.slice(2).join("/"));"item"===this.pagination&&e.startsWith("tag/")&&(a=t+"/"+e,"section"===(n=e.split("/"))[2]&&(a=t+"/"+n.slice(0,2).join("/"),o=n.slice(2).join("/")));return this.makeUrl(a,o)}}),Object.defineProperty(e.prototype,"subscribe",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this._emiter.addListener("popstate",e);return function(){return t.removeListener("popstate",e)}}}),Object.defineProperty(e.prototype,"bind",{enumerable:!1,configurable:!0,writable:!0,value:function(){IS_BROWSER&&window.addEventListener("popstate",this.emit,!1)}}),Object.defineProperty(e.prototype,"dispose",{enumerable:!1,configurable:!0,writable:!0,value:function(){IS_BROWSER&&window.removeEventListener("popstate",this.emit)}}),Object.defineProperty(e.prototype,"replace",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(void 0===t&&(t=!1),t)return this.replaceDebounced(e);this.replaceNow(e,t)}}),Object.defineProperty(e.prototype,"replaceForField",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(void 0===t&&(t=!1),IS_BROWSER&&e){var i,r=new URL(e,window.location.href);i=r,t&&window.history.replaceState(null,"",i),window.history.pushState(null,"",i),this.emit()}}}),Object.defineProperty(e.prototype,"replaceNow",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(void 0===t&&(t=!1),IS_BROWSER&&null!=e&&!isSameHash(e,this.currentId)){var i=new URL(this.linkForId(e),window.location.href);t?IS_BROWSER&&window.history.replaceState(null,"",i.href):IS_BROWSER&&(window.history.pushState(null,"",i.href),this.emit())}}}),Object.defineProperty(e.prototype,"replaceDebounced",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.replaceNow(e,!0)}}),__decorate([bind],e.prototype,"replace",null),__decorate([bind],e.prototype,"replaceForField",null),__decorate([bind,debounce],e.prototype,"replaceDebounced",null),e}();export{PushStateHistoryService};
|
|
2
2
|
//# sourceMappingURL=PushStateHistoryService.js.map
|
package/lib-esm/types.d.ts
CHANGED