@redocly/reference-docs 2.22.0 → 2.24.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 +26 -26
- package/bin/cli/commands/redocly-docs-cli.min.js.LICENSE.txt +1 -1
- package/dist/console.redocly-reference-docs.min.js +96 -96
- package/dist/oauth2-redirect.js +1 -1
- package/dist/redocly-reference-docs.min.js +906 -906
- package/lib/components/NextSectionButton.js +1 -1
- package/lib/components/console/CodemirrorInput.d.ts +1 -1
- package/lib/components/console/CodemirrorInput.js +1 -1
- package/lib/components/console/Console.js +1 -1
- package/lib/components/console/RequestBody.d.ts +2 -2
- package/lib/components/console/RequestBody.js +1 -1
- package/lib/redoc-lib/src/common-elements/CopyButtonWrapper.js +1 -1
- package/lib/redoc-lib/src/components/Loading/Loading.js +1 -1
- package/lib/redoc-lib/src/components/Loading/{Spinner.svg.d.ts → Spinner.d.ts} +0 -0
- package/lib/redoc-lib/src/components/Loading/{Spinner.svg.js → Spinner.js} +1 -1
- package/lib/redoc-lib/src/components/RequestSamples/RequestSamples.js +1 -1
- package/lib/redoc-lib/src/components/SourceCode/SourceCode.js +1 -1
- package/lib/redoc-lib/src/services/models/Operation.d.ts +6 -0
- package/lib/redoc-lib/src/services/models/Operation.js +1 -1
- package/lib/services/ProStore.js +1 -1
- package/lib/services/code-samples/generator.js +1 -1
- package/lib/services/history/ProHashHistoryService.js +1 -1
- package/lib-esm/components/NextSectionButton.js +1 -1
- package/lib-esm/components/console/CodemirrorInput.d.ts +1 -1
- package/lib-esm/components/console/CodemirrorInput.js +1 -1
- package/lib-esm/components/console/Console.js +1 -1
- package/lib-esm/components/console/RequestBody.d.ts +2 -2
- package/lib-esm/components/console/RequestBody.js +1 -1
- package/lib-esm/redoc-lib/src/common-elements/CopyButtonWrapper.js +1 -1
- package/lib-esm/redoc-lib/src/components/Loading/Loading.js +1 -1
- package/lib-esm/redoc-lib/src/components/Loading/{Spinner.svg.d.ts → Spinner.d.ts} +0 -0
- package/lib-esm/redoc-lib/src/components/Loading/{Spinner.svg.js → Spinner.js} +1 -1
- package/lib-esm/redoc-lib/src/components/RequestSamples/RequestSamples.js +1 -1
- package/lib-esm/redoc-lib/src/components/SourceCode/SourceCode.js +1 -1
- package/lib-esm/redoc-lib/src/services/models/Operation.d.ts +6 -0
- package/lib-esm/redoc-lib/src/services/models/Operation.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/ProHashHistoryService.js +1 -1
- package/package.json +2 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign,__awaiter,__decorate,__extends,__generator,__rest}from"tslib";import*as React from"react";import{Form,useField}from"informed";import{observer}from"mobx-react";import Swagger from"swagger-client";import{get,useDimensions,unescapeFormId}from"../../utils";import{AnalyticsEventType}from"../../services";import{JsonPointer}from"../../redoc-lib";import{RenderHook}from"../../redoc-lib/src/components/RenderHook";import{l}from"../../redoc-lib/src/services/Labels";import{CodeHeader,Accordion}from"../Panel";import{OAuth2}from"../../services/OAuth2";import{isFileUploadMime}from"../common/FileUpload/helper";import{getFileNameFromHeaders,getParameters,makeRequestInterceptor,unescapeQueryParams,updateStorage}from"./utils";import{AuthPanel,requiredValidator}from"./AuthPanel";import{ConsoleBadges}from"./ConsoleBadges";import{RequestBody}from"./RequestBody";import{ResponsePanel}from"./ResponsePanel";import{ActionPanel}from"./ActionPanel";import{OperationParameters}from"./OperationParameters";import{ServerChooser}from"./ServerDropdown";import{TryItPanel}from"./TryItPanel";import{CloseButton,ConsoleBody,ConsoleWrap}from"./styled";function normalizeUrlProtocol(e){return e.startsWith("//")?"https:"+e:e}var flexColumn={flex:1,display:"flex",flexDirection:"column"},Console=function(e){function t(t){var r=e.call(this,t)||this;return Object.defineProperty(r,"formApi",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"setFormApi",{enumerable:!0,configurable:!0,writable:!0,value:function(e,t){void 0===t&&(t=e.getState());var o=t.values,a=__rest(t,["values"]);r.formApi=e,setTimeout((function(){var e=__assign(__assign({},a),{values:__assign(__assign({},o),{query:unescapeQueryParams(o.query||{})})});r.setState({form:e})}),0)}}),Object.defineProperty(r,"handleChange",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var t=e.values,o=__rest(e,["values"]),a=__assign(__assign({},o),{values:__assign(__assign({},t),{query:unescapeQueryParams(t.query||{})})});r.setState({form:a}),updateStorage(a)}}),Object.defineProperty(r,"handleTabChange",{enumerable:!0,configurable:!0,writable:!0,value:function(e){r.setState({activeTab:e})}}),Object.defineProperty(r,"handleServerChange",{enumerable:!0,configurable:!0,writable:!0,value:function(e){r.setState({server:e}),r.props.operation.setActiveServer(e)}}),Object.defineProperty(r,"handleExecute",{enumerable:!0,configurable:!0,writable:!0,value:function(){return __awaiter(r,void 0,void 0,(function(){var e,t,r,o,a,n,s,i,l,u,c,p,d,m,h,v,g,f,y,_,b,P,R,S,C,w,E,A,I,k,T,q,O,F,B,x,H,j,V,D,U=this;return __generator(this,(function(N){switch(N.label){case 0:if(e=this.props,t=e.store,r=e.operation,o=e.onResponse,a=this.state.form,n=a.values,s=a.invalid,this.formApi.submitForm(),s)return this.setState({shaking:!0}),setTimeout((function(){return U.setState({shaking:!1})}),1e3),null===(B=null===(F=null==t?void 0:t.options.events)||void 0===F?void 0:F.tryItSent)||void 0===B||B.call(F,{eventType:AnalyticsEventType.TryItSent,resource:"Redocly_OperationTryIt",action:"ValidationFailed",operationId:r.operationId,operationPath:r.path,operationHttpVerb:r.httpVerb,operationSummary:r.description}),[2];if(i=this.props.operation.requestBody,l=i&&i.content&&i.content.active&&i.content.active.name||"",u=n.body,/json/.test(l))try{u=JSON.parse(u)}catch(e){console.error(e)}if(this.setState({loading:!0}),c=this.state.resolvedRawSpec,p=(r.httpVerb||"").toLowerCase(),!(d=get(c,["paths",r.path,p,"servers"])||get(c,["paths",r.path,"servers"])||get(c,["servers"])))throw console.error("Servers are not specified in your OpenAPI file. You can't use Try It Out console without specifying servers. If you use OpenAPI 2, make sure you configured host and basepath"),new Error("Servers are not specified");m=d.find((function(e){return U.state.server.url.endsWith(e.url.endsWith("/")?e.url.substring(0,e.url.length-1):e.url)})),h=Date.now(),v=!!window.document.documentMode,f=n.auth,n.auth?(y=Object.keys(n.auth)[0],_=unescapeFormId(y),g=__assign(__assign({},c),{components:__assign(__assign({},c.components),{securitySchemes:__assign(__assign({},c.components.securitySchemes),(k={},k[_]=__assign(__assign({},c.components.securitySchemes[_]),{type:"openIdConnect"===c.components.securitySchemes[_].type?"oauth2":c.components.securitySchemes[_].type}),k))})}),f=__assign(__assign({},f),((T={})[_]=f[y],T))):g=__assign({},c),(b=t.options.corsProxyUrl)&&d.length&&(g.servers=d.map((function(e){return __assign(__assign({},e),{url:b+normalizeUrlProtocol(e.url)})})),g.paths=__assign(__assign({},g.paths),((q={})[r.path]=__assign(__assign({},g.paths[r.path]),((O={})[p]=__assign(__assign({},g.paths[r.path][p]),{servers:void 0}),O.servers=void 0,O)),q))),(P=(null===(H=null===(x=null==i?void 0:i.content)||void 0===x?void 0:x.active)||void 0===H?void 0:H.name)||null)&&u&&isFileUploadMime(P)&&(R=Object.values(u),u=R.length>1?R:R[0]),S={userFetch:v&&require("cross-fetch").fetch,server:b?b+normalizeUrlProtocol(m.url):m.url,serverVariables:this.state.server.variables,spec:g,pathName:r.path,method:r.httpVerb,parameters:__assign(__assign(__assign(__assign({},n.path),n.query),n.header),n.cookie),securities:{authorized:f},requestBody:u,requestContentType:P,responseContentType:(null===(j=n.header)||void 0===j?void 0:j.Accept)||null,requestInterceptor:makeRequestInterceptor(t.options,r)},N.label=1;case 1:return N.trys.push([1,5,8,9]),[4,Swagger.execute(S)];case 2:return C=N.sent(),(w=null==C?void 0:C.data)instanceof Blob?(isFileUploadMime(w.type)&&(C.fileInfo={rawData:w,fileName:getFileNameFromHeaders(C.headers)}),E=C,[4,w.text()]):[3,4];case 3:E.data=N.sent(),N.label=4;case 4:return null==o||o({request:S,response:C}),this.setState({response:C,error:void 0}),[3,9];case 5:return(A=N.sent())&&A.response&&A.response.data instanceof Blob?(I=A.response,[4,A.response.data.text()]):[3,7];case 6:I.data=N.sent(),null==o||o({request:S,response:A.response}),N.label=7;case 7:return this.setState({response:void 0,error:A}),[3,9];case 8:return this.setState({loading:!1,activeTab:1,time:Date.now()-h}),null===(D=null===(V=null==t?void 0:t.options.events)||void 0===V?void 0:V.tryItSent)||void 0===D||D.call(V,{eventType:AnalyticsEventType.TryItSent,resource:"Redocly_OperationTryIt",action:"Sent",operationId:r.operationId,operationPath:r.path,operationHttpVerb:r.httpVerb,operationSummary:r.description}),[7];case 9:return[2]}}))}))}}),r.state={form:{values:{path:getParameters(t.operation.parameters,"path"),cookie:getParameters(t.operation.parameters,"cookie"),header:getParameters(t.operation.parameters,"header"),query:getParameters(t.operation.parameters,"query")}},shaking:!1,loading:!1,activeTab:0,server:{}},r}return __extends(t,e),Object.defineProperty(t.prototype,"componentDidMount",{enumerable:!1,configurable:!0,writable:!0,value:function(){return __awaiter(this,void 0,void 0,(function(){var e,t,r,o;return __generator(this,(function(a){switch(a.label){case 0:return e=this.props,t=e.store,r=e.operation,[4,t.dereferenceSpecForTryIt(r)];case 1:return o=a.sent(),this.setState({resolvedRawSpec:o}),this.formApi.setValues({}),[2]}}))}))}}),Object.defineProperty(t.prototype,"componentDidUpdate",{enumerable:!1,configurable:!0,writable:!0,value:function(e){e.operation!==this.props.operation&&this.setState({response:void 0,error:void 0,activeTab:0})}}),Object.defineProperty(t.prototype,"render",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this.props,t=e.operation,r=e.className,o=e.rootElement,a=this.state,n=a.shaking,s=a.activeTab,i=a.form,l=a.response,u=a.loading,c=a.error,p=!(!l&&!c);return React.createElement(ConsoleWrapHook,{shaking:n,className:r,rootElement:o},React.createElement(CodeHeader,null,React.createElement(ConsoleBadges,{active:s,hasResponse:p,onChange:this.handleTabChange}),this.props.onClose&&React.createElement(CloseButton,{onClick:this.props.onClose}," ✕ ")),React.createElement(ConsoleBody,{hidden:0!==s},this.renderRequest()),React.createElement(ConsoleBody,{hidden:1!==s},this.renderResponse()),React.createElement(ActionPanel,{hasResponse:p,params:i.values,operation:t,loading:u,execute:this.handleExecute}))}}),Object.defineProperty(t.prototype,"renderRequest",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e,t=this.props,r=t.operation,o=t.store,a=t.properties,n=t.securityDefaults,s=this.state,i=s.form,u=s.resolvedRawSpec,c=s.server,p=i.errors||{},d=p.path||p.cookie||p.header||p.query,m=u&&JsonPointer.get(u,r.pointer),h=i.values&&i.values.auth&&Object.keys(i.values.auth)[0];h&&i.values.auth[h]||(h=void 0),!h||void 0===i.values.auth[h].token&&void 0===i.values.auth[h].client_id&&void 0===i.values.auth[h].client_secret||i.values.auth[h].token&&i.values.auth[h].token.access_token||(h=void 0),h&&null!=i.values.auth[h].username&&(i.values.auth[h].username&&i.values.auth[h].password||(h=void 0));var v=r.parameters||[],g=null===(e=null==o?void 0:o.options.hooks)||void 0===e?void 0:e.ReplaceTryItSecurityPanel;return!u&&React.createElement(React.Fragment,null,"Loading...")||React.createElement(React.Fragment,null,React.createElement(Form,{onChange:this.handleChange,getApi:this.setFormApi,style:__assign(__assign({},flexColumn),{margin:0})},React.createElement(Accordion,{initialActiveIdx:r.security.length&&h?1:0},r.security.length&&React.createElement(TryItPanel,{header:l("tryItAuth"),"data-cy":"security-trigger",renderChildrenHidden:!0,error:!h&&!!p.auth,success:!!h},g?React.createElement(AuthPanelHook,{field:"auth",validate:requiredValidator},(function(e){return React.createElement(RenderHook,{Hook:g,props:{server:c,operation:r,onChange:e,OAuth2:OAuth2}})})):React.createElement(AuthPanel,{formApi:this.formApi,form:i,operation:r,activeServer:c.url,authCorsProxyUrl:o.options.authCorsProxyUrl,securityDefaults:n}))||null,r.requestBody&&React.createElement(TryItPanel,{header:l("tryItBody"),"data-cy":"body-trigger",renderChildrenHidden:!0,error:!!p.body},React.createElement(RequestBody,{validate:allowBodyErrors,console:this,body:r.requestBody,id:r.id,resolvedBody:m.requestBody,properties:a}))||null,v.length&&React.createElement(TryItPanel,{header:l("tryItParameters"),"data-cy":"parameters-trigger",error:d,renderChildrenHidden:!0},React.createElement(OperationParameters,{operation:r,values:i.values,errors:i.errors||{}}))||null)),React.createElement(ServerChooser,{operation:r,onChange:this.handleServerChange}))}}),Object.defineProperty(t.prototype,"renderResponse",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this.state,t=e.response,r=e.error,o=e.time;return React.createElement(ResponsePanel,{response:t,error:r,time:o})}}),t=__decorate([observer],t)}(React.Component);export{Console};function allowBodyErrors(){}function ConsoleWrapHook(e){var t=e.shaking,r=e.className,o=e.children,a=e.rootElement,n=useDimensions(a)[0];return React.createElement(ConsoleWrap,{shaking:t,className:r,"data-cy":"console",fullWidth:null==n?void 0:n.width},o)}function AuthPanelHook(e){var t=useField(__assign({},e)),r=t.fieldApi,o=t.render,a=t.userProps,n=r.setValue,s=a.children;return o(React.createElement(React.Fragment,null,s(n)))}
|
|
1
|
+
import{__assign,__awaiter,__decorate,__extends,__generator,__rest}from"tslib";import*as React from"react";import{Form,useField}from"informed";import{observer}from"mobx-react";import Swagger from"swagger-client";import{get,useDimensions,unescapeFormId}from"../../utils";import{AnalyticsEventType}from"../../services";import{JsonPointer}from"../../redoc-lib";import{RenderHook}from"../../redoc-lib/src/components/RenderHook";import{l}from"../../redoc-lib/src/services/Labels";import{CodeHeader,Accordion}from"../Panel";import{OAuth2}from"../../services/OAuth2";import{isFileUploadMime}from"../common/FileUpload/helper";import{getFileNameFromHeaders,getParameters,makeRequestInterceptor,unescapeQueryParams,updateStorage}from"./utils";import{AuthPanel,requiredValidator}from"./AuthPanel";import{ConsoleBadges}from"./ConsoleBadges";import{RequestBody}from"./RequestBody";import{ResponsePanel}from"./ResponsePanel";import{ActionPanel}from"./ActionPanel";import{OperationParameters}from"./OperationParameters";import{ServerChooser}from"./ServerDropdown";import{TryItPanel}from"./TryItPanel";import{CloseButton,ConsoleBody,ConsoleWrap}from"./styled";function normalizeUrlProtocol(e){return e.startsWith("//")?"https:"+e:e}var flexColumn={flex:1,display:"flex",flexDirection:"column"},Console=function(e){function t(t){var r=e.call(this,t)||this;return Object.defineProperty(r,"formApi",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"setFormApi",{enumerable:!0,configurable:!0,writable:!0,value:function(e,t){void 0===t&&(t=e.getState());var o=t.values,a=__rest(t,["values"]);r.formApi=e,setTimeout((function(){var e=__assign(__assign({},a),{values:__assign(__assign({},o),{query:unescapeQueryParams(o.query||{})})});r.setState({form:e})}),0)}}),Object.defineProperty(r,"handleChange",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var t=e.values,o=__rest(e,["values"]),a=__assign(__assign({},o),{values:__assign(__assign({},t),{query:unescapeQueryParams(t.query||{})})});r.setState({form:a}),updateStorage(a),r.props.operation.setRequestValues(t)}}),Object.defineProperty(r,"handleTabChange",{enumerable:!0,configurable:!0,writable:!0,value:function(e){r.setState({activeTab:e})}}),Object.defineProperty(r,"handleServerChange",{enumerable:!0,configurable:!0,writable:!0,value:function(e){r.setState({server:e}),r.props.operation.setActiveServer(e)}}),Object.defineProperty(r,"handleExecute",{enumerable:!0,configurable:!0,writable:!0,value:function(){return __awaiter(r,void 0,void 0,(function(){var e,t,r,o,a,n,s,i,l,u,c,p,d,m,h,v,g,f,y,_,b,P,R,S,C,w,E,A,I,k,q,T,O,F,B,x,H,j,V,D,U=this;return __generator(this,(function(N){switch(N.label){case 0:if(e=this.props,t=e.store,r=e.operation,o=e.onResponse,a=this.state.form,n=a.values,s=a.invalid,this.formApi.submitForm(),s)return this.setState({shaking:!0}),setTimeout((function(){return U.setState({shaking:!1})}),1e3),null===(B=null===(F=null==t?void 0:t.options.events)||void 0===F?void 0:F.tryItSent)||void 0===B||B.call(F,{eventType:AnalyticsEventType.TryItSent,resource:"Redocly_OperationTryIt",action:"ValidationFailed",operationId:r.operationId,operationPath:r.path,operationHttpVerb:r.httpVerb,operationSummary:r.description}),[2];if(i=this.props.operation.requestBody,l=i&&i.content&&i.content.active&&i.content.active.name||"",u=n.body,/json/.test(l))try{u=JSON.parse(u)}catch(e){console.error(e)}if(this.setState({loading:!0}),c=this.state.resolvedRawSpec,p=(r.httpVerb||"").toLowerCase(),!(d=get(c,["paths",r.path,p,"servers"])||get(c,["paths",r.path,"servers"])||get(c,["servers"])))throw console.error("Servers are not specified in your OpenAPI file. You can't use Try It Out console without specifying servers. If you use OpenAPI 2, make sure you configured host and basepath"),new Error("Servers are not specified");m=d.find((function(e){return U.state.server.url.endsWith(e.url.endsWith("/")?e.url.substring(0,e.url.length-1):e.url)})),h=Date.now(),v=!!window.document.documentMode,f=n.auth,n.auth?(y=Object.keys(n.auth)[0],_=unescapeFormId(y),g=__assign(__assign({},c),{components:__assign(__assign({},c.components),{securitySchemes:__assign(__assign({},c.components.securitySchemes),(k={},k[_]=__assign(__assign({},c.components.securitySchemes[_]),{type:"openIdConnect"===c.components.securitySchemes[_].type?"oauth2":c.components.securitySchemes[_].type}),k))})}),f=__assign(__assign({},f),((q={})[_]=f[y],q))):g=__assign({},c),(b=t.options.corsProxyUrl)&&d.length&&(g.servers=d.map((function(e){return __assign(__assign({},e),{url:b+normalizeUrlProtocol(e.url)})})),g.paths=__assign(__assign({},g.paths),((T={})[r.path]=__assign(__assign({},g.paths[r.path]),((O={})[p]=__assign(__assign({},g.paths[r.path][p]),{servers:void 0}),O.servers=void 0,O)),T))),(P=(null===(H=null===(x=null==i?void 0:i.content)||void 0===x?void 0:x.active)||void 0===H?void 0:H.name)||null)&&u&&isFileUploadMime(P)&&(R=Object.values(u),u=R.length>1?R:R[0]),S={userFetch:v&&require("cross-fetch").fetch,server:b?b+normalizeUrlProtocol(m.url):m.url,serverVariables:this.state.server.variables,spec:g,pathName:r.path,method:r.httpVerb,parameters:__assign(__assign(__assign(__assign({},n.path),n.query),n.header),n.cookie),securities:{authorized:f},requestBody:u,requestContentType:P,responseContentType:(null===(j=n.header)||void 0===j?void 0:j.Accept)||null,requestInterceptor:makeRequestInterceptor(t.options,r)},N.label=1;case 1:return N.trys.push([1,5,8,9]),[4,Swagger.execute(S)];case 2:return C=N.sent(),(w=null==C?void 0:C.data)instanceof Blob?(isFileUploadMime(w.type)&&(C.fileInfo={rawData:w,fileName:getFileNameFromHeaders(C.headers)}),E=C,[4,w.text()]):[3,4];case 3:E.data=N.sent(),N.label=4;case 4:return null==o||o({request:S,response:C}),this.setState({response:C,error:void 0}),[3,9];case 5:return(A=N.sent())&&A.response&&A.response.data instanceof Blob?(I=A.response,[4,A.response.data.text()]):[3,7];case 6:I.data=N.sent(),null==o||o({request:S,response:A.response}),N.label=7;case 7:return this.setState({response:void 0,error:A}),[3,9];case 8:return this.setState({loading:!1,activeTab:1,time:Date.now()-h}),null===(D=null===(V=null==t?void 0:t.options.events)||void 0===V?void 0:V.tryItSent)||void 0===D||D.call(V,{eventType:AnalyticsEventType.TryItSent,resource:"Redocly_OperationTryIt",action:"Sent",operationId:r.operationId,operationPath:r.path,operationHttpVerb:r.httpVerb,operationSummary:r.description}),[7];case 9:return[2]}}))}))}}),r.state={form:{values:{path:getParameters(t.operation.parameters,"path"),cookie:getParameters(t.operation.parameters,"cookie"),header:getParameters(t.operation.parameters,"header"),query:getParameters(t.operation.parameters,"query")}},shaking:!1,loading:!1,activeTab:0,server:{}},r}return __extends(t,e),Object.defineProperty(t.prototype,"componentDidMount",{enumerable:!1,configurable:!0,writable:!0,value:function(){return __awaiter(this,void 0,void 0,(function(){var e,t,r,o;return __generator(this,(function(a){switch(a.label){case 0:return e=this.props,t=e.store,r=e.operation,[4,t.dereferenceSpecForTryIt(r)];case 1:return o=a.sent(),this.setState({resolvedRawSpec:o}),this.formApi.setValues({}),[2]}}))}))}}),Object.defineProperty(t.prototype,"componentDidUpdate",{enumerable:!1,configurable:!0,writable:!0,value:function(e){e.operation!==this.props.operation&&this.setState({response:void 0,error:void 0,activeTab:0})}}),Object.defineProperty(t.prototype,"render",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this.props,t=e.operation,r=e.className,o=e.rootElement,a=this.state,n=a.shaking,s=a.activeTab,i=a.form,l=a.response,u=a.loading,c=a.error,p=!(!l&&!c);return React.createElement(ConsoleWrapHook,{shaking:n,className:r,rootElement:o},React.createElement(CodeHeader,null,React.createElement(ConsoleBadges,{active:s,hasResponse:p,onChange:this.handleTabChange}),this.props.onClose&&React.createElement(CloseButton,{onClick:this.props.onClose}," ✕ ")),React.createElement(ConsoleBody,{hidden:0!==s},this.renderRequest()),React.createElement(ConsoleBody,{hidden:1!==s},this.renderResponse()),React.createElement(ActionPanel,{hasResponse:p,params:i.values,operation:t,loading:u,execute:this.handleExecute}))}}),Object.defineProperty(t.prototype,"renderRequest",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e,t=this.props,r=t.operation,o=t.store,a=t.properties,n=t.securityDefaults,s=this.state,i=s.form,u=s.resolvedRawSpec,c=s.server,p=i.errors||{},d=p.path||p.cookie||p.header||p.query,m=u&&JsonPointer.get(u,r.pointer),h=i.values&&i.values.auth&&Object.keys(i.values.auth)[0];h&&i.values.auth[h]||(h=void 0),!h||void 0===i.values.auth[h].token&&void 0===i.values.auth[h].client_id&&void 0===i.values.auth[h].client_secret||i.values.auth[h].token&&i.values.auth[h].token.access_token||(h=void 0),h&&null!=i.values.auth[h].username&&(i.values.auth[h].username&&i.values.auth[h].password||(h=void 0));var v=r.parameters||[],g=null===(e=null==o?void 0:o.options.hooks)||void 0===e?void 0:e.ReplaceTryItSecurityPanel;return!u&&React.createElement(React.Fragment,null,"Loading...")||React.createElement(React.Fragment,null,React.createElement(Form,{onChange:this.handleChange,getApi:this.setFormApi,style:__assign(__assign({},flexColumn),{margin:0})},React.createElement(Accordion,{initialActiveIdx:r.security.length&&h?1:0},r.security.length&&React.createElement(TryItPanel,{header:l("tryItAuth"),"data-cy":"security-trigger",renderChildrenHidden:!0,error:!h&&!!p.auth,success:!!h},g?React.createElement(AuthPanelHook,{field:"auth",validate:requiredValidator},(function(e){return React.createElement(RenderHook,{Hook:g,props:{server:c,operation:r,onChange:e,OAuth2:OAuth2}})})):React.createElement(AuthPanel,{formApi:this.formApi,form:i,operation:r,activeServer:c.url,authCorsProxyUrl:o.options.authCorsProxyUrl,securityDefaults:n}))||null,r.requestBody&&React.createElement(TryItPanel,{header:l("tryItBody"),"data-cy":"body-trigger",renderChildrenHidden:!0,error:!!p.body},React.createElement(RequestBody,{validate:allowBodyErrors,console:this,body:r.requestBody,id:r.id,resolvedBody:m.requestBody,properties:a}))||null,v.length&&React.createElement(TryItPanel,{header:l("tryItParameters"),"data-cy":"parameters-trigger",error:d,renderChildrenHidden:!0},React.createElement(OperationParameters,{operation:r,values:i.values,errors:i.errors||{}}))||null)),React.createElement(ServerChooser,{operation:r,onChange:this.handleServerChange}))}}),Object.defineProperty(t.prototype,"renderResponse",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this.state,t=e.response,r=e.error,o=e.time;return React.createElement(ResponsePanel,{response:t,error:r,time:o})}}),t=__decorate([observer],t)}(React.Component);export{Console};function allowBodyErrors(){}function ConsoleWrapHook(e){var t=e.shaking,r=e.className,o=e.children,a=e.rootElement,n=useDimensions(a)[0];return React.createElement(ConsoleWrap,{shaking:t,className:r,"data-cy":"console",fullWidth:null==n?void 0:n.width},o)}function AuthPanelHook(e){var t=useField(__assign({},e)),r=t.fieldApi,o=t.render,a=t.userProps,n=r.setValue,s=a.children;return o(React.createElement(React.Fragment,null,s(n)))}
|
|
2
2
|
//# sourceMappingURL=Console.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import * as React from 'react';
|
|
2
2
|
import type { RequestBodyModel } from '../../redoc-lib';
|
|
3
3
|
import type { Console } from './Console';
|
|
4
4
|
export interface RequestBodyProps {
|
|
@@ -9,4 +9,4 @@ export interface RequestBodyProps {
|
|
|
9
9
|
id: string;
|
|
10
10
|
properties: any;
|
|
11
11
|
}
|
|
12
|
-
export declare const RequestBody: (
|
|
12
|
+
export declare const RequestBody: React.MemoExoticComponent<(props: RequestBodyProps) => JSX.Element>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var _this=this;import{__assign,__awaiter,__generator
|
|
1
|
+
var _this=this;import{__assign,__awaiter,__generator}from"tslib";import*as React from"react";import{useEffect}from"react";import{observer}from"mobx-react";import merge from"deepmerge";import{DropdownOrLabel,MediaTypesSwitch}from"../../redoc-lib";import{ExampleSwitch,useExampleKey}from"../Samples";import{arrayMergeStrategy}from"../../services/utils";import{isRootFileUpload}from"../common/FileUpload/helper";import{MediaTypes}from"../../models";import{Dropdown}from"../common/Dropdown";import{RequestBodyForm}from"./RequestBodyForm";import{RequestMimeLabel}from"./RequestMimeLabel";import CodemirrorInput from"./CodemirrorInput";var RequestBodyComponent=observer((function(e){var r,o=e.body.content,t=e.console.formApi,a=function(e){return void 0===e&&(e={}),Array.isArray(e)?[]:{}},n=function(r){var t;if(!o||!o.hasSample)return"";var n=null===(t=o.active)||void 0===t?void 0:t.examples;if(!(null==n?void 0:n[r]))return"";var i=null==n?void 0:n[r].value,m=merge(i,e.properties||a(i),{arrayMerge:arrayMergeStrategy});return JSON.stringify(m,null,2)},i=null===(r=null==o?void 0:o.operation)||void 0===r?void 0:r.activeExampleName,m=function(e){var r;null===(r=null==o?void 0:o.operation)||void 0===r||r.activateExampleName(e),t.setValue("body",n(e))},l=function(r){if(!r)return"";if("application/x-www-form-urlencoded"===r.mime)return r.value;var o=r.value,t=merge(o,e.properties||a(o),{arrayMerge:arrayMergeStrategy});return JSON.stringify(t,null,2)},d=function(e,r){return __awaiter(void 0,void 0,void 0,(function(){return __generator(this,(function(o){return(0,t.setValue)("body."+e,r),[2]}))}))};useEffect((function(){!1!==i?i&&t.setValue("body",n(i)):t.setValue("body",JSON.stringify(e.properties||a(),null,2))}),[i]);var u=e.validate,p=e.body;return React.createElement(React.Fragment,null,React.createElement(MediaTypesSwitch,{content:p.content,renderDropdown:function(e){return React.createElement(DropdownOrLabel,__assign({},e,{variant:"dark",fullWidth:!0,Label:RequestMimeLabel,Dropdown:Dropdown}))}},(function(r){var o,a=r.examples||{},n=Object.keys(a),i=r.schema,p=isRootFileUpload(i||{},r.name)||r.name===MediaTypes.MULTIPART||r.name===MediaTypes.URL_ENCODED,s=useExampleKey(r.operation,a).exampleKey,c=a[s];return React.createElement(React.Fragment,null,n.length&&1!==n.length&&React.createElement(ExampleSwitch,{examples:a,onChange:m,exampleKey:s})||null,p?React.createElement(RequestBodyForm,{mediaType:r,formApi:t,onChange:d.bind(_this)}):React.createElement(CodemirrorInput,{id:"body"+e.id,field:"body",initialValue:l(c),schema:((null===(o=null==e?void 0:e.resolvedBody)||void 0===o?void 0:o.content[r.name])||{}).schema,mode:r.name,validate:u}))})))}));export var RequestBody=React.memo(RequestBodyComponent);
|
|
2
2
|
//# sourceMappingURL=RequestBody.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__extends}from"tslib";import*as React from"react";import{ClipboardService}from"../services/ClipboardService";import{SamplesControlButton}from"./samples";import{Tooltip}from"./Tooltip";var CopyButtonWrapper=function(t){function e(e){var o=t.call(this,e)||this;return Object.defineProperty(o,"copy",{enumerable:!0,configurable:!0,writable:!0,value:function(){var t="string"==typeof o.props.data?o.props.data:JSON.stringify(o.props.data,null,2);ClipboardService.copyCustom(t),o.showTooltip()}}),Object.defineProperty(o,"renderCopyButton",{enumerable:!0,configurable:!0,writable:!0,value:function(){return React.createElement(Tooltip,{variant:"light",placement:"top",tip:ClipboardService.isSupported()?"Copied":"Not supported in your browser",open:o.state.tooltipShown},React.createElement(SamplesControlButton,{onClick:o.copy},"Copy"))}}),o.state={tooltipShown:!1},o}return __extends(e,t),Object.defineProperty(e.prototype,"render",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.props.children({renderCopyButton:this.renderCopyButton})}}),Object.defineProperty(e.prototype,"showTooltip",{enumerable:!1,configurable:!0,writable:!0,value:function(){var t=this;this.setState({tooltipShown:!0}),setTimeout((function(){t.setState({tooltipShown:!1})}),1500)}}),e}(React.PureComponent);export{CopyButtonWrapper};
|
|
1
|
+
import{__extends}from"tslib";import*as React from"react";import{ClipboardService}from"../services/ClipboardService";import{SamplesControlButton}from"./samples";import{Tooltip}from"./Tooltip";var CopyButtonWrapper=function(t){function e(e){var o=t.call(this,e)||this;return Object.defineProperty(o,"copy",{enumerable:!0,configurable:!0,writable:!0,value:function(){var t="string"==typeof o.props.data?o.props.data:JSON.stringify(o.props.data,(function(t,e){return void 0===e?null:e}),2);ClipboardService.copyCustom(t),o.showTooltip()}}),Object.defineProperty(o,"renderCopyButton",{enumerable:!0,configurable:!0,writable:!0,value:function(){return React.createElement(Tooltip,{variant:"light",placement:"top",tip:ClipboardService.isSupported()?"Copied":"Not supported in your browser",open:o.state.tooltipShown},React.createElement(SamplesControlButton,{onClick:o.copy},"Copy"))}}),o.state={tooltipShown:!1},o}return __extends(e,t),Object.defineProperty(e.prototype,"render",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.props.children({renderCopyButton:this.renderCopyButton})}}),Object.defineProperty(e.prototype,"showTooltip",{enumerable:!1,configurable:!0,writable:!0,value:function(){var t=this;this.setState({tooltipShown:!0}),setTimeout((function(){t.setState({tooltipShown:!1})}),1500)}}),e}(React.PureComponent);export{CopyButtonWrapper};
|
|
2
2
|
//# sourceMappingURL=CopyButtonWrapper.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__extends,__makeTemplateObject}from"tslib";import*as React from"react";import styled from"../../styled-components";import{Spinner}from"./Spinner
|
|
1
|
+
import{__extends,__makeTemplateObject}from"tslib";import*as React from"react";import styled from"../../styled-components";import{Spinner}from"./Spinner";var templateObject_1,LoadingMessage=styled.div(templateObject_1||(templateObject_1=__makeTemplateObject(["\n font-family: helvetica, sans;\n width: 100%;\n text-align: center;\n font-size: 25px;\n margin: 30px 0 20px 0;\n color: ",";\n"],["\n font-family: helvetica, sans;\n width: 100%;\n text-align: center;\n font-size: 25px;\n margin: 30px 0 20px 0;\n color: ",";\n"])),(function(e){return e.color})),Loading=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),Object.defineProperty(t.prototype,"render",{enumerable:!1,configurable:!0,writable:!0,value:function(){return React.createElement("div",{style:{textAlign:"center"}},React.createElement(LoadingMessage,{color:this.props.color},"Loading ..."),React.createElement(Spinner,{color:this.props.color}))}}),t}(React.PureComponent);export{Loading};
|
|
2
2
|
//# sourceMappingURL=Loading.js.map
|
|
File without changes
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{__makeTemplateObject}from"tslib";import*as React from"react";import styled,{keyframes}from"../../styled-components";var templateObject_1,templateObject_2,_Spinner=function(e){return React.createElement("svg",{className:e.className,version:"1.1",width:"512",height:"512",viewBox:"0 0 512 512"},React.createElement("path",{d:"M275.682 147.999c0 10.864-8.837 19.661-19.682 19.661v0c-10.875 0-19.681-8.796-19.681-19.661v-96.635c0-10.885 8.806-19.661 19.681-19.661v0c10.844 0 19.682 8.776 19.682 19.661v96.635z"}),React.createElement("path",{d:"M275.682 460.615c0 10.865-8.837 19.682-19.682 19.682v0c-10.875 0-19.681-8.817-19.681-19.682v-96.604c0-10.885 8.806-19.681 19.681-19.681v0c10.844 0 19.682 8.796 19.682 19.682v96.604z"}),React.createElement("path",{d:"M147.978 236.339c10.885 0 19.681 8.755 19.681 19.641v0c0 10.885-8.796 19.702-19.681 19.702h-96.624c-10.864 0-19.661-8.817-19.661-19.702v0c0-10.885 8.796-19.641 19.661-19.641h96.624z"}),React.createElement("path",{d:"M460.615 236.339c10.865 0 19.682 8.755 19.682 19.641v0c0 10.885-8.817 19.702-19.682 19.702h-96.584c-10.885 0-19.722-8.817-19.722-19.702v0c0-10.885 8.837-19.641 19.722-19.641h96.584z"}),React.createElement("path",{d:"M193.546 165.703c7.69 7.66 7.68 20.142 0 27.822v0c-7.701 7.701-20.162 7.701-27.853 0.020l-68.311-68.322c-7.68-7.701-7.68-20.142 0-27.863v0c7.68-7.68 20.121-7.68 27.822 0l68.342 68.342z"}),React.createElement("path",{d:"M414.597 386.775c7.7 7.68 7.7 20.163 0.021 27.863v0c-7.7 7.659-20.142 7.659-27.843-0.062l-68.311-68.26c-7.68-7.7-7.68-20.204 0-27.863v0c7.68-7.7 20.163-7.7 27.842 0l68.291 68.322z"}),React.createElement("path",{d:"M165.694 318.464c7.69-7.7 20.153-7.7 27.853 0v0c7.68 7.659 7.69 20.163 0 27.863l-68.342 68.322c-7.67 7.659-20.142 7.659-27.822-0.062v0c-7.68-7.68-7.68-20.122 0-27.801l68.311-68.322z"}),React.createElement("path",{d:"M386.775 97.362c7.7-7.68 20.142-7.68 27.822 0v0c7.7 7.68 7.7 20.183 0.021 27.863l-68.322 68.311c-7.68 7.68-20.163 7.68-27.843-0.020v0c-7.68-7.68-7.68-20.162 0-27.822l68.322-68.332z"}))},rotate=keyframes(templateObject_1||(templateObject_1=__makeTemplateObject(["\n 0% {\n transform: rotate(0deg); }\n 100% {\n transform: rotate(360deg);\n }\n"],["\n 0% {\n transform: rotate(0deg); }\n 100% {\n transform: rotate(360deg);\n }\n"])));export var Spinner=styled(_Spinner)(templateObject_2||(templateObject_2=__makeTemplateObject(["\n animation: 2s "," linear infinite;\n width: 50px;\n height: 50px;\n content: '';\n display: inline-block;\n margin-left: -25px;\n\n path {\n fill: ",";\n }\n"],["\n animation: 2s "," linear infinite;\n width: 50px;\n height: 50px;\n content: '';\n display: inline-block;\n margin-left: -25px;\n\n path {\n fill: ",";\n }\n"])),rotate,(function(e){return e.color}));
|
|
2
|
-
//# sourceMappingURL=Spinner.
|
|
2
|
+
//# sourceMappingURL=Spinner.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign,__rest}from"tslib";import React,{useContext,useEffect}from"react";import{observer}from"mobx-react";import{CodePanel}from"../../../../components/Panel";import{TabPanel}from"../../../../components/Tabs";import{SamplesTabs}from"../../../../components/Samples";import{isPayloadSample}from"../../services";import{PayloadSamples}from"../PayloadSamples/PayloadSamples";import{OptionsContext}from"../OptionsProvider";import{l}from"../../services/Labels";import{CodeSample}from"./CodeSample";import{useCodeSamples}from"./useCodeSamples";import{createLanguageSwitchEvent,creatPanelToggleEvent}from"./languageSwitchEvent";export var RequestSamples=observer((function(e){var a=e.operation,t=e.defaultLanguage,o=e.disableHeader,n=(e.content,__rest(e,["operation","defaultLanguage","disableHeader","content"])),r=useContext(OptionsContext),s=r.events,m=r.hideSingleRequestSampleTab;useEffect((function(){}),[a.activeServer]);var p=useCodeSamples(a),i=p.samples,c=p.payload,d=1===i.length&&m;return i.length?React.createElement(CodePanel,{dataHeaderTestId:"request-samples",header:o?void 0:l("requestSamples"),onToggle:function(e){var t,o=creatPanelToggleEvent({operation:a,isExpanded:e,panelType:"request-samples"});null===(t=null==s?void 0:s.panelToggle)||void 0===t||t.call(s,o)}},React.createElement(SamplesTabs,{operation:a,tabs:i,onChange:function(e){var t,o=createLanguageSwitchEvent({operation:a,sample:e});null===(t=null==s?void 0:s.codeSamplesLanguageSwitch)||void 0===t||t.call(s,o)},hidden:d,defaultLanguage:t},i.map((function(e){return React.createElement(TabPanel,{key:e.key},isPayloadSample(e)?React.createElement(PayloadSamples,__assign({content:e.requestBodyContent,operation:a},n)):React.createElement(CodeSample,__assign({lang:e.lang,source:e.source,externalSample:e,content:null==c?void 0:c.requestBodyContent,operation:a},n)))})))):null}));
|
|
1
|
+
import{__assign,__rest}from"tslib";import React,{useContext,useEffect}from"react";import{observer}from"mobx-react";import{CodePanel}from"../../../../components/Panel";import{TabPanel}from"../../../../components/Tabs";import{SamplesTabs}from"../../../../components/Samples";import{isPayloadSample}from"../../services";import{PayloadSamples}from"../PayloadSamples/PayloadSamples";import{OptionsContext}from"../OptionsProvider";import{l}from"../../services/Labels";import{CodeSample}from"./CodeSample";import{useCodeSamples}from"./useCodeSamples";import{createLanguageSwitchEvent,creatPanelToggleEvent}from"./languageSwitchEvent";export var RequestSamples=observer((function(e){var a=e.operation,t=e.defaultLanguage,o=e.disableHeader,n=(e.content,__rest(e,["operation","defaultLanguage","disableHeader","content"])),r=useContext(OptionsContext),s=r.events,m=r.hideSingleRequestSampleTab;useEffect((function(){}),[a.activeServer,a.requestValues]);var p=useCodeSamples(a),i=p.samples,c=p.payload,d=1===i.length&&m;return i.length?React.createElement(CodePanel,{dataHeaderTestId:"request-samples",header:o?void 0:l("requestSamples"),onToggle:function(e){var t,o=creatPanelToggleEvent({operation:a,isExpanded:e,panelType:"request-samples"});null===(t=null==s?void 0:s.panelToggle)||void 0===t||t.call(s,o)}},React.createElement(SamplesTabs,{operation:a,tabs:i,onChange:function(e){var t,o=createLanguageSwitchEvent({operation:a,sample:e});null===(t=null==s?void 0:s.codeSamplesLanguageSwitch)||void 0===t||t.call(s,o)},hidden:d,defaultLanguage:t},i.map((function(e){return React.createElement(TabPanel,{key:e.key},isPayloadSample(e)?React.createElement(PayloadSamples,__assign({content:e.requestBodyContent,operation:a},n)):React.createElement(CodeSample,__assign({lang:e.lang,source:e.source,externalSample:e,content:null==c?void 0:c.requestBodyContent,operation:a},n)))})))):null}));
|
|
2
2
|
//# sourceMappingURL=RequestSamples.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__extends}from"tslib";import*as React from"react";import{highlight}from"../../utils";import{FileIcon,SampleControls,SampleControlsWrap,StyledPre}from"../../common-elements";import{CopyButtonWrapper}from"../../common-elements/CopyButtonWrapper";import{Download}from"../../common-elements/Download";var SourceCode=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),Object.defineProperty(t.prototype,"render",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this.props,t=e.source,o=e.lang;return React.createElement(StyledPre,{dangerouslySetInnerHTML:{__html:highlight(t,o)}})}}),t}(React.PureComponent);export{SourceCode};export function SourceCodeWithText(e){var t,o,r,l=e.source||(null===(r=null===(o=null===(t=e.externalSource)||void 0===t?void 0:t.sample)||void 0===o?void 0:o.get)||void 0===r?void 0:r.call(o,e.externalSource))||"";return React.createElement(CopyButtonWrapper,{data:l},(function(t){var o=t.renderCopyButton;return React.createElement(SampleControlsWrap,null,React.createElement(SampleControls,null,o()),React.createElement(SourceCode,{lang:e.lang,source:l}))}))}export function SourceCodeWithFile(e){var t;return React.createElement(SampleControlsWrap,null,React.createElement(SampleControls,null,React.createElement(Download,{fileInfo:e.fileInfo})),React.createElement(StyledPre,null,React.createElement(FileIcon,{color:"light"})," ",null===(t=e.fileInfo)||void 0===t?void 0:t.fileName))}
|
|
1
|
+
import{__extends}from"tslib";import*as React from"react";import{highlight}from"../../utils";import{FileIcon,SampleControls,SampleControlsWrap,StyledPre}from"../../common-elements";import{CopyButtonWrapper}from"../../common-elements/CopyButtonWrapper";import{Download}from"../../common-elements/Download";var SourceCode=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),Object.defineProperty(t.prototype,"render",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this.props,t=e.source,o=e.lang;return React.createElement(StyledPre,{"data-cy":"code-samples",dangerouslySetInnerHTML:{__html:highlight(t,o)}})}}),t}(React.PureComponent);export{SourceCode};export function SourceCodeWithText(e){var t,o,r,l=e.source||(null===(r=null===(o=null===(t=e.externalSource)||void 0===t?void 0:t.sample)||void 0===o?void 0:o.get)||void 0===r?void 0:r.call(o,e.externalSource))||"";return React.createElement(CopyButtonWrapper,{data:l},(function(t){var o=t.renderCopyButton;return React.createElement(SampleControlsWrap,null,React.createElement(SampleControls,null,o()),React.createElement(SourceCode,{lang:e.lang,source:l}))}))}export function SourceCodeWithFile(e){var t;return React.createElement(SampleControlsWrap,null,React.createElement(SampleControls,null,React.createElement(Download,{fileInfo:e.fileInfo})),React.createElement(StyledPre,null,React.createElement(FileIcon,{color:"light"})," ",null===(t=e.fileInfo)||void 0===t?void 0:t.fileName))}
|
|
2
2
|
//# sourceMappingURL=SourceCode.js.map
|
|
@@ -44,6 +44,9 @@ export declare class OperationModel implements IMenuItem {
|
|
|
44
44
|
activeMimeName?: string;
|
|
45
45
|
activeExampleName?: string | false;
|
|
46
46
|
activeServer: Server;
|
|
47
|
+
requestValues?: {
|
|
48
|
+
[field: string]: any;
|
|
49
|
+
};
|
|
47
50
|
defaultExampleName?: string | false;
|
|
48
51
|
defaultMimeType?: string;
|
|
49
52
|
pointer: string;
|
|
@@ -84,5 +87,8 @@ export declare class OperationModel implements IMenuItem {
|
|
|
84
87
|
get callbacks(): CallbackModel[];
|
|
85
88
|
get hideTryItPanel(): boolean;
|
|
86
89
|
setActiveServer(activeServer: Server): void;
|
|
90
|
+
setRequestValues(values: {
|
|
91
|
+
[field: string]: any;
|
|
92
|
+
}): void;
|
|
87
93
|
private generateCodeSamples;
|
|
88
94
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign,__decorate}from"tslib";import{action,makeObservable,observable}from"mobx";import{extractExtensions,getOperationSummary,getStatusCodeType,isStatusCode,memoize,mergeParams,normalizeServers,sanitizeItemId,sortByField,sortByRequired}from"../../utils";import{getCodeSample}from"../../../../services/code-samples/generator";import{getInitialServerWithVariables}from"../../../../components/console/utils";import{CallbackModel}from"./Callback";import{FieldModel}from"./Field";import{RequestBodyModel}from"./RequestBody";import{ResponseModel}from"./Response";import{SecurityRequirementModel}from"./SecurityRequirement";export function isPayloadSample(e){return"payload"===e.lang&&"requestBodyContent"in e}var isCodeSamplesWarningPrinted=!1,OperationModel=function(){function e(e,t,i,r,o){var a,n;void 0===o&&(o=!1),Object.defineProperty(this,"parser",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"operationDefinition",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"absoluteIdx",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"description",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"href",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:"operation"}),Object.defineProperty(this,"parent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"externalDocs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"items",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"depth",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ready",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"active",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"expanded",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"activeMimeName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"activeExampleName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"activeServer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"defaultExampleName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"defaultMimeType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pointer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"operationId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"httpVerb",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"deprecated",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"path",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"servers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"security",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"extensions",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isCallback",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isWebhook",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isEvent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),makeObservable(this),this.pointer=t.pointer,this.description=t.description,this.parent=i,this.externalDocs=t.externalDocs,this.deprecated=!!t.deprecated,this.httpVerb=t.httpVerb,this.deprecated=!!t.deprecated,this.operationId=t.operationId,this.path=t.pathName,this.isCallback=o,this.isWebhook=t.isWebhook,this.isEvent=this.isCallback||this.isWebhook,this.name=getOperationSummary(t),this.defaultExampleName=t.defaultSampleName;var l=null===(n=null===(a=this.requestBody)||void 0===a?void 0:a.content)||void 0===n?void 0:n.mediaTypes,s=(l||[])[0],p=Object.keys((null==s?void 0:s.examples)||[])[0];this.activeExampleName=!1!==t.defaultSampleName&&(t.defaultSampleName||p),this.defaultMimeType=t.defaultMimeType;var u=null==l?void 0:l.find((function(e){return e.name===t.defaultMimeType}));this.activeMimeName=(null==u?void 0:u.name)||(null==s?void 0:s.name),this.isCallback?(this.security=(t.security||[]).map((function(t){return new SecurityRequirementModel(t,e)})),this.servers=normalizeServers("",t.servers||t.pathServers||[])):(this.id=sanitizeItemId(void 0!==t.operationId?"operation/"+t.operationId:void 0!==i?i.id+this.pointer:this.pointer),this.security=(t.security||e.definition.security||[]).map((function(t){return new SecurityRequirementModel(t,e)})),this.servers=normalizeServers(e.definitionUrl,t.servers||t.pathServers||e.definition.servers||[])),r.showExtensions&&(this.extensions=extractExtensions(t,r.showExtensions)),this.activeServer=getInitialServerWithVariables(this.servers)}return Object.defineProperty(e.prototype,"activate",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.active=!0}}),Object.defineProperty(e.prototype,"deactivate",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.active=!1}}),Object.defineProperty(e.prototype,"toggle",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.expanded=!this.expanded}}),Object.defineProperty(e.prototype,"activateMimeName",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.activeMimeName=e}}),Object.defineProperty(e.prototype,"activateExampleName",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.activeExampleName=e}}),Object.defineProperty(e.prototype,"expand",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.parent&&this.parent.expand()}}),Object.defineProperty(e.prototype,"collapse",{enumerable:!1,configurable:!0,writable:!0,value:function(){}}),Object.defineProperty(e.prototype,"requestBody",{get:function(){return this.operationDefinition.requestBody&&new RequestBodyModel({parser:this.parser,infoOrRef:this.operationDefinition.requestBody,options:this.options,operation:this,isEvent:this.isEvent})},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"payload",{get:function(){var e,t=null===(e=this.requestBody)||void 0===e?void 0:e.content;return(null==t?void 0:t.hasSample)?{lang:"payload",label:"Payload",source:"",requestBodyContent:t}:void 0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasSamples",{get:function(){var e,t;return(null===(t=null===(e=this.requestBody)||void 0===e?void 0:e.content)||void 0===t?void 0:t.hasSample)||this.definitionSamples.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"definitionSamples",{get:function(){var e=this.operationDefinition["x-codeSamples"]||this.operationDefinition["x-code-samples"]||[];return this.operationDefinition["x-code-samples"]&&!isCodeSamplesWarningPrinted&&(isCodeSamplesWarningPrinted=!0,console.warn('"x-code-samples" is deprecated. Use "x-codeSamples" instead')),e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"allCodeSamples",{get:function(){var e,t=this.options,i=t.payloadSampleIdx,r=t.hideRequestPayloadSample,o=[];if(!this.isWebhook){var a=this.options.generateCodeSamples||{},n=new Set(this.definitionSamples.map((function(e){return e.lang.toLowerCase()}))),l=(null===(e=a.languages)||void 0===e?void 0:e.filter((function(e){var t=e.lang;return!n.has(t.toLowerCase())})))||[];o=this.generateCodeSamples(l,a)}var s=this.definitionSamples.concat(o),p=Math.min(s.length,i);return this.payload&&!r&&s.splice(p,0,this.payload),s},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parameters",{get:function(){var e=this,t=mergeParams(this.parser,this.operationDefinition.pathParameters,this.operationDefinition.parameters).map((function(t){return new FieldModel(e.parser,t,e.pointer,e.options,void 0,{operation:e,type:"request"})}));return this.options.sortPropsAlphabetically?sortByField(t,"name"):this.options.requiredPropsFirst?sortByRequired(t):t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"responses",{get:function(){var e=this,t=!1;return Object.keys(this.operationDefinition.responses||[]).filter((function(e){return"default"===e||("success"===getStatusCodeType(e)&&(t=!0),isStatusCode(e))})).map((function(i){return new ResponseModel({parser:e.parser,code:i,defaultAsError:t,infoOrRef:e.operationDefinition.responses[i],options:e.options,isEvent:e.isEvent,operation:e})}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"callbacks",{get:function(){var e=this;return Object.keys(this.operationDefinition.callbacks||[]).map((function(t){var i;return new CallbackModel(e.parser,t,null===(i=e.operationDefinition.callbacks)||void 0===i?void 0:i[t],e.pointer,e.options)}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hideTryItPanel",{get:function(){return!0===this.operationDefinition["x-hideTryItPanel"]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"setActiveServer",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.activeServer=e}}),Object.defineProperty(e.prototype,"generateCodeSamples",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var i=this,r=t.skipOptionalParameters,o=t.withOAuth2Call;return e.map((function(e){var t=e.lang,a=e.label,n=e.options;return{lang:t,label:a,get:function(e){return getCodeSample(__assign(__assign({},e),{lang:t,options:__assign(__assign({},n),{skipOptionalParameters:r,withOAuth2Call:o,spec:i.parser.definition,generatedPayloadSamplesMaxDepth:i.options.generatedPayloadSamplesMaxDepth})}))}}}))}}),__decorate([observable],e.prototype,"ready",void 0),__decorate([observable],e.prototype,"active",void 0),__decorate([observable],e.prototype,"expanded",void 0),__decorate([observable],e.prototype,"activeMimeName",void 0),__decorate([observable],e.prototype,"activeExampleName",void 0),__decorate([observable.ref],e.prototype,"activeServer",void 0),__decorate([action],e.prototype,"activate",null),__decorate([action],e.prototype,"deactivate",null),__decorate([action],e.prototype,"toggle",null),__decorate([action],e.prototype,"activateMimeName",null),__decorate([action],e.prototype,"activateExampleName",null),__decorate([memoize],e.prototype,"requestBody",null),__decorate([memoize],e.prototype,"payload",null),__decorate([memoize],e.prototype,"hasSamples",null),__decorate([memoize],e.prototype,"definitionSamples",null),__decorate([memoize],e.prototype,"allCodeSamples",null),__decorate([memoize],e.prototype,"parameters",null),__decorate([memoize],e.prototype,"responses",null),__decorate([memoize],e.prototype,"callbacks",null),__decorate([memoize],e.prototype,"hideTryItPanel",null),__decorate([action],e.prototype,"setActiveServer",null),e}();export{OperationModel};
|
|
1
|
+
import{__assign,__decorate}from"tslib";import{action,makeObservable,observable}from"mobx";import{extractExtensions,getOperationSummary,getStatusCodeType,isStatusCode,memoize,mergeParams,normalizeServers,sanitizeItemId,sortByField,sortByRequired}from"../../utils";import{getCodeSample}from"../../../../services/code-samples/generator";import{getInitialServerWithVariables}from"../../../../components/console/utils";import{CallbackModel}from"./Callback";import{FieldModel}from"./Field";import{RequestBodyModel}from"./RequestBody";import{ResponseModel}from"./Response";import{SecurityRequirementModel}from"./SecurityRequirement";export function isPayloadSample(e){return"payload"===e.lang&&"requestBodyContent"in e}var isCodeSamplesWarningPrinted=!1,OperationModel=function(){function e(e,t,i,r,o){var a,n;void 0===o&&(o=!1),Object.defineProperty(this,"parser",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"operationDefinition",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"absoluteIdx",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"description",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"href",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:"operation"}),Object.defineProperty(this,"parent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"externalDocs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"items",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"depth",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ready",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"active",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"expanded",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"activeMimeName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"activeExampleName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"activeServer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"requestValues",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"defaultExampleName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"defaultMimeType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pointer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"operationId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"httpVerb",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"deprecated",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"path",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"servers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"security",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"extensions",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isCallback",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isWebhook",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isEvent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),makeObservable(this),this.pointer=t.pointer,this.description=t.description,this.parent=i,this.externalDocs=t.externalDocs,this.deprecated=!!t.deprecated,this.httpVerb=t.httpVerb,this.deprecated=!!t.deprecated,this.operationId=t.operationId,this.path=t.pathName,this.isCallback=o,this.isWebhook=t.isWebhook,this.isEvent=this.isCallback||this.isWebhook,this.name=getOperationSummary(t),this.defaultExampleName=t.defaultSampleName;var l=null===(n=null===(a=this.requestBody)||void 0===a?void 0:a.content)||void 0===n?void 0:n.mediaTypes,s=(l||[])[0],p=Object.keys((null==s?void 0:s.examples)||[])[0];this.activeExampleName=!1!==t.defaultSampleName&&(t.defaultSampleName||p),this.defaultMimeType=t.defaultMimeType;var u=null==l?void 0:l.find((function(e){return e.name===t.defaultMimeType}));this.activeMimeName=(null==u?void 0:u.name)||(null==s?void 0:s.name),this.isCallback?(this.security=(t.security||[]).map((function(t){return new SecurityRequirementModel(t,e)})),this.servers=normalizeServers("",t.servers||t.pathServers||[])):(this.id=sanitizeItemId(void 0!==t.operationId?"operation/"+t.operationId:void 0!==i?i.id+this.pointer:this.pointer),this.security=(t.security||e.definition.security||[]).map((function(t){return new SecurityRequirementModel(t,e)})),this.servers=normalizeServers(e.definitionUrl,t.servers||t.pathServers||e.definition.servers||[])),r.showExtensions&&(this.extensions=extractExtensions(t,r.showExtensions)),this.activeServer=getInitialServerWithVariables(this.servers)}return Object.defineProperty(e.prototype,"activate",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.active=!0}}),Object.defineProperty(e.prototype,"deactivate",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.active=!1}}),Object.defineProperty(e.prototype,"toggle",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.expanded=!this.expanded}}),Object.defineProperty(e.prototype,"activateMimeName",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.activeMimeName=e}}),Object.defineProperty(e.prototype,"activateExampleName",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.activeExampleName=e}}),Object.defineProperty(e.prototype,"expand",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.parent&&this.parent.expand()}}),Object.defineProperty(e.prototype,"collapse",{enumerable:!1,configurable:!0,writable:!0,value:function(){}}),Object.defineProperty(e.prototype,"requestBody",{get:function(){return this.operationDefinition.requestBody&&new RequestBodyModel({parser:this.parser,infoOrRef:this.operationDefinition.requestBody,options:this.options,operation:this,isEvent:this.isEvent})},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"payload",{get:function(){var e,t=null===(e=this.requestBody)||void 0===e?void 0:e.content;return(null==t?void 0:t.hasSample)?{lang:"payload",label:"Payload",source:"",requestBodyContent:t}:void 0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasSamples",{get:function(){var e,t;return(null===(t=null===(e=this.requestBody)||void 0===e?void 0:e.content)||void 0===t?void 0:t.hasSample)||this.definitionSamples.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"definitionSamples",{get:function(){var e=this.operationDefinition["x-codeSamples"]||this.operationDefinition["x-code-samples"]||[];return this.operationDefinition["x-code-samples"]&&!isCodeSamplesWarningPrinted&&(isCodeSamplesWarningPrinted=!0,console.warn('"x-code-samples" is deprecated. Use "x-codeSamples" instead')),e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"allCodeSamples",{get:function(){var e,t=this.options,i=t.payloadSampleIdx,r=t.hideRequestPayloadSample,o=[];if(!this.isWebhook){var a=this.options.generateCodeSamples||{},n=new Set(this.definitionSamples.map((function(e){return e.lang.toLowerCase()}))),l=(null===(e=a.languages)||void 0===e?void 0:e.filter((function(e){var t=e.lang;return!n.has(t.toLowerCase())})))||[];o=this.generateCodeSamples(l,a)}var s=this.definitionSamples.concat(o),p=Math.min(s.length,i);return this.payload&&!r&&s.splice(p,0,this.payload),s},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parameters",{get:function(){var e=this,t=mergeParams(this.parser,this.operationDefinition.pathParameters,this.operationDefinition.parameters).map((function(t){return new FieldModel(e.parser,t,e.pointer,e.options,void 0,{operation:e,type:"request"})}));return this.options.sortPropsAlphabetically?sortByField(t,"name"):this.options.requiredPropsFirst?sortByRequired(t):t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"responses",{get:function(){var e=this,t=!1;return Object.keys(this.operationDefinition.responses||[]).filter((function(e){return"default"===e||("success"===getStatusCodeType(e)&&(t=!0),isStatusCode(e))})).map((function(i){return new ResponseModel({parser:e.parser,code:i,defaultAsError:t,infoOrRef:e.operationDefinition.responses[i],options:e.options,isEvent:e.isEvent,operation:e})}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"callbacks",{get:function(){var e=this;return Object.keys(this.operationDefinition.callbacks||[]).map((function(t){var i;return new CallbackModel(e.parser,t,null===(i=e.operationDefinition.callbacks)||void 0===i?void 0:i[t],e.pointer,e.options)}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hideTryItPanel",{get:function(){return!0===this.operationDefinition["x-hideTryItPanel"]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"setActiveServer",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.activeServer=e}}),Object.defineProperty(e.prototype,"setRequestValues",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.requestValues=e}}),Object.defineProperty(e.prototype,"generateCodeSamples",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var i=this,r=t.skipOptionalParameters,o=t.withOAuth2Call;return e.map((function(e){var t=e.lang,a=e.label,n=e.options;return{lang:t,label:a,get:function(e){return getCodeSample(__assign(__assign({},e),{lang:t,options:__assign(__assign({},n),{skipOptionalParameters:r,withOAuth2Call:o,spec:i.parser.definition,generatedPayloadSamplesMaxDepth:i.options.generatedPayloadSamplesMaxDepth})}))}}}))}}),__decorate([observable],e.prototype,"ready",void 0),__decorate([observable],e.prototype,"active",void 0),__decorate([observable],e.prototype,"expanded",void 0),__decorate([observable],e.prototype,"activeMimeName",void 0),__decorate([observable],e.prototype,"activeExampleName",void 0),__decorate([observable.ref],e.prototype,"activeServer",void 0),__decorate([observable],e.prototype,"requestValues",void 0),__decorate([action],e.prototype,"activate",null),__decorate([action],e.prototype,"deactivate",null),__decorate([action],e.prototype,"toggle",null),__decorate([action],e.prototype,"activateMimeName",null),__decorate([action],e.prototype,"activateExampleName",null),__decorate([memoize],e.prototype,"requestBody",null),__decorate([memoize],e.prototype,"payload",null),__decorate([memoize],e.prototype,"hasSamples",null),__decorate([memoize],e.prototype,"definitionSamples",null),__decorate([memoize],e.prototype,"allCodeSamples",null),__decorate([memoize],e.prototype,"parameters",null),__decorate([memoize],e.prototype,"responses",null),__decorate([memoize],e.prototype,"callbacks",null),__decorate([memoize],e.prototype,"hideTryItPanel",null),__decorate([action],e.prototype,"setActiveServer",null),__decorate([action],e.prototype,"setRequestValues",null),e}();export{OperationModel};
|
|
2
2
|
//# sourceMappingURL=Operation.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var _a;import{__assign,__awaiter,__decorate,__generator}from"tslib";import{action,makeObservable,observable,observe}from"mobx";import{bundle,Config}from"@redocly/openapi-core";import{bind,debounce}from"decko";import{createParsedDocument,IS_BROWSER,MarkerService,RedocNormalizedOptions,SCHEMA_DEFINITION_JSX_NAME,SchemaDefinition,ScrollService,SECURITY_DEFINITIONS_COMPONENT_NAME,SECURITY_DEFINITIONS_JSX_NAME,SpecStore}from"../redoc-lib";import{PullRight,RedocResponse}from"../components/pluggable";import{fromLocalStorage,fromSessionStorage,setGlobalStore,toLocalStorage,toSessionStorage}from"../utils";import{SecurityDefs}from"../redoc-lib/src/components/SecurityRequirement/SecurityDefs";import{FakeHistoryService,ProHashHistoryService,PushStateHistoryService}from"./history";import{ProMenu}from"./ProMenu";import{DeepSearchStore,DEFAULT_SEARCH_MAX_DEPTH,RemoteSearch}from"./SearchStore";import{extendTheme}from"./extendTheme";import{VersionedSpecStore}from"./VersionedSpecStore";import parseToken from"./check";import{normalizePath}from"./utils";import{LayoutVariant}from"./store-types";import{SideNavStyle}from"./types";var global="undefined"==typeof window?{__REDOCLY_SEARCH_URL:void 0}:window,NestingGroup=function(){function e(e,t,i,o){var n=this;Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"absoluteIdx",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"description",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"linkable",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"items",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"parent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"externalDocs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"active",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"expanded",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"depth",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"level",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),makeObservable(this),this.id="section/"+e,this.type="nesting-group",this.name=i||"",this.level=1,this.depth=1,this.description="",this.parent=void 0,this.expanded=!1,this.items=t,this.linkable=!!o,t.forEach((function(e){return e.parent=n})),increaseDepthDeep(t)}return Object.defineProperty(e.prototype,"activate",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.active=!0}}),Object.defineProperty(e.prototype,"expand",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.expanded=!0,this.parent&&this.parent.expand()}}),Object.defineProperty(e.prototype,"collapse",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.expanded=!1}}),Object.defineProperty(e.prototype,"deactivate",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.active=!1}}),__decorate([observable],e.prototype,"active",void 0),__decorate([observable],e.prototype,"expanded",void 0),__decorate([action],e.prototype,"activate",null),__decorate([action],e.prototype,"expand",null),__decorate([action],e.prototype,"collapse",null),__decorate([action],e.prototype,"deactivate",null),e}();export{NestingGroup};function increaseDepthDeep(e){Array.isArray(e)&&e.forEach((function(e){e.depth++,e.parent&&"group"===e.parent.type&&(e.depth=e.parent.depth),increaseDepthDeep(e.items)}))}var ProStore=function(){function e(e,t,i,o){var n=this;void 0===i&&(i={}),void 0===o&&(o=!0),Object.defineProperty(this,"rawOptions",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"menu",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"definition",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"marker",{enumerable:!0,configurable:!0,writable:!0,value:new MarkerService}),Object.defineProperty(this,"scroll",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"disposer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"search",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tryItOperation",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"showRightPanel",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"layout",{enumerable:!0,configurable:!0,writable:!0,value:LayoutVariant.THREE_PANEL}),Object.defineProperty(this,"activeSampleLanguage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isLoading",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"l",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),makeObservable(this),this.initProOptions(i),IS_BROWSER&&(this.l=parseToken(i.licenseKey),this.l.then((function(e){e.valid&&e.allowed&&!e.expired||e.local||(n.menu.items=[],n.menu.flatItems=n.menu.flatItems.slice(0,1),n.menu.renderItems=[])})));var r="object"==typeof e&&"versions"in e,a=this.options.disableSidebar?new FakeHistoryService(this.options):"browser"===this.options.routingStrategy?new PushStateHistoryService(this.options,r):new ProHashHistoryService(this.options,r);this.definition=r?new VersionedSpecStore(e,this.options,a.currentId.split("/")[0]):new SpecStore(e,t,this.options),i.downloadDefinitionUrl&&(this.definition.info.downloadFileName=""),this.scroll=new ScrollService(this.options),this.options.disableSidebar||ProMenu.updateOnHistory(a.currentId,this.scroll),this.menu=new ProMenu(this.definition,this.scroll,this.options,a),this.menu.initOnHistory(),this.options.disableSearch||this.initSearch(this.options,o),this.disposer=observe(this.menu,"none"===this.options.pagination?"activeItemIdx":"activeRenderItemIdx",(function(e){setTimeout((function(){return n.updateMarkOnMenu(e.newValue)}))})),setGlobalStore(this)}return Object.defineProperty(e.prototype,"initProOptions",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,i,o,n,r;e=deepClone(e),this.rawOptions=extendTheme(e),this.options=new RedocNormalizedOptions(this.rawOptions,DEFAULT_OPTIONS),null!=this.rawOptions.showConsole&&console.warn('"showConsole" option is deprecated. Please, use "hideTryItPanel" instead.'),this.options.showConsole=null!=this.rawOptions.hideTryItPanel?!this.rawOptions.hideTryItPanel:null===(t=this.rawOptions.showConsole)||void 0===t||t,this.options.hideRightPanel=null!==(i=this.rawOptions.hideRightPanel)&&void 0!==i&&i,this.showRightPanel=!this.options.hideRightPanel,this.options.showRightPanelToggle=null===(o=this.rawOptions.showRightPanelToggle)||void 0===o||o,this.options.showChangeLayoutButton=null===(n=this.rawOptions.showChangeLayoutButton)||void 0===n||n,this.options.layout=this.rawOptions.layout||LayoutVariant.THREE_PANEL,this.options.defaultSampleLanguage=this.rawOptions.defaultSampleLanguage||"",this.options.deepLinkSeparator=this.rawOptions.deepLinkSeparator||"/",this.options.deepLinkPrefix=this.rawOptions.deepLinkPrefix||"!",this.options.disableDeepLinks=this.rawOptions.disableDeepLinks||!1,this.options.sideNavStyle=this.rawOptions.sideNavStyle||SideNavStyle.SummaryOnly,this.options.whiteLabel=!!this.rawOptions.whiteLabel,this.options.hideLogo=!!this.rawOptions.hideLogo,this.options.hideInfoSection=!!this.rawOptions.hideInfoSection,this.options.oAuth2RedirectURI=this.rawOptions.oAuth2RedirectURI||null,this.options.oAuth2RedirectURI=this.rawOptions.oAuth2RedirectURI||null,this.options.events=this.rawOptions.events||{},this.options.corsProxyUrl=this.rawOptions.corsProxyUrl?addTrailingSlash(this.rawOptions.corsProxyUrl):null,this.options.authCorsProxyUrl=this.rawOptions.authCorsProxyUrl?addTrailingSlash(this.rawOptions.authCorsProxyUrl):null,this.options.theme.scrollYOffset=this.options.scrollYOffset,this.options.linkForId=this.rawOptions.linkForId||null,this.options.generateDeepLink=this.rawOptions.generateDeepLink||null,this.options.onDeepLinkClick=this.rawOptions.onDeepLinkClick||null,this.options.requestInterceptor=this.rawOptions.requestInterceptor||null,this.options.sidebarLinks=this.rawOptions.sidebarLinks||{};var a="object"==typeof this.rawOptions.layout?this.rawOptions.layout:null;if(this.options.pagination=this.rawOptions.pagination||"none",this.options.routingStrategy="none"===this.options.pagination?"hash":"browser",!(null===(r=this.rawOptions)||void 0===r?void 0:r.pagination)&&(null==a?void 0:a.scope))switch(console.warn('"layout.scope" and "routingStrategy" settings are deprecated. Please, use "pagination" instead.'),null==a?void 0:a.scope){case"all":default:this.options.pagination="none",this.options.routingStrategy="hash";break;case"section":this.options.pagination="section",this.options.routingStrategy="browser";break;case"item":this.options.pagination="item",this.options.routingStrategy="browser"}this.options.markdownItemsPagination="none",!1!==this.rawOptions.showNextButton&&(this.options.showNextButton=!0),this.options.disableSidebar=!!e.disableSidebar,this.options.disableSidebar&&(this.options.theme.sidebar.width="0px"),this.options.skipBundleAndConvert=!!e.skipBundleAndConvert,this.options.routingBasePath=e.routingBasePath&&normalizePath(e.routingBasePath)||"",this.options.searchAutoExpand=!1!==e.searchAutoExpand,this.options.searchMode=e.searchMode||"default",this.options.ctrlFHijack=void 0===e.ctrlFHijack||e.ctrlFHijack,this.options.disablePaginationLoadingAnimation=!!e.disablePaginationLoadingAnimation||"none"===this.options.pagination,this.options.showConsole,this.options.generateCodeSamples=e.generateCodeSamples||{languages:[]},this.options.searchMaxDepth=this.rawOptions.searchMaxDepth||DEFAULT_SEARCH_MAX_DEPTH}}),Object.defineProperty(e.prototype,"initSearch",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var i=this;global.__REDOCLY_SEARCH_URL?this.search=new RemoteSearch(global.__REDOCLY_SEARCH_URL):this.search=new DeepSearchStore(e),t&&setTimeout((function(){var e;return null===(e=i.search)||void 0===e?void 0:e.indexItems(i.menu.items)}),50),this.definition instanceof VersionedSpecStore&&observe(this.definition,"activeVersionIdx",(function(t){var o,n,r=i.definition;null===(o=i.search)||void 0===o||o.dispose(),i.search=new DeepSearchStore(e);var a=r.versions[t.newValue]._searchIndexName;if(IS_BROWSER&&a){var s=r.versions[t.newValue]._searchIndexName,l=new URL(window.location.href);l.pathname=joinURLs(i.options.routingBasePath,s),null===(n=i.search)||void 0===n||n.fromExternalJS(l.toString(),__redoc_state.searchIndexExport),i.observeAllAndRemark()}else setTimeout((function(){var e;null===(e=i.search)||void 0===e||e.indexItems(i.menu.items)}),0)})),IS_BROWSER&&this.observeAllAndRemark()}}),Object.defineProperty(e.prototype,"onDidMount",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(this.menu.updateOnHistory(),this.updateMarkOnMenu(this.menu.activeItemIdx),this.layout=fromLocalStorage("layoutVariant")||this.options.layout||this.layout,this.activeSampleLanguage=fromLocalStorage("activeSampleLanguage")||this.options.defaultSampleLanguage,this.options.showRightPanelToggle){var e=fromSessionStorage("showRightPanelToggleState");e&&(this.showRightPanel="true"===e)}}}),Object.defineProperty(e.prototype,"toggleRightPanel",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.showRightPanel=null!=e?e:!this.showRightPanel,toSessionStorage("showRightPanelToggleState",JSON.stringify(this.showRightPanel))}}),Object.defineProperty(e.prototype,"toggleLayout",{enumerable:!1,configurable:!0,writable:!0,value:function(e){void 0===e&&(e=LayoutVariant.THREE_PANEL),this.layout=e,toLocalStorage("layoutVariant",e)}}),Object.defineProperty(e.prototype,"disableConsole",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.options.showConsole=!1}}),Object.defineProperty(e.prototype,"enableConsole",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.options.showConsole=!0}}),Object.defineProperty(e.prototype,"tryItOut",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.tryItOperation=e}}),Object.defineProperty(e.prototype,"setActiveSampleLanguage",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this.activeSampleLanguage===e)return this.stopLoader();this.activeSampleLanguage=e,toLocalStorage("activeSampleLanguage",e)}}),Object.defineProperty(e.prototype,"activateSampleLanguage",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.setActiveSampleLanguage(e)}}),Object.defineProperty(e.prototype,"startLoader",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.isLoading||(this.isLoading=!0)}}),Object.defineProperty(e.prototype,"stopLoader",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.isLoading&&(this.isLoading=!1)}}),Object.defineProperty(e.prototype,"dereferenceSpecForTryIt",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,i,o,n;return __awaiter(this,void 0,void 0,(function(){var r,a,s,l,p,u,c;return __generator(this,(function(h){switch(h.label){case 0:return r=this.definition.parser.definition,a=JSON.parse(JSON.stringify(r)),s=__assign(__assign({},getSpecVersionObj(a)),{components:a.components,paths:(u={},u[e.path]=(c={},c[e.httpVerb]=null===(i=null===(t=a.paths)||void 0===t?void 0:t[e.path])||void 0===i?void 0:i[e.httpVerb],c.parameters=null===(n=null===(o=a.paths)||void 0===o?void 0:o[e.path])||void 0===n?void 0:n.parameters,c),u)}),l=new Config({}),p=createParsedDocument(s),[4,bundle({config:l,doc:p,dereference:!0})];case 1:return h.sent(),[2,a]}}))}))}}),Object.defineProperty(e.prototype,"observeAllAndRemark",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this,t=function(i){for(var o=0,n=i;o<n.length;o++){var r=n[o];if("operation"===r.type)for(var a=0,s=r.responses;a<s.length;a++){var l=s[a];observe(l,"expanded",(function(t){return e.remark(t)}))}else"tag"===r.type&&t(r.items||[])}};t(this.menu.renderItems),"none"!==this.options.pagination&&observe(this.menu,"renderItems",(function(){return t(e.menu.renderItems)}))}}),Object.defineProperty(e.prototype,"remark",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;e.newValue&&setTimeout((function(){return t.marker.mark()}),0)}}),Object.defineProperty(e,"fromJS",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var i,o=new e(t.definition.data,t.definition.url,t.options,!1);setGlobalStore(o),o.menu.activeItemIdx=void 0!==t.menu.activeItemIdx?t.menu.activeItemIdx:-1,o.definition instanceof VersionedSpecStore&&t.definition.activeVersionIdx&&(o.definition.activeVersionIdx=t.definition.activeVersionIdx||0);var n=o.menu.flatItems[o.menu.activeItemIdx];if(n&&o.menu.activate(n,!1),!o.options.disableSearch){var r=new URL(window.location.href);r.pathname=t.searchIndexPath&&t.searchIndexPath.startsWith("/")?t.searchIndexPath:r.pathname+(r.pathname.endsWith("/")?"":"/")+t.searchIndexPath,null===(i=o.search)||void 0===i||i.fromExternalJS(r.toString(),t.searchIndexExport)}return t.tryItOperationId&&(o.tryItOperation=o.menu.flatItems.find((function(e){return e.id===t.tryItOperationId}))),setTimeout((function(){return o.observeAllAndRemark()}),0),o}}),Object.defineProperty(e.prototype,"toJS",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e;return __awaiter(this,void 0,void 0,(function(){var t,i;return __generator(this,(function(o){switch(o.label){case 0:return i={menu:{activeItemIdx:this.menu.activeItemIdx},definition:this.definition instanceof VersionedSpecStore?{url:void 0,data:this.definition.toJS()}:{url:this.definition.parser.definitionUrl,data:this.definition.parser.definition}},this.search?[4,this.search.toJS()]:[3,2];case 1:return t=o.sent(),[3,3];case 2:t=void 0,o.label=3;case 3:return[2,(i.searchIndex=t,i.options=this.rawOptions,i.tryItOperationId=null===(e=this.tryItOperation)||void 0===e?void 0:e.id,i)]}}))}))}}),Object.defineProperty(e.prototype,"dispose",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.scroll.dispose(),this.menu.dispose(),this.search&&this.search.dispose(),this.disposer()}}),Object.defineProperty(e.prototype,"updateMarkOnMenu",{enumerable:!1,configurable:!0,writable:!0,value:function(e){for(var t=Math.max(0,e),i=Math.min(this.menu.flatItems.length,t+5),o=[],n=t;n<i;n++){(r=this.menu.getElementAt(n))&&(r&&o.push(r))}if("item"===this.options.pagination){var r,a=(this.menu.flatItems[e]||{}).parent;if(null==a?void 0:a.absoluteIdx)(r=this.menu.getElementAt(a.absoluteIdx))&&o.push(r)}this.marker.addOnly(o),this.marker.mark()}}),__decorate([observable],e.prototype,"search",void 0),__decorate([observable],e.prototype,"tryItOperation",void 0),__decorate([observable],e.prototype,"showRightPanel",void 0),__decorate([observable],e.prototype,"layout",void 0),__decorate([observable],e.prototype,"activeSampleLanguage",void 0),__decorate([observable],e.prototype,"isLoading",void 0),__decorate([action],e.prototype,"onDidMount",null),__decorate([action],e.prototype,"toggleRightPanel",null),__decorate([action],e.prototype,"toggleLayout",null),__decorate([action],e.prototype,"disableConsole",null),__decorate([action],e.prototype,"enableConsole",null),__decorate([action],e.prototype,"tryItOut",null),__decorate([action],e.prototype,"setActiveSampleLanguage",null),__decorate([bind,debounce(500)],e.prototype,"activateSampleLanguage",null),__decorate([action],e.prototype,"startLoader",null),__decorate([action],e.prototype,"stopLoader",null),e}();export{ProStore};var DEFAULT_OPTIONS={ignoreNamedSchemas:["java.io.ObjectStreamField"],allowedMdComponents:(_a={RedocResponse:{component:RedocResponse,propsSelector:function(e){return{store:e}}},PullRight:{component:PullRight,propsSelector:function(){return{}}}},_a[SCHEMA_DEFINITION_JSX_NAME]={component:SchemaDefinition,propsSelector:function(e){return{parser:e.definition.parser,options:e.options,layout:e.layout,showRightPanel:e.showRightPanel}}},_a[SECURITY_DEFINITIONS_COMPONENT_NAME]={component:SecurityDefs,propsSelector:function(e){return{securitySchemes:e.definition.securitySchemes}}},_a[SECURITY_DEFINITIONS_JSX_NAME]={component:SecurityDefs,propsSelector:function(e){return{securitySchemes:e.definition.securitySchemes}}},_a)};function joinURLs(e,t){return e.endsWith("/")&&(e=e.slice(0,-1)),t.startsWith("/")&&(t=t.substring(1)),e+"/"+t}function addTrailingSlash(e){return e.endsWith("/")?e:e+"/"}function getSpecVersionObj(e){return e.openapi?{openapi:e.openapi}:e.swagger?{swagger:e.swagger}:void 0}function deepClone(e){if("object"!=typeof e||null===e)return e;var t=Array.isArray(e)?[]:{};for(var i in e){var o=e[i];t[i]=deepClone(o)}return t}
|
|
1
|
+
var _a;import{__assign,__awaiter,__decorate,__generator}from"tslib";import{action,makeObservable,observable,observe}from"mobx";import{bundle,Config}from"@redocly/openapi-core";import{bind,debounce}from"decko";import{createParsedDocument,IS_BROWSER,MarkerService,RedocNormalizedOptions,SCHEMA_DEFINITION_JSX_NAME,SchemaDefinition,ScrollService,SECURITY_DEFINITIONS_COMPONENT_NAME,SECURITY_DEFINITIONS_JSX_NAME,SpecStore}from"../redoc-lib";import{PullRight,RedocResponse}from"../components/pluggable";import{fromLocalStorage,fromSessionStorage,setGlobalStore,toLocalStorage,toSessionStorage}from"../utils";import{SecurityDefs}from"../redoc-lib/src/components/SecurityRequirement/SecurityDefs";import{FakeHistoryService,ProHashHistoryService,PushStateHistoryService}from"./history";import{ProMenu}from"./ProMenu";import{DeepSearchStore,DEFAULT_SEARCH_MAX_DEPTH,RemoteSearch}from"./SearchStore";import{extendTheme}from"./extendTheme";import{VersionedSpecStore}from"./VersionedSpecStore";import parseToken from"./check";import{normalizePath}from"./utils";import{LayoutVariant}from"./store-types";import{SideNavStyle}from"./types";var global="undefined"==typeof window?{__REDOCLY_SEARCH_URL:void 0}:window,NestingGroup=function(){function e(e,t,i,o){var n=this;Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"absoluteIdx",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"description",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"linkable",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"items",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"parent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"externalDocs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"active",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"expanded",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"depth",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"level",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),makeObservable(this),this.id="section/"+e,this.type="nesting-group",this.name=i||"",this.level=1,this.depth=1,this.description="",this.parent=void 0,this.expanded=!1,this.items=t,this.linkable=!!o,t.forEach((function(e){return e.parent=n})),increaseDepthDeep(t)}return Object.defineProperty(e.prototype,"activate",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.active=!0}}),Object.defineProperty(e.prototype,"expand",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.expanded=!0,this.parent&&this.parent.expand()}}),Object.defineProperty(e.prototype,"collapse",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.expanded=!1}}),Object.defineProperty(e.prototype,"deactivate",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.active=!1}}),__decorate([observable],e.prototype,"active",void 0),__decorate([observable],e.prototype,"expanded",void 0),__decorate([action],e.prototype,"activate",null),__decorate([action],e.prototype,"expand",null),__decorate([action],e.prototype,"collapse",null),__decorate([action],e.prototype,"deactivate",null),e}();export{NestingGroup};function increaseDepthDeep(e){Array.isArray(e)&&e.forEach((function(e){e.depth++,e.parent&&"group"===e.parent.type&&(e.depth=e.parent.depth),increaseDepthDeep(e.items)}))}var ProStore=function(){function e(e,t,i,o){var n=this;void 0===i&&(i={}),void 0===o&&(o=!0),Object.defineProperty(this,"rawOptions",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"menu",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"definition",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"marker",{enumerable:!0,configurable:!0,writable:!0,value:new MarkerService}),Object.defineProperty(this,"scroll",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"disposer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"search",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tryItOperation",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"showRightPanel",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"layout",{enumerable:!0,configurable:!0,writable:!0,value:LayoutVariant.THREE_PANEL}),Object.defineProperty(this,"activeSampleLanguage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isLoading",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"l",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),makeObservable(this),this.initProOptions(i),IS_BROWSER&&(this.l=parseToken(i.licenseKey),this.l.then((function(e){e.valid&&e.allowed&&!e.expired||e.local||(n.menu.items=[],n.menu.flatItems=n.menu.flatItems.slice(0,1),n.menu.renderItems=[])})));var r="object"==typeof e&&"versions"in e,a=this.options.disableSidebar?new FakeHistoryService(this.options):"browser"===this.options.routingStrategy?new PushStateHistoryService(this.options,r):new ProHashHistoryService(this.options,r);this.definition=r?new VersionedSpecStore(e,this.options,a.currentId.split("/")[0]):new SpecStore(e,t,this.options),i.downloadDefinitionUrl&&(this.definition.info.downloadFileName=""),this.scroll=new ScrollService(this.options),this.options.disableSidebar||ProMenu.updateOnHistory(a.currentId,this.scroll),this.menu=new ProMenu(this.definition,this.scroll,this.options,a),this.menu.initOnHistory(),this.options.disableSearch||this.initSearch(this.options,o),this.disposer=observe(this.menu,"none"===this.options.pagination?"activeItemIdx":"activeRenderItemIdx",(function(e){setTimeout((function(){return n.updateMarkOnMenu(e.newValue)}))})),setGlobalStore(this)}return Object.defineProperty(e.prototype,"initProOptions",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,i,o,n,r,a,s,l,p;e=deepClone(e),this.rawOptions=extendTheme(e),this.options=new RedocNormalizedOptions(this.rawOptions,DEFAULT_OPTIONS),null!=this.rawOptions.showConsole&&console.warn('"showConsole" option is deprecated. Please, use "hideTryItPanel" instead.'),this.options.showConsole=null!=this.rawOptions.hideTryItPanel?!this.rawOptions.hideTryItPanel:null===(t=this.rawOptions.showConsole)||void 0===t||t,this.options.hideRightPanel=null!==(i=this.rawOptions.hideRightPanel)&&void 0!==i&&i,this.showRightPanel=!this.options.hideRightPanel,this.options.showRightPanelToggle=null===(o=this.rawOptions.showRightPanelToggle)||void 0===o||o,this.options.showChangeLayoutButton=null===(n=this.rawOptions.showChangeLayoutButton)||void 0===n||n,this.options.layout=this.rawOptions.layout||LayoutVariant.THREE_PANEL,this.options.defaultSampleLanguage=this.rawOptions.defaultSampleLanguage||"",this.options.deepLinkSeparator=this.rawOptions.deepLinkSeparator||"/",this.options.deepLinkPrefix=this.rawOptions.deepLinkPrefix||"!",this.options.disableDeepLinks=this.rawOptions.disableDeepLinks||!1,this.options.sideNavStyle=this.rawOptions.sideNavStyle||SideNavStyle.SummaryOnly,this.options.whiteLabel=!!this.rawOptions.whiteLabel,this.options.hideLogo=!!this.rawOptions.hideLogo,this.options.hideInfoSection=!!this.rawOptions.hideInfoSection,this.options.oAuth2RedirectURI=this.rawOptions.oAuth2RedirectURI||null,this.options.oAuth2RedirectURI=this.rawOptions.oAuth2RedirectURI||null,this.options.events=this.rawOptions.events||{},this.options.corsProxyUrl=this.rawOptions.corsProxyUrl?addTrailingSlash(this.rawOptions.corsProxyUrl):null,this.options.authCorsProxyUrl=this.rawOptions.authCorsProxyUrl?addTrailingSlash(this.rawOptions.authCorsProxyUrl):null,this.options.theme.scrollYOffset=this.options.scrollYOffset,this.options.linkForId=this.rawOptions.linkForId||IS_BROWSER&&(null===(r=null===window||void 0===window?void 0:window.REFERENCE_DOCS_OPTIONS)||void 0===r?void 0:r.linkForId)||null,this.options.generateDeepLink=this.rawOptions.generateDeepLink||IS_BROWSER&&(null===(a=null===window||void 0===window?void 0:window.REFERENCE_DOCS_OPTIONS)||void 0===a?void 0:a.generateDeepLink)||null,this.options.onDeepLinkClick=this.rawOptions.onDeepLinkClick||IS_BROWSER&&(null===(s=null===window||void 0===window?void 0:window.REFERENCE_DOCS_OPTIONS)||void 0===s?void 0:s.onDeepLinkClick)||null,this.options.requestInterceptor=this.rawOptions.requestInterceptor||IS_BROWSER&&(null===(l=null===window||void 0===window?void 0:window.REFERENCE_DOCS_OPTIONS)||void 0===l?void 0:l.requestInterceptor)||null,this.options.sidebarLinks=this.rawOptions.sidebarLinks||{};var u="object"==typeof this.rawOptions.layout?this.rawOptions.layout:null;if(this.options.pagination=this.rawOptions.pagination||"none",this.options.routingStrategy=void 0!==this.rawOptions.routingStrategy?this.rawOptions.routingStrategy:"none"===this.options.pagination?"hash":"browser",!(null===(p=this.rawOptions)||void 0===p?void 0:p.pagination)&&(null==u?void 0:u.scope))switch(console.warn('"layout.scope" and "routingStrategy" settings are deprecated. Please, use "pagination" instead.'),null==u?void 0:u.scope){case"all":default:this.options.pagination="none",this.options.routingStrategy="hash";break;case"section":this.options.pagination="section",this.options.routingStrategy="browser";break;case"item":this.options.pagination="item",this.options.routingStrategy="browser"}this.options.markdownItemsPagination="none",!1!==this.rawOptions.showNextButton&&(this.options.showNextButton=!0),this.options.disableSidebar=!!e.disableSidebar,this.options.disableSidebar&&(this.options.theme.sidebar.width="0px"),this.options.skipBundleAndConvert=!!e.skipBundleAndConvert,this.options.routingBasePath=e.routingBasePath&&normalizePath(e.routingBasePath)||"",this.options.searchAutoExpand=!1!==e.searchAutoExpand,this.options.searchMode=e.searchMode||"default",this.options.ctrlFHijack=void 0===e.ctrlFHijack||e.ctrlFHijack,this.options.disablePaginationLoadingAnimation=!!e.disablePaginationLoadingAnimation||"none"===this.options.pagination,this.options.showConsole,this.options.generateCodeSamples=e.generateCodeSamples||{languages:[]},this.options.searchMaxDepth=this.rawOptions.searchMaxDepth||DEFAULT_SEARCH_MAX_DEPTH}}),Object.defineProperty(e.prototype,"initSearch",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var i=this;global.__REDOCLY_SEARCH_URL?this.search=new RemoteSearch(global.__REDOCLY_SEARCH_URL):this.search=new DeepSearchStore(e),t&&setTimeout((function(){var e;return null===(e=i.search)||void 0===e?void 0:e.indexItems(i.menu.items)}),50),this.definition instanceof VersionedSpecStore&&observe(this.definition,"activeVersionIdx",(function(t){var o,n,r=i.definition;null===(o=i.search)||void 0===o||o.dispose(),i.search=new DeepSearchStore(e);var a=r.versions[t.newValue]._searchIndexName;if(IS_BROWSER&&a){var s=r.versions[t.newValue]._searchIndexName,l=new URL(window.location.href);l.pathname=joinURLs(i.options.routingBasePath,s),null===(n=i.search)||void 0===n||n.fromExternalJS(l.toString(),__redoc_state.searchIndexExport),i.observeAllAndRemark()}else setTimeout((function(){var e;null===(e=i.search)||void 0===e||e.indexItems(i.menu.items)}),0)})),IS_BROWSER&&this.observeAllAndRemark()}}),Object.defineProperty(e.prototype,"onDidMount",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(this.menu.updateOnHistory(),this.updateMarkOnMenu(this.menu.activeItemIdx),this.layout=fromLocalStorage("layoutVariant")||this.options.layout||this.layout,this.activeSampleLanguage=fromLocalStorage("activeSampleLanguage")||this.options.defaultSampleLanguage,this.options.showRightPanelToggle){var e=fromSessionStorage("showRightPanelToggleState");e&&(this.showRightPanel="true"===e)}}}),Object.defineProperty(e.prototype,"toggleRightPanel",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.showRightPanel=null!=e?e:!this.showRightPanel,toSessionStorage("showRightPanelToggleState",JSON.stringify(this.showRightPanel))}}),Object.defineProperty(e.prototype,"toggleLayout",{enumerable:!1,configurable:!0,writable:!0,value:function(e){void 0===e&&(e=LayoutVariant.THREE_PANEL),this.layout=e,toLocalStorage("layoutVariant",e)}}),Object.defineProperty(e.prototype,"disableConsole",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.options.showConsole=!1}}),Object.defineProperty(e.prototype,"enableConsole",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.options.showConsole=!0}}),Object.defineProperty(e.prototype,"tryItOut",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.tryItOperation=e}}),Object.defineProperty(e.prototype,"setActiveSampleLanguage",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this.activeSampleLanguage===e)return this.stopLoader();this.activeSampleLanguage=e,toLocalStorage("activeSampleLanguage",e)}}),Object.defineProperty(e.prototype,"activateSampleLanguage",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.setActiveSampleLanguage(e)}}),Object.defineProperty(e.prototype,"startLoader",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.isLoading||(this.isLoading=!0)}}),Object.defineProperty(e.prototype,"stopLoader",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.isLoading&&(this.isLoading=!1)}}),Object.defineProperty(e.prototype,"dereferenceSpecForTryIt",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,i,o,n;return __awaiter(this,void 0,void 0,(function(){var r,a,s,l,p,u,d;return __generator(this,(function(c){switch(c.label){case 0:return r=this.definition.parser.definition,a=JSON.parse(JSON.stringify(r)),s=__assign(__assign({},getSpecVersionObj(a)),{components:a.components,paths:(u={},u[e.path]=(d={},d[e.httpVerb]=null===(i=null===(t=a.paths)||void 0===t?void 0:t[e.path])||void 0===i?void 0:i[e.httpVerb],d.parameters=null===(n=null===(o=a.paths)||void 0===o?void 0:o[e.path])||void 0===n?void 0:n.parameters,d),u)}),l=new Config({}),p=createParsedDocument(s),[4,bundle({config:l,doc:p,dereference:!0})];case 1:return c.sent(),[2,a]}}))}))}}),Object.defineProperty(e.prototype,"observeAllAndRemark",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this,t=function(i){for(var o=0,n=i;o<n.length;o++){var r=n[o];if("operation"===r.type)for(var a=0,s=r.responses;a<s.length;a++){var l=s[a];observe(l,"expanded",(function(t){return e.remark(t)}))}else"tag"===r.type&&t(r.items||[])}};t(this.menu.renderItems),"none"!==this.options.pagination&&observe(this.menu,"renderItems",(function(){return t(e.menu.renderItems)}))}}),Object.defineProperty(e.prototype,"remark",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;e.newValue&&setTimeout((function(){return t.marker.mark()}),0)}}),Object.defineProperty(e,"fromJS",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var i,o=new e(t.definition.data,t.definition.url,t.options,!1);setGlobalStore(o),o.menu.activeItemIdx=void 0!==t.menu.activeItemIdx?t.menu.activeItemIdx:-1,o.definition instanceof VersionedSpecStore&&t.definition.activeVersionIdx&&(o.definition.activeVersionIdx=t.definition.activeVersionIdx||0);var n=o.menu.flatItems[o.menu.activeItemIdx];if(n&&o.menu.activate(n,!1),!o.options.disableSearch){var r=new URL(window.location.href);r.pathname=t.searchIndexPath&&t.searchIndexPath.startsWith("/")?t.searchIndexPath:r.pathname+(r.pathname.endsWith("/")?"":"/")+t.searchIndexPath,null===(i=o.search)||void 0===i||i.fromExternalJS(r.toString(),t.searchIndexExport)}return t.tryItOperationId&&(o.tryItOperation=o.menu.flatItems.find((function(e){return e.id===t.tryItOperationId}))),setTimeout((function(){return o.observeAllAndRemark()}),0),o}}),Object.defineProperty(e.prototype,"toJS",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e;return __awaiter(this,void 0,void 0,(function(){var t,i;return __generator(this,(function(o){switch(o.label){case 0:return i={menu:{activeItemIdx:this.menu.activeItemIdx},definition:this.definition instanceof VersionedSpecStore?{url:void 0,data:this.definition.toJS()}:{url:this.definition.parser.definitionUrl,data:this.definition.parser.definition}},this.search?[4,this.search.toJS()]:[3,2];case 1:return t=o.sent(),[3,3];case 2:t=void 0,o.label=3;case 3:return[2,(i.searchIndex=t,i.options=this.rawOptions,i.tryItOperationId=null===(e=this.tryItOperation)||void 0===e?void 0:e.id,i)]}}))}))}}),Object.defineProperty(e.prototype,"dispose",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.scroll.dispose(),this.menu.dispose(),this.search&&this.search.dispose(),this.disposer()}}),Object.defineProperty(e.prototype,"updateMarkOnMenu",{enumerable:!1,configurable:!0,writable:!0,value:function(e){for(var t=Math.max(0,e),i=Math.min(this.menu.flatItems.length,t+5),o=[],n=t;n<i;n++){(r=this.menu.getElementAt(n))&&(r&&o.push(r))}if("item"===this.options.pagination){var r,a=(this.menu.flatItems[e]||{}).parent;if(null==a?void 0:a.absoluteIdx)(r=this.menu.getElementAt(a.absoluteIdx))&&o.push(r)}this.marker.addOnly(o),this.marker.mark()}}),__decorate([observable],e.prototype,"search",void 0),__decorate([observable],e.prototype,"tryItOperation",void 0),__decorate([observable],e.prototype,"showRightPanel",void 0),__decorate([observable],e.prototype,"layout",void 0),__decorate([observable],e.prototype,"activeSampleLanguage",void 0),__decorate([observable],e.prototype,"isLoading",void 0),__decorate([action],e.prototype,"onDidMount",null),__decorate([action],e.prototype,"toggleRightPanel",null),__decorate([action],e.prototype,"toggleLayout",null),__decorate([action],e.prototype,"disableConsole",null),__decorate([action],e.prototype,"enableConsole",null),__decorate([action],e.prototype,"tryItOut",null),__decorate([action],e.prototype,"setActiveSampleLanguage",null),__decorate([bind,debounce(500)],e.prototype,"activateSampleLanguage",null),__decorate([action],e.prototype,"startLoader",null),__decorate([action],e.prototype,"stopLoader",null),e}();export{ProStore};var DEFAULT_OPTIONS={ignoreNamedSchemas:["java.io.ObjectStreamField"],allowedMdComponents:(_a={RedocResponse:{component:RedocResponse,propsSelector:function(e){return{store:e}}},PullRight:{component:PullRight,propsSelector:function(){return{}}}},_a[SCHEMA_DEFINITION_JSX_NAME]={component:SchemaDefinition,propsSelector:function(e){return{parser:e.definition.parser,options:e.options,layout:e.layout,showRightPanel:e.showRightPanel}}},_a[SECURITY_DEFINITIONS_COMPONENT_NAME]={component:SecurityDefs,propsSelector:function(e){return{securitySchemes:e.definition.securitySchemes}}},_a[SECURITY_DEFINITIONS_JSX_NAME]={component:SecurityDefs,propsSelector:function(e){return{securitySchemes:e.definition.securitySchemes}}},_a)};function joinURLs(e,t){return e.endsWith("/")&&(e=e.slice(0,-1)),t.startsWith("/")&&(t=t.substring(1)),e+"/"+t}function addTrailingSlash(e){return e.endsWith("/")?e:e+"/"}function getSpecVersionObj(e){return e.openapi?{openapi:e.openapi}:e.swagger?{swagger:e.swagger}:void 0}function deepClone(e){if("object"!=typeof e||null===e)return e;var t=Array.isArray(e)?[]:{};for(var i in e){var o=e[i];t[i]=deepClone(o)}return t}
|
|
2
2
|
//# sourceMappingURL=ProStore.js.map
|
|
@@ -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{serializeParameterValue}from"../../redoc-lib";import{getSecurityDetails,getParameterValue}from"../../utils";import{normalizeMimeType,arrayMergeStrategy}from"../utils";import{HTTPSnippet}from"./httpsnippet";function mapOperationToHAR(e,a){var t,r,i,n,s,
|
|
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{serializeParameterValue}from"../../redoc-lib";import{getSecurityDetails,getParameterValue}from"../../utils";import{normalizeMimeType,arrayMergeStrategy}from"../utils";import{HTTPSnippet}from"./httpsnippet";function mapOperationToHAR(e,a){var t,r,i,n,o,s,l,u,p,d,c=a.exampleName,m=void 0===c?"":c,v=a.skipOptionalParameters,h=void 0!==v&&v,f=a.withOAuth2Call,g=void 0!==f&&f,y=a.spec,O=a.generatedPayloadSamplesMaxDepth,_=void 0===O?8:O,S=a.pathParams,T=void 0===S?{}:S,w=a.properties,C=void 0===w?{}:w,b=getSecurityData(null===(t=e.security)||void 0===t?void 0:t[0],g),P=b.securityHeaders,k=b.securityCookies,x=b.securityQueries,A=b.securityOAuth2ExtraCalls,E=b.basicAuth,q=null===(i=null===(r=e.requestBody)||void 0===r?void 0:r.content)||void 0===i?void 0:i.active,H={skipNonRequired:h,skipReadOnly:!0,maxSampleDepth:_},R={path:toJS(null===(n=null==e?void 0:e.requestValues)||void 0===n?void 0:n.path),cookie:toJS(null===(o=null==e?void 0:e.requestValues)||void 0===o?void 0:o.cookie),header:toJS(null===(s=null==e?void 0:e.requestValues)||void 0===s?void 0:s.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)},D=!1,z=e.parameters.filter((function(e){return"header"===e.in})).filter((function(e){return!(h&&!e.required)})).map((function(e){var a;return{name:e.name,value:(null===(a=R.header)||void 0===a?void 0:a[e.name])||getParameterValue("header",e.name)||serializeParameterValue(e,Sampler.sample(e.schema.rawSchema,H,y))}})).map((function(e){return(null==q?void 0:q.name)&&"content-type"===e.name.toLowerCase()&&(D=!0,e.value=q.name),e})).concat(P);!D&&(null==q?void 0:q.name)&&z.unshift({name:"Content-Type",value:null==q?void 0:q.name});var V=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,H,y)))})).reduce((function(e,a){for(var t,r=0,i=Object.entries(a);r<i.length;r++){var n=i[r],o=n[0],s=n[1];e.push({name:o,value:String((null===(t=R.cookie)||void 0===t?void 0:t[o])||s)})}return e}),[]).concat(k),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,H,y)))})).reduce((function(e,a){for(var t,r=0,i=Object.entries(a);r<i.length;r++){var n=i[r],o=n[0],s=n[1];e.push({name:o,value:String((null===(t=R.query)||void 0===t?void 0:t[o])||s)})}return e}),[]).concat(x),N=(null===(p=e.activeServer)||void 0===p?void 0:p.url.replace(/\/$/,""))+"/"+e.path.replace(/^\//,""),J=e.parameters.filter((function(e){return"path"===e.in})).reduce((function(e,a){var t,r=a.in,i=a.name;return e[i]=(null===(t=R.path)||void 0===t?void 0:t[i])||T[i]||getParameterValue(r,i),e}),{}),U=null===(d=null==q?void 0:q.examples)||void 0===d?void 0:d[m],I=(null==q?void 0:q.examples)||{},M=Object.values(I)[0],Y=R.body||(null==U?void 0:U.value)||(null==M?void 0:M.value)||(null==q?void 0:q.schema)&&Sampler.sample(null==q?void 0:q.schema.rawSchema,H,y),Q=null==q?void 0:q.name.toLowerCase(),L="",K=[];switch(normalizeMimeType(Q)){case"application/json":L=JSON.stringify(getDataRequest(Y,C));break;case"application/x-www-form-urlencoded":case"multipart/form-data":L=stringifyQueryString(getDataRequest(Y,C)),K=objectToHarParams(getDataRequest(Y,C));break;default:L=String(Y||"")}var B=L?{mimeType:(null==q?void 0:q.name)||"application/octet-stream",text:L,params:K}:void 0;return{method:e.httpVerb,url:N,httpVersion:"HTTP/1.1",cookies:V,headers:z,queryString:j,postData:B,headersSize:-1,bodySize:-1,securityOAuth2ExtraCalls:A,basicAuth:E,pathParameters:J,serverVariables:e.activeServer.variables}}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 a=e.lang,t=e.operation,r=e.exampleName,i=e.pathParams,n=e.properties,o=e.options,s=void 0===o?{}:o;try{var l=mapOperationToHAR(t,{exampleName:r,pathParams:i,properties:n,skipOptionalParameters:s.skipOptionalParameters,withOAuth2Call:s.withOAuth2Call,spec:s.spec,generatedPayloadSamplesMaxDepth:s.generatedPayloadSamplesMaxDepth}),u=new HTTPSnippet(l);return langToSnippetConfig[a]?u.convert(langToSnippetConfig[a].code,langToSnippetConfig[a].defaultTarget,__assign(__assign({},langToSnippetConfig[a].defaultOptions),s)):"Language is not supported."}catch(e){return console.error(e),"Failed to generate code sample."}}function getSecurityData(e,a){for(var t,r,i,n,o={securityHeaders:[],securityCookies:[],securityQueries:[],securityOAuth2ExtraCalls:[],basicAuth:void 0},s=0,l=(null==e?void 0:e.schemes)||[];s<l.length;s++){var u=l[s],p=getSecurityDetails(u.id);switch(u.type){case"openIdConnect":null===(t=o.securityHeaders)||void 0===t||t.push({name:"Authorization",value:"Bearer <YOUR_TOKEN_HERE>"});break;case"oauth2":var d=p.token?(p.token.token_type||"Bearer")+" "+p.token.access_token:"Bearer <YOUR_TOKEN_HERE>";u.flows.clientCredentials&&a?o.securityOAuth2ExtraCalls.push(getOAuth2ClientCredsCallHar(u.flows.clientCredentials,u.scopes,p)):u.flows.password&&a&&o.securityOAuth2ExtraCalls.push(getOAuth2PasswordCallHar(u.flows.password,u.scopes,p)),null===(r=o.securityHeaders)||void 0===r||r.push({name:"Authorization",value:d});break;case"apiKey":var c=p.raw||"YOUR_API_KEY_HERE";"header"===u.in&&(null===(i=o.securityHeaders)||void 0===i||i.push({name:u.name,value:c})),"cookie"===u.in&&o.securityCookies.push({name:u.name,value:c}),"query"===u.in&&o.securityQueries.push({name:u.name,value:c});break;case"http":"basic"===u.scheme?o.basicAuth={username:p.username||"<username>",password:p.password||"<password>"}:null===(n=o.securityHeaders)||void 0===n||n.push({name:"Authorization",value:capitalizeFirst(u.scheme||"bearer")+" <YOUR_"+(u.bearerFormat||"TOKEN")+"_HERE>"})}}return o}function getOAuth2PasswordCallHar(e,a,t){return{method:"POST",url:e.tokenUrl,httpVersion:"HTTP/1.1",headers:[{name:"Content-Type",value:"application/x-www-form-urlencoded"},{name:"Accept",value:"application/json"}],queryString:[],postData:{mimeType:"application/x-www-form-urlencoded",text:"",params:[{name:"grant_type",value:"password"},{name:"client_id",value:t.client_id||"YOUR_CLIENT_ID"},{name:"client_secret",value:t.client_secret||"YOUR_CLIENT_SECRET"},{name:"username",value:t.username||"<username>"},{name:"password",value:t.password||"<password>"},a.length?{name:"scope",value:a.join(" ")}:void 0].filter(isDefined)},cookies:[],headersSize:-1,bodySize:-1,securityOAuth2ExtraCalls:[]}}function getOAuth2ClientCredsCallHar(e,a,t){return{method:"POST",url:e.tokenUrl,httpVersion:"HTTP/1.1",headers:[{name:"Content-Type",value:"application/x-www-form-urlencoded"},{name:"Accept",value:"application/json"}],queryString:[],postData:{mimeType:"application/x-www-form-urlencoded",text:"",params:[{name:"grant_type",value:"client_credentials"},{name:"client_id",value:t.client_id||"YOUR_CLIENT_ID"},{name:"client_secret",value:t.client_secret||"YOUR_CLIENT_SECRET"},a.length?{name:"scope",value:a.join(" ")}:void 0].filter(isDefined)},cookies:[],headersSize:-1,bodySize:-1,securityOAuth2ExtraCalls:[]}}function getDataRequest(e,a){if(e){if("object"==typeof e)return merge(e,a,{arrayMerge:arrayMergeStrategy});try{return merge(JSON.parse(e),a,{arrayMerge:arrayMergeStrategy})}catch(e){return!1}}return!1}function objectToHarParams(e){for(var a=[],t=0,r=Object.entries(e);t<r.length;t++){var i=r[t],n=i[0],o=i[1];a.push({name:n,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 ProHashHistoryService=function(){function e(e,t){var r=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,"emit",{enumerable:!0,configurable:!0,writable:!0,value:function(){r._emiter.emit("popstate",r.currentId)}});var i=e.routingBasePath||"";this.basePath=i.endsWith("/")?i.substring(0,i.length-1):i,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);if(t.startsWith(this.basePath+"/")&&(t=t.substring(this.basePath.length+1)),t.endsWith("/")&&(t=t.substring(0,t.length-1)),e.startsWith("operation/")||(null==e?void 0:e.startsWith("section/"))){if(this.multiSpec){var r=t.split("/")[0];return joinWithSeparator(r,e)}return e}return t?joinWithSeparator(t,e):e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"makeUrl",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r="";return IS_BROWSER&&(r=window.location.search),(e.startsWith("/")?"/"+(this.basePath?this.basePath+"/":"")+e.substring(1):e)+r+(t?"#"+t:"")}}),Object.defineProperty(e.prototype,"linkForId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!e)return"";if(""===e)return this.makeUrl("","");var t="";return this.multiSpec&&(t="/"+e.split("/")[0],e=e.split("/").slice(1).join("/")),this.makeUrl(t,e)}}),Object.defineProperty(e.prototype,"generateDeepLink",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(t)return t+this.options.deepLinkPrefix+e}}),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),window.addEventListener("hashchange",this.emit,!1))}}),Object.defineProperty(e.prototype,"dispose",{enumerable:!1,configurable:!0,writable:!0,value:function(){IS_BROWSER&&(window.removeEventListener("popstate",this.emit),window.removeEventListener("hashchange",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){var r=this;if(void 0===t&&(t=!1),IS_BROWSER&&e){var i,n=new URL(e,window.location.href);i=n,t?window.history.replaceState(null,"",i):(window.history.pushState(null,"",i),r.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 r=new URL(this.linkForId(e),window.location.href);t?IS_BROWSER&&window.history.replaceState(null,"",r.href):IS_BROWSER&&(window.history.pushState(null,"",r.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{ProHashHistoryService};
|
|
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 ProHashHistoryService=function(){function e(e,t){var r=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,"emit",{enumerable:!0,configurable:!0,writable:!0,value:function(){r._emiter.emit("popstate",r.currentId)}});var i=e.routingBasePath||"";this.basePath=i.endsWith("/")?i.substring(0,i.length-1):i,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);if(t.startsWith(this.basePath+(this.basePath.endsWith(".html")?"":"/"))&&(t=t.substring(this.basePath.length+1)),t.endsWith("/")&&(t=t.substring(0,t.length-1)),e.startsWith("operation/")||(null==e?void 0:e.startsWith("section/"))){if(this.multiSpec){var r=t.split("/")[0];return joinWithSeparator(r,e)}return e}return t?joinWithSeparator(t,e):e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"makeUrl",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r="";return IS_BROWSER&&(r=window.location.search),(e.startsWith("/")?"/"+(this.basePath?this.basePath+"/":"")+e.substring(1):e)+r+(t?"#"+t:"")}}),Object.defineProperty(e.prototype,"linkForId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!e)return"";if(""===e)return this.makeUrl("","");var t="";return this.multiSpec&&(t="/"+e.split("/")[0],e=e.split("/").slice(1).join("/")),this.makeUrl(t,e)}}),Object.defineProperty(e.prototype,"generateDeepLink",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(t)return t+this.options.deepLinkPrefix+e}}),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),window.addEventListener("hashchange",this.emit,!1))}}),Object.defineProperty(e.prototype,"dispose",{enumerable:!1,configurable:!0,writable:!0,value:function(){IS_BROWSER&&(window.removeEventListener("popstate",this.emit),window.removeEventListener("hashchange",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){var r=this;if(void 0===t&&(t=!1),IS_BROWSER&&e){var i,n=new URL(e,window.location.href);i=n,t?window.history.replaceState(null,"",i):(window.history.pushState(null,"",i),r.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 r=new URL(this.linkForId(e),window.location.href);t?IS_BROWSER&&window.history.replaceState(null,"",r.href):IS_BROWSER&&(window.history.pushState(null,"",r.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{ProHashHistoryService};
|
|
2
2
|
//# sourceMappingURL=ProHashHistoryService.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/reference-docs",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.24.0",
|
|
4
4
|
"description": "Redocly Reference Docs",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib-esm/index.js",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"prismjs": "^1.22.0",
|
|
44
44
|
"prop-types": "^15.7.2",
|
|
45
45
|
"query-string": "^6.13.6",
|
|
46
|
-
"react-codemirror2": "
|
|
46
|
+
"react-codemirror2-react-17": "1.0.0",
|
|
47
47
|
"react-tabs": "^3.1.1",
|
|
48
48
|
"serve-static": "^1.14.1",
|
|
49
49
|
"slugify": "^1.4.4",
|