@redocly/reference-docs 2.21.0 → 2.23.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.
Files changed (46) hide show
  1. package/bin/cli/commands/redocly-docs-cli.min.js +27 -27
  2. package/bin/cli/commands/redocly-docs-cli.min.js.LICENSE.txt +1 -1
  3. package/dist/console.redocly-reference-docs.min.js +96 -96
  4. package/dist/oauth2-redirect.js +1 -1
  5. package/dist/redocly-reference-docs.min.js +889 -889
  6. package/lib/components/NextSectionButton.js +1 -1
  7. package/lib/components/console/CodemirrorInput.d.ts +1 -1
  8. package/lib/components/console/CodemirrorInput.js +1 -1
  9. package/lib/components/console/Console.js +1 -1
  10. package/lib/components/console/RequestBody.d.ts +2 -2
  11. package/lib/components/console/RequestBody.js +1 -1
  12. package/lib/redoc-lib/src/common-elements/CopyButtonWrapper.js +1 -1
  13. package/lib/redoc-lib/src/components/Callbacks/CallbackDetails.js +1 -1
  14. package/lib/redoc-lib/src/components/Operation/Operation.js +1 -1
  15. package/lib/redoc-lib/src/components/RequestSamples/RequestSamples.js +1 -1
  16. package/lib/redoc-lib/src/components/SecurityRequirement/SecurityRequirement.js +1 -1
  17. package/lib/redoc-lib/src/components/SourceCode/SourceCode.js +1 -1
  18. package/lib/redoc-lib/src/services/RedocNormalizedOptions.d.ts +2 -0
  19. package/lib/redoc-lib/src/services/RedocNormalizedOptions.js +1 -1
  20. package/lib/redoc-lib/src/services/models/Operation.d.ts +6 -0
  21. package/lib/redoc-lib/src/services/models/Operation.js +1 -1
  22. package/lib/redoc-lib/src/services/models/Schema.js +1 -1
  23. package/lib/services/ProStore.js +1 -1
  24. package/lib/services/code-samples/generator.js +1 -1
  25. package/lib/services/history/ProHashHistoryService.js +1 -1
  26. package/lib-esm/components/NextSectionButton.js +1 -1
  27. package/lib-esm/components/console/CodemirrorInput.d.ts +1 -1
  28. package/lib-esm/components/console/CodemirrorInput.js +1 -1
  29. package/lib-esm/components/console/Console.js +1 -1
  30. package/lib-esm/components/console/RequestBody.d.ts +2 -2
  31. package/lib-esm/components/console/RequestBody.js +1 -1
  32. package/lib-esm/redoc-lib/src/common-elements/CopyButtonWrapper.js +1 -1
  33. package/lib-esm/redoc-lib/src/components/Callbacks/CallbackDetails.js +1 -1
  34. package/lib-esm/redoc-lib/src/components/Operation/Operation.js +1 -1
  35. package/lib-esm/redoc-lib/src/components/RequestSamples/RequestSamples.js +1 -1
  36. package/lib-esm/redoc-lib/src/components/SecurityRequirement/SecurityRequirement.js +1 -1
  37. package/lib-esm/redoc-lib/src/components/SourceCode/SourceCode.js +1 -1
  38. package/lib-esm/redoc-lib/src/services/RedocNormalizedOptions.d.ts +2 -0
  39. package/lib-esm/redoc-lib/src/services/RedocNormalizedOptions.js +1 -1
  40. package/lib-esm/redoc-lib/src/services/models/Operation.d.ts +6 -0
  41. package/lib-esm/redoc-lib/src/services/models/Operation.js +1 -1
  42. package/lib-esm/redoc-lib/src/services/models/Schema.js +1 -1
  43. package/lib-esm/services/ProStore.js +1 -1
  44. package/lib-esm/services/code-samples/generator.js +1 -1
  45. package/lib-esm/services/history/ProHashHistoryService.js +1 -1
  46. package/package.json +3 -3
@@ -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
- import{__assign,__decorate,__rest,__spreadArray}from"tslib";import{action,observable,makeObservable}from"mobx";import{detectType,extractExtensions,humanizeConstraints,isNamedDefinition,isObject,isPrimitiveType,JsonPointer,pluralizeType,sortByField,sortByRequired}from"../../utils/";import{l}from"../Labels";import{FieldModel}from"./Field";var SchemaModel=function(){function e(e,i,t,r,n,a,s){void 0===n&&(n=!1),void 0===s&&(s={}),Object.defineProperty(this,"parser",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"parent",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(this,"deps",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"pointer",{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,"displayType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"typePrefix",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"title",{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,"externalDocs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isPrimitive",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isCircular",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"format",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"displayFormat",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"nullable",{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,"pattern",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"example",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"enum",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"default",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"readOnly",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"writeOnly",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"constraints",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_fields",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"items",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"oneOf",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"oneOfType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"discriminatorProp",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"activeOneOf",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"rawSchema",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"schema",{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,"x-enumDescriptions",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"const",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"contentEncoding",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"contentMediaType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"minItems",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"maxItems",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),makeObservable(this),this.pointer=i.$ref||t||"",this.rawSchema=e.deref(i,!1,!0),this.schema=e.mergeAllOf(this.rawSchema,this.pointer,n),this.init(e,n),e.exitRef(i),e.exitParents(this.schema),r.showExtensions&&(this.extensions=extractExtensions(this.schema,r.showExtensions))}return Object.defineProperty(e.prototype,"activateOneOf",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.activeOneOf=e}}),Object.defineProperty(e.prototype,"hasType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.type===e||Array.isArray(this.type)&&this.type.includes(e)}}),Object.defineProperty(e.prototype,"fields",{get:function(){if(!this.isCircular)return!this._fields&&this.hasType("object")&&(this._fields=buildFields(this.parser,this.schema,this.pointer,this.options,this,this.deps)),this._fields},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasCircularParent",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var i=this;if(this.parent){if(e.some((function(e){var t,r;if(!e)return!1;var n=i.parent;return(null==n?void 0:n.pointer)===e||(!!(null===(r=null===(t=null==n?void 0:n.schema.parentRefs)||void 0===t?void 0:t.some)||void 0===r?void 0:r.call(t,(function(i){return i===e})))||void 0)})))return!0;if(this.parent.hasCircularParent(e))return!0}return!1}}),Object.defineProperty(e.prototype,"init",{enumerable:!1,configurable:!0,writable:!0,value:function(i,t){var r,n,a,s,o,p,d,u=this,f=this.schema;if(this.isCircular=f["x-circular-ref"]||this.hasCircularParent(__spreadArray([this.pointer],this.schema.parentRefs||[],!0)),this.title=f.title||isNamedDefinition(this.pointer)&&JsonPointer.baseName(this.pointer)||"",this.description=f.description||"",this.type=f.type||detectType(f),this.format=f.format,this.enum=f.enum||[],this["x-enumDescriptions"]=f["x-enumDescriptions"],this.example=f.example,this.deprecated=!!f.deprecated,this.pattern=f.pattern,this.externalDocs=f.externalDocs,this.constraints=humanizeConstraints(f),this.displayFormat=this.format,this.isPrimitive=isPrimitiveType(f,this.type),this.default=f.default,this.readOnly=!!f.readOnly,this.writeOnly=!!f.writeOnly,this.const=f.const||"",this.contentEncoding=f.contentEncoding,this.contentMediaType=f.contentMediaType,this.minItems=f.minItems,this.maxItems=f.maxItems,(f.nullable||f["x-nullable"])&&(Array.isArray(this.type)&&!this.type.some((function(e){return null===e||"null"===e}))?this.type=__spreadArray(__spreadArray([],this.type,!0),["null"],!1):Array.isArray(this.type)||null===this.type&&"null"===this.type||(this.type=[this.type,"null"])),this.displayType=Array.isArray(this.type)?this.type.map((function(e){return null===e?"null":e})).join(" or "):this.type,!this.isCircular)if(f.if&&f.then||f.if&&f.else)this.initConditionalOperators(f,i);else if(t||void 0===getDiscriminator(f)){if(t&&Array.isArray(f.oneOf)&&f.oneOf.find((function(e){return e.$ref===u.pointer}))&&delete f.oneOf,void 0!==f.oneOf)return this.initOneOf(f.oneOf,i),this.oneOfType="One of",void(void 0!==f.anyOf&&console.warn("oneOf and anyOf are not supported on the same level. Skipping anyOf at "+this.pointer));if(void 0!==f.anyOf)return this.initOneOf(f.anyOf,i),void(this.oneOfType="Any of");if(this.hasType("array")&&(Array.isArray(f.items)||Array.isArray(f.prefixItems)?this._fields=buildFields(i,f,this.pointer,this.options,this,this.deps):isObject(f.items)&&(this.items=new e(i,f.items,this.pointer+"/items",this.options)),this.displayType=f.prefixItems||Array.isArray(f.items)?"items":pluralizeType((null===(r=this.items)||void 0===r?void 0:r.displayType)||this.displayType),this.displayFormat=(null===(n=this.items)||void 0===n?void 0:n.format)||"",this.typePrefix=(null===(a=this.items)||void 0===a?void 0:a.typePrefix)||""+l("arrayOf"),this.title=this.title||(null===(s=this.items)||void 0===s?void 0:s.title)||"",this.isPrimitive=(null===(o=this.items)||void 0===o?void 0:o.isPrimitive)||this.isPrimitive,void 0===this.example&&void 0!==(null===(p=this.items)||void 0===p?void 0:p.example)&&(this.example=[this.items.example]),(null===(d=this.items)||void 0===d?void 0:d.isPrimitive)&&(this.enum=this.items.enum,this["x-enumDescriptions"]=this.items["x-enumDescriptions"]),Array.isArray(this.type))){var c=this.type.filter((function(e){return"array"!==e}));c.length&&(this.displayType+=" or "+c.join(" or "))}this.enum.length&&this.options.sortEnumValuesAlphabetically&&this.enum.sort()}else this.initDiscriminator(f,i)}}),Object.defineProperty(e.prototype,"initOneOf",{enumerable:!1,configurable:!0,writable:!0,value:function(i,t){var r=this;if(this.oneOf=i.map((function(i,n){var a=t.deref(i,!1,!0),s=t.mergeAllOf(a,r.pointer+"/oneOf/"+n),o=isNamedDefinition(i.$ref)&&!s.title?JsonPointer.baseName(i.$ref):""+(s.title||"")+(s.const&&JSON.stringify(s.const)||""),l=new e(t,__assign(__assign({},s),{title:o,allOf:[__assign(__assign({},r.schema),{oneOf:void 0,anyOf:void 0})]}),r.pointer+"/oneOf/"+n,r.options,!1,r.parent,__assign(__assign({},r.deps),{parentFieldFullPath:r.deps.parentFieldFullPath?r.deps.parentFieldFullPath+r.options.deepLinkSeparator+n:n.toString()}));return t.exitRef(i),t.exitParents(s),l})),this.options.simpleOneOfTypeLabel){var n=collectUniqueOneOfTypesDeep(this);this.displayType=n.join(" or ")}else this.displayType=this.oneOf.map((function(e){var i=e.typePrefix+(e.title?e.title+" ("+e.displayType+")":e.displayType);return i.indexOf(" or ")>-1&&(i="("+i+")"),i})).join(" or ")}}),Object.defineProperty(e.prototype,"initDiscriminator",{enumerable:!1,configurable:!0,writable:!0,value:function(i,t){var r=this,n=getDiscriminator(i);this.discriminatorProp=null==n?void 0:n.propertyName;var a=t.findDerived(__spreadArray(__spreadArray([],i.parentRefs||[],!0),[this.pointer],!1));if(i.oneOf)for(var s=0,o=i.oneOf;s<o.length;s++){var l=o[s];if(void 0!==l.$ref){var p=JsonPointer.baseName(l.$ref);a[l.$ref]=p}}var d=(null==n?void 0:n.mapping)||{},u=(null==n?void 0:n["x-explicitMappingOnly"])||!1;0===Object.keys(d).length&&(u=!1);var f={};for(var c in d){var h=d[c];Array.isArray(f[h])?f[h].push(c):f[h]=[c]}for(var b=__assign(u?{}:__assign({},a),f),m=[],y=0,v=Object.keys(b);y<v.length;y++){var O=b[h=v[y]];if(Array.isArray(O))for(var g=0,P=O;g<P.length;g++){var w=P[g];m.push({$ref:h,name:w})}else m.push({$ref:h,name:O})}var j=Object.keys(d);0!==j.length&&(m=m.sort((function(e,i){var t=j.indexOf(e.name),r=j.indexOf(i.name);return t<0&&r<0?e.name.localeCompare(i.name):t<0?1:r<0?-1:t-r}))),this.oneOf=m.map((function(i,n){var a=i.$ref,s=i.name,o=new e(t,t.byRef(a),a,r.options,!0,r.parent,__assign(__assign({},r.deps),{parentFieldFullPath:r.deps.parentFieldFullPath?r.deps.parentFieldFullPath+r.options.deepLinkSeparator+n:n.toString()}));return o.title=s,o}))}}),Object.defineProperty(e.prototype,"initConditionalOperators",{enumerable:!1,configurable:!0,writable:!0,value:function(i,t){var r=this,n=i.if,a=i.else,s=void 0===a?{}:a,o=i.then,l=void 0===o?{}:o,p=__rest(i,["if","else","then"]),d=[{allOf:[p,l,n],title:n&&n["x-displayName"]||(null==n?void 0:n.title)||"case 1"},{allOf:[p,s],title:s&&s["x-displayName"]||(null==s?void 0:s.title)||"case 2"}];this.oneOf=d.map((function(i,n){return new e(t,__assign({},i),r.pointer+"/oneOf/"+n,r.options,!1,r.parent,__assign(__assign({},r.deps),{parentFieldFullPath:r.deps.parentFieldFullPath?r.deps.parentFieldFullPath+r.options.deepLinkSeparator+n:n.toString()}))})),this.oneOfType="One of"}}),__decorate([observable],e.prototype,"activeOneOf",void 0),__decorate([action],e.prototype,"activateOneOf",null),e}();export{SchemaModel};function normalizeField(e,i,t){return e||(console.warn('Field "'+i+'" is invalid, skipping.\n Field must be an object but got '+typeof e+' at "'+t+'"'),{})}function buildFields(e,i,t,r,n,a){var s=i.properties||i.prefixItems||i.items||{},o=i.patternProperties||{},l=i.additionalProperties||i.unevaluatedProperties,p=i.prefixItems?i.items:i.additionalItems,d=i.default||{},u=Object.keys(s).map((function(o){var l=normalizeField(s[o],o,t),p=void 0!==i.required&&i.required.indexOf(o)>-1;return new FieldModel(e,{name:i.properties?o:"["+o+"]",required:p,schema:__assign(__assign({},l),{default:void 0===l.default&&d?d[o]:l.default})},t+"/properties/"+o,r,n,a)}));return r.sortPropsAlphabetically&&(u=sortByField(u,"name")),r.requiredPropsFirst&&(u=sortByRequired(u,r.sortPropsAlphabetically?void 0:i.required)),u.push.apply(u,Object.keys(o).map((function(i){var s=normalizeField(o[i],i,t);return new FieldModel(e,{name:i,required:!1,schema:s,kind:"patternProperties"},t+"/patternProperties/"+i,r,n,a)}))),(isObject(l)||!0===l)&&u.push(new FieldModel(e,{name:(isObject(l)&&l["x-additionalPropertiesName"]||"property name").concat("*"),required:!1,schema:!0===l?{}:l,kind:"additionalProperties"},t+"/additionalProperties",r,n,a)),u.push.apply(u,buildAdditionalItems({parser:e,schema:p,fieldsCount:u.length,$ref:t,options:r,parent:n,deps:a})),u}function buildAdditionalItems(e){var i=e.parser,t=e.schema,r=void 0!==t&&t,n=e.fieldsCount,a=e.$ref,s=e.options,o=e.parent,l=e.deps;return"boolean"==typeof r?r?[new FieldModel(i,{name:"["+n+"...]",schema:{},kind:"additionalItems"},a+"/additionalItems",s,o,l)]:[]:Array.isArray(r)?__spreadArray([],r.map((function(e,t){return new FieldModel(i,{name:"["+(n+t)+"]",schema:e,kind:"additionalItems"},a+"/additionalItems/"+t,s,o,l)})),!0):isObject(r)?[new FieldModel(i,{name:"["+n+"...]",schema:r,kind:"additionalItems"},a+"/additionalItems",s,o,l)]:[]}function getDiscriminator(e){return e.discriminator||e["x-discriminator"]}function collectUniqueOneOfTypesDeep(e){var i=new Set;return function e(t){for(var r=0,n=t.oneOf||[];r<n.length;r++){var a=n[r];a.oneOf?e(a):a.type&&i.add(a.type)}}(e),Array.from(i.values())}
1
+ import{__assign,__decorate,__rest,__spreadArray}from"tslib";import{action,observable,makeObservable}from"mobx";import{detectType,extractExtensions,humanizeConstraints,isNamedDefinition,isObject,isPrimitiveType,JsonPointer,pluralizeType,sortByField,sortByRequired}from"../../utils/";import{l}from"../Labels";import{FieldModel}from"./Field";var SchemaModel=function(){function e(e,i,t,r,n,a,s){void 0===n&&(n=!1),void 0===s&&(s={}),Object.defineProperty(this,"parser",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"parent",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(this,"deps",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"pointer",{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,"displayType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"typePrefix",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"title",{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,"externalDocs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isPrimitive",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isCircular",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"format",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"displayFormat",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"nullable",{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,"pattern",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"example",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"enum",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"default",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"readOnly",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"writeOnly",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"constraints",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_fields",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"items",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"oneOf",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"oneOfType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"discriminatorProp",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"activeOneOf",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"rawSchema",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"schema",{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,"x-enumDescriptions",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"const",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"contentEncoding",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"contentMediaType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"minItems",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"maxItems",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),makeObservable(this),this.pointer=i.$ref||t||"",this.rawSchema=e.deref(i,!1,!0),this.schema=e.mergeAllOf(this.rawSchema,this.pointer,n),this.init(e,n),e.exitRef(i),e.exitParents(this.schema),r.showExtensions&&(this.extensions=extractExtensions(this.schema,r.showExtensions))}return Object.defineProperty(e.prototype,"activateOneOf",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.activeOneOf=e}}),Object.defineProperty(e.prototype,"hasType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.type===e||Array.isArray(this.type)&&this.type.includes(e)}}),Object.defineProperty(e.prototype,"fields",{get:function(){if(!this.isCircular)return!this._fields&&this.hasType("object")&&(this._fields=buildFields(this.parser,this.schema,this.pointer,this.options,this,this.deps)),this._fields},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasCircularParent",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var i=this;if(this.parent){if(e.some((function(e){var t,r;if(!e)return!1;var n=i.parent;return(null==n?void 0:n.pointer)===e||(!!(null===(r=null===(t=null==n?void 0:n.schema.parentRefs)||void 0===t?void 0:t.some)||void 0===r?void 0:r.call(t,(function(i){return i===e})))||void 0)})))return!0;if(this.parent.hasCircularParent(e))return!0}return!1}}),Object.defineProperty(e.prototype,"init",{enumerable:!1,configurable:!0,writable:!0,value:function(i,t){var r,n,a,s,o,p,d,u,f=this,c=this.schema;if(this.isCircular=c["x-circular-ref"]||this.hasCircularParent(__spreadArray([this.pointer],this.schema.parentRefs||[],!0)),this.title=c.title||isNamedDefinition(this.pointer)&&JsonPointer.baseName(this.pointer)||"",this.description=c.description||"",this.type=c.type||detectType(c),this.format=c.format,this.enum=c.enum||[],this["x-enumDescriptions"]=c["x-enumDescriptions"],this.example=c.example,this.deprecated=!!c.deprecated,this.pattern=c.pattern,this.externalDocs=c.externalDocs,this.constraints=humanizeConstraints(c),this.displayFormat=this.format,this.isPrimitive=isPrimitiveType(c,this.type),this.default=c.default,this.readOnly=!!c.readOnly,this.writeOnly=!!c.writeOnly,this.const=c.const||"",this.contentEncoding=c.contentEncoding,this.contentMediaType=c.contentMediaType,this.minItems=c.minItems,this.maxItems=c.maxItems,(c.nullable||c["x-nullable"])&&(Array.isArray(this.type)&&!this.type.some((function(e){return null===e||"null"===e}))?this.type=__spreadArray(__spreadArray([],this.type,!0),["null"],!1):Array.isArray(this.type)||null===this.type&&"null"===this.type||(this.type=[this.type,"null"])),this.displayType=Array.isArray(this.type)?this.type.map((function(e){return null===e?"null":e})).join(" or "):this.type,!this.isCircular)if(c.if&&c.then||c.if&&c.else)this.initConditionalOperators(c,i);else if(t||void 0===getDiscriminator(c)){if(t&&Array.isArray(c.oneOf)&&c.oneOf.find((function(e){return e.$ref===f.pointer}))&&delete c.oneOf,void 0!==c.oneOf)return this.initOneOf(c.oneOf,i),this.oneOfType="One of",void(void 0!==c.anyOf&&console.warn("oneOf and anyOf are not supported on the same level. Skipping anyOf at "+this.pointer));if(void 0!==c.anyOf)return this.initOneOf(c.anyOf,i),void(this.oneOfType="Any of");if(this.hasType("array")&&(Array.isArray(c.items)||Array.isArray(c.prefixItems)?this._fields=buildFields(i,c,this.pointer,this.options,this,this.deps):isObject(c.items)&&(this.items=new e(i,c.items,this.pointer+"/items",this.options)),this.displayType=c.prefixItems||Array.isArray(c.items)?"items":pluralizeType((null===(r=this.items)||void 0===r?void 0:r.displayType)||this.displayType),this.displayFormat=(null===(n=this.items)||void 0===n?void 0:n.format)||"",this.typePrefix=(null===(a=this.items)||void 0===a?void 0:a.typePrefix)||""+l("arrayOf"),this.title=this.title||(null===(s=this.items)||void 0===s?void 0:s.title)||"",this.isPrimitive=void 0!==(null===(o=this.items)||void 0===o?void 0:o.isPrimitive)?null===(p=this.items)||void 0===p?void 0:p.isPrimitive:this.isPrimitive,void 0===this.example&&void 0!==(null===(d=this.items)||void 0===d?void 0:d.example)&&(this.example=[this.items.example]),(null===(u=this.items)||void 0===u?void 0:u.isPrimitive)&&(this.enum=this.items.enum,this["x-enumDescriptions"]=this.items["x-enumDescriptions"]),Array.isArray(this.type))){var h=this.type.filter((function(e){return"array"!==e}));h.length&&(this.displayType+=" or "+h.join(" or "))}this.enum.length&&this.options.sortEnumValuesAlphabetically&&this.enum.sort()}else this.initDiscriminator(c,i)}}),Object.defineProperty(e.prototype,"initOneOf",{enumerable:!1,configurable:!0,writable:!0,value:function(i,t){var r=this;if(this.oneOf=i.map((function(i,n){var a=t.deref(i,!1,!0),s=t.mergeAllOf(a,r.pointer+"/oneOf/"+n),o=isNamedDefinition(i.$ref)&&!s.title?JsonPointer.baseName(i.$ref):""+(s.title||"")+(s.const&&JSON.stringify(s.const)||""),l=new e(t,__assign(__assign({},s),{title:o,allOf:[__assign(__assign({},r.schema),{oneOf:void 0,anyOf:void 0})]}),r.pointer+"/oneOf/"+n,r.options,!1,r.parent,__assign(__assign({},r.deps),{parentFieldFullPath:r.deps.parentFieldFullPath?r.deps.parentFieldFullPath+r.options.deepLinkSeparator+n:n.toString()}));return t.exitRef(i),t.exitParents(s),l})),this.options.simpleOneOfTypeLabel){var n=collectUniqueOneOfTypesDeep(this);this.displayType=n.join(" or ")}else this.displayType=this.oneOf.map((function(e){var i=e.typePrefix+(e.title?e.title+" ("+e.displayType+")":e.displayType);return i.indexOf(" or ")>-1&&(i="("+i+")"),i})).join(" or ")}}),Object.defineProperty(e.prototype,"initDiscriminator",{enumerable:!1,configurable:!0,writable:!0,value:function(i,t){var r=this,n=getDiscriminator(i);this.discriminatorProp=null==n?void 0:n.propertyName;var a=t.findDerived(__spreadArray(__spreadArray([],i.parentRefs||[],!0),[this.pointer],!1));if(i.oneOf)for(var s=0,o=i.oneOf;s<o.length;s++){var l=o[s];if(void 0!==l.$ref){var p=JsonPointer.baseName(l.$ref);a[l.$ref]=p}}var d=(null==n?void 0:n.mapping)||{},u=(null==n?void 0:n["x-explicitMappingOnly"])||!1;0===Object.keys(d).length&&(u=!1);var f={};for(var c in d){var h=d[c];Array.isArray(f[h])?f[h].push(c):f[h]=[c]}for(var b=__assign(u?{}:__assign({},a),f),m=[],y=0,v=Object.keys(b);y<v.length;y++){var O=b[h=v[y]];if(Array.isArray(O))for(var P=0,g=O;P<g.length;P++){var w=g[P];m.push({$ref:h,name:w})}else m.push({$ref:h,name:O})}var j=Object.keys(d);0!==j.length&&(m=m.sort((function(e,i){var t=j.indexOf(e.name),r=j.indexOf(i.name);return t<0&&r<0?e.name.localeCompare(i.name):t<0?1:r<0?-1:t-r}))),this.oneOf=m.map((function(i,n){var a=i.$ref,s=i.name,o=new e(t,t.byRef(a),a,r.options,!0,r.parent,__assign(__assign({},r.deps),{parentFieldFullPath:r.deps.parentFieldFullPath?r.deps.parentFieldFullPath+r.options.deepLinkSeparator+n:n.toString()}));return o.title=s,o}))}}),Object.defineProperty(e.prototype,"initConditionalOperators",{enumerable:!1,configurable:!0,writable:!0,value:function(i,t){var r=this,n=i.if,a=i.else,s=void 0===a?{}:a,o=i.then,l=void 0===o?{}:o,p=__rest(i,["if","else","then"]),d=[{allOf:[p,l,n],title:n&&n["x-displayName"]||(null==n?void 0:n.title)||"case 1"},{allOf:[p,s],title:s&&s["x-displayName"]||(null==s?void 0:s.title)||"case 2"}];this.oneOf=d.map((function(i,n){return new e(t,__assign({},i),r.pointer+"/oneOf/"+n,r.options,!1,r.parent,__assign(__assign({},r.deps),{parentFieldFullPath:r.deps.parentFieldFullPath?r.deps.parentFieldFullPath+r.options.deepLinkSeparator+n:n.toString()}))})),this.oneOfType="One of"}}),__decorate([observable],e.prototype,"activeOneOf",void 0),__decorate([action],e.prototype,"activateOneOf",null),e}();export{SchemaModel};function normalizeField(e,i,t){return e||(console.warn('Field "'+i+'" is invalid, skipping.\n Field must be an object but got '+typeof e+' at "'+t+'"'),{})}function buildFields(e,i,t,r,n,a){var s=i.properties||i.prefixItems||i.items||{},o=i.patternProperties||{},l=i.additionalProperties||i.unevaluatedProperties,p=i.prefixItems?i.items:i.additionalItems,d=i.default||{},u=Object.keys(s).map((function(o){var l=normalizeField(s[o],o,t),p=void 0!==i.required&&i.required.indexOf(o)>-1;return new FieldModel(e,{name:i.properties?o:"["+o+"]",required:p,schema:__assign(__assign({},l),{default:void 0===l.default&&d?d[o]:l.default})},t+"/properties/"+o,r,n,a)}));return r.sortPropsAlphabetically&&(u=sortByField(u,"name")),r.requiredPropsFirst&&(u=sortByRequired(u,r.sortPropsAlphabetically?void 0:i.required)),u.push.apply(u,Object.keys(o).map((function(i){var s=normalizeField(o[i],i,t);return new FieldModel(e,{name:i,required:!1,schema:s,kind:"patternProperties"},t+"/patternProperties/"+i,r,n,a)}))),(isObject(l)||!0===l)&&u.push(new FieldModel(e,{name:(isObject(l)&&l["x-additionalPropertiesName"]||"property name").concat("*"),required:!1,schema:!0===l?{}:l,kind:"additionalProperties"},t+"/additionalProperties",r,n,a)),u.push.apply(u,buildAdditionalItems({parser:e,schema:p,fieldsCount:u.length,$ref:t,options:r,parent:n,deps:a})),u}function buildAdditionalItems(e){var i=e.parser,t=e.schema,r=void 0!==t&&t,n=e.fieldsCount,a=e.$ref,s=e.options,o=e.parent,l=e.deps;return"boolean"==typeof r?r?[new FieldModel(i,{name:"["+n+"...]",schema:{},kind:"additionalItems"},a+"/additionalItems",s,o,l)]:[]:Array.isArray(r)?__spreadArray([],r.map((function(e,t){return new FieldModel(i,{name:"["+(n+t)+"]",schema:e,kind:"additionalItems"},a+"/additionalItems/"+t,s,o,l)})),!0):isObject(r)?[new FieldModel(i,{name:"["+n+"...]",schema:r,kind:"additionalItems"},a+"/additionalItems",s,o,l)]:[]}function getDiscriminator(e){return e.discriminator||e["x-discriminator"]}function collectUniqueOneOfTypesDeep(e){var i=new Set;return function e(t){for(var r=0,n=t.oneOf||[];r<n.length;r++){var a=n[r];a.oneOf?e(a):a.type&&i.add(a.type)}}(e),Array.from(i.values())}
2
2
  //# sourceMappingURL=Schema.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;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=void 0!==this.rawOptions.routingStrategy?this.rawOptions.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}
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,o=a.exampleName,l=void 0===o?"":o,u=a.skipOptionalParameters,p=void 0!==u&&u,c=a.withOAuth2Call,d=void 0!==c&&c,m=a.spec,f=a.generatedPayloadSamplesMaxDepth,h=void 0===f?8:f,v=a.pathParams,g=void 0===v?{}:v,y=a.properties,O=void 0===y?{}:y,_=getSecurityData(null===(t=e.security)||void 0===t?void 0:t[0],d),S=_.securityHeaders,T=_.securityCookies,w=_.securityQueries,C=_.securityOAuth2ExtraCalls,P=_.basicAuth,b=null===(i=null===(r=e.requestBody)||void 0===r?void 0:r.content)||void 0===i?void 0:i.active,A={skipNonRequired:p,skipReadOnly:!0,maxSampleDepth:h},x=!1,E=e.parameters.filter((function(e){return"header"===e.in})).filter((function(e){return!(p&&!e.required)})).map((function(e){return{name:e.name,value:getParameterValue("header",e.name)||serializeParameterValue(e,Sampler.sample(e.schema.rawSchema,A,m))}})).map((function(e){return(null==b?void 0:b.name)&&"content-type"===e.name.toLowerCase()&&(x=!0,e.value=b.name),e})).concat(S);!x&&(null==b?void 0:b.name)&&E.unshift({name:"Content-Type",value:null==b?void 0:b.name});var k=e.parameters.filter((function(e){return"cookie"===e.in})).filter((function(e){return!(p&&!e.required)})).map((function(e){return parseQueryString(serializeParameterValue(e,Sampler.sample(e.schema.rawSchema,A,m)))})).reduce((function(e,a){for(var t=0,r=Object.entries(a);t<r.length;t++){var i=r[t],n=i[0],s=i[1];e.push({name:n,value:String(s)})}return e}),[]).concat(T),H=e.parameters.filter((function(e){return"query"===e.in})).filter((function(e){return!(p&&!e.required)})).map((function(e){return parseQueryString(serializeParameterValue(e,Sampler.sample(e.schema.rawSchema,A,m)))})).reduce((function(e,a){for(var t=0,r=Object.entries(a);t<r.length;t++){var i=r[t],n=i[0],s=i[1];e.push({name:n,value:String(s)})}return e}),[]).concat(w),R=(null===(n=e.activeServer)||void 0===n?void 0:n.url.replace(/\/$/,""))+"/"+e.path.replace(/^\//,""),z=e.parameters.filter((function(e){return"path"===e.in})).reduce((function(e,a){var t=a.in,r=a.name;return e[r]=g[r]||getParameterValue(t,r),e}),{}),D=null===(s=null==b?void 0:b.examples)||void 0===s?void 0:s[l],j=(null==b?void 0:b.examples)||{},N=Object.values(j)[0],q=(null==D?void 0:D.value)||(null==N?void 0:N.value)||(null==b?void 0:b.schema)&&Sampler.sample(null==b?void 0:b.schema.rawSchema,A,m),V=q&&"object"==typeof q&&merge(q,O,{arrayMerge:arrayMergeStrategy}),U=null==b?void 0:b.name.toLowerCase(),I="",Y=[];switch(normalizeMimeType(U)){case"application/json":I=JSON.stringify(V);break;case"application/x-www-form-urlencoded":case"multipart/form-data":I=stringifyQueryString(V),Y=objectToHarParams(V);break;default:I=String(q||"")}var M=I?{mimeType:(null==b?void 0:b.name)||"application/octet-stream",text:I,params:Y}:void 0;return{method:e.httpVerb,url:R,httpVersion:"HTTP/1.1",cookies:k,headers:E,queryString:H,postData:M,headersSize:-1,bodySize:-1,securityOAuth2ExtraCalls:C,basicAuth:P,pathParameters:z,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,s=e.options,o=void 0===s?{}:s;try{var l=mapOperationToHAR(t,{exampleName:r,pathParams:i,properties:n,skipOptionalParameters:o.skipOptionalParameters,withOAuth2Call:o.withOAuth2Call,spec:o.spec,generatedPayloadSamplesMaxDepth:o.generatedPayloadSamplesMaxDepth}),u=new HTTPSnippet(l);return langToSnippetConfig[a]?u.convert(langToSnippetConfig[a].code,langToSnippetConfig[a].defaultTarget,__assign(__assign({},langToSnippetConfig[a].defaultOptions),o)):"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,s={securityHeaders:[],securityCookies:[],securityQueries:[],securityOAuth2ExtraCalls:[],basicAuth:void 0},o=0,l=(null==e?void 0:e.schemes)||[];o<l.length;o++){var u=l[o],p=getSecurityDetails(u.id);switch(u.type){case"openIdConnect":null===(t=s.securityHeaders)||void 0===t||t.push({name:"Authorization",value:"Bearer <YOUR_TOKEN_HERE>"});break;case"oauth2":var c=p.token?(p.token.token_type||"Bearer")+" "+p.token.access_token:"Bearer <YOUR_TOKEN_HERE>";u.flows.clientCredentials&&a?s.securityOAuth2ExtraCalls.push(getOAuth2ClientCredsCallHar(u.flows.clientCredentials,u.scopes,p)):u.flows.password&&a&&s.securityOAuth2ExtraCalls.push(getOAuth2PasswordCallHar(u.flows.password,u.scopes,p)),null===(r=s.securityHeaders)||void 0===r||r.push({name:"Authorization",value:c});break;case"apiKey":var d=p.raw||"YOUR_API_KEY_HERE";"header"===u.in&&(null===(i=s.securityHeaders)||void 0===i||i.push({name:u.name,value:d})),"cookie"===u.in&&s.securityCookies.push({name:u.name,value:d}),"query"===u.in&&s.securityQueries.push({name:u.name,value:d});break;case"http":"basic"===u.scheme?s.basicAuth={username:p.username||"<username>",password:p.password||"<password>"}:null===(n=s.securityHeaders)||void 0===n||n.push({name:"Authorization",value:capitalizeFirst(u.scheme||"bearer")+" <YOUR_"+(u.bearerFormat||"TOKEN")+"_HERE>"})}}return s}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 objectToHarParams(e){for(var a=[],t=0,r=Object.entries(e);t<r.length;t++){var i=r[t],n=i[0],s=i[1];a.push({name:n,value:String(s)})}return a}export function isDefined(e){return void 0!==e}export function capitalizeFirst(e){return e.charAt(0).toUpperCase()+e.slice(1)}
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.21.0",
3
+ "version": "2.23.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": "^7.2.1",
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",
@@ -68,7 +68,7 @@
68
68
  "publish-cli-s3": "scripts/publish-cli-s3.sh",
69
69
  "deploy-local": "ENV=local npm run bundle-cli && ENV=local npm run publish-cli-s3",
70
70
  "publish-cdn": "scripts/publish-cdn.sh",
71
- "clear-cdn": "scripts/clear-cache.sh",
71
+ "clear-cache": "scripts/clear-cache.sh",
72
72
  "pack-sourcemaps": "rm -rf reference-docs.sourcemaps.tag.gz && find lib lib-esm -name \"*.js.map\" | xargs tar -czvf reference-docs.sourcemaps.tar.gz",
73
73
  "start": "webpack serve --mode=development --hot",
74
74
  "stats": "webpack --json --profile --mode=production -p > stats.json && npx webpack-bundle-analyzer stats.json",