@redocly/reference-docs 2.6.2-beta.circular.1 → 2.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli/commands/redocly-docs-cli.min.js +39 -41
- package/dist/console.redocly-reference-docs.min.js +7 -9
- package/dist/oauth2-redirect.js +2 -2
- package/dist/redocly-reference-docs.min.js +24 -24
- package/lib/components/Endpoint/Path.js +1 -1
- package/lib/components/Endpoint/ServerList.js +1 -1
- package/lib/components/Endpoint/ServerUrl.js +1 -1
- package/lib/components/console/Console.js +1 -1
- package/lib/components/shared/HttpVerb.js +1 -1
- package/lib/redoc-lib/src/common-elements/fields-layout.js +1 -1
- package/lib/redoc-lib/src/common-elements/fields.js +1 -1
- package/lib/redoc-lib/src/common-elements/samples.js +1 -1
- package/lib/redoc-lib/src/components/Fields/FieldDetails.js +1 -1
- package/lib/redoc-lib/src/index.d.ts +1 -1
- package/lib/redoc-lib/src/services/OpenAPIParser.js +1 -1
- package/lib/redoc-lib/src/services/RedocNormalizedOptions.d.ts +4 -2
- package/lib/redoc-lib/src/services/RedocNormalizedOptions.js +1 -1
- package/lib/redoc-lib/src/services/models/Schema.d.ts +1 -2
- package/lib/redoc-lib/src/services/models/Schema.js +1 -1
- package/lib/services/ProStore.d.ts +1 -1
- package/lib/services/ProStore.js +1 -1
- package/lib/services/code-samples/httpsnippet/targets/csharp/httpclient.js +1 -1
- package/lib/services/code-samples/httpsnippet/targets/go/native.js +1 -1
- package/lib/services/code-samples/httpsnippet/targets/java/httpclient.js +1 -1
- package/lib/services/code-samples/httpsnippet/targets/java8/apachehttp.js +1 -1
- package/lib/services/code-samples/httpsnippet/targets/javascript/fetch.js +1 -1
- package/lib/services/code-samples/httpsnippet/targets/node/fetch.js +1 -1
- package/lib/services/code-samples/httpsnippet/targets/php/curl.js +1 -1
- package/lib/services/code-samples/httpsnippet/targets/python/requests.js +1 -1
- package/lib/services/code-samples/httpsnippet/targets/ruby/native.js +1 -1
- package/lib/services/extendTheme.js +1 -1
- package/lib-esm/components/Endpoint/Path.js +1 -1
- package/lib-esm/components/Endpoint/ServerList.js +1 -1
- package/lib-esm/components/Endpoint/ServerUrl.js +1 -1
- package/lib-esm/components/console/Console.js +1 -1
- package/lib-esm/components/shared/HttpVerb.js +1 -1
- package/lib-esm/redoc-lib/src/common-elements/fields-layout.js +1 -1
- package/lib-esm/redoc-lib/src/common-elements/fields.js +1 -1
- package/lib-esm/redoc-lib/src/common-elements/samples.js +1 -1
- package/lib-esm/redoc-lib/src/components/Fields/FieldDetails.js +1 -1
- package/lib-esm/redoc-lib/src/index.d.ts +1 -1
- package/lib-esm/redoc-lib/src/services/OpenAPIParser.js +1 -1
- package/lib-esm/redoc-lib/src/services/RedocNormalizedOptions.d.ts +4 -2
- package/lib-esm/redoc-lib/src/services/RedocNormalizedOptions.js +1 -1
- package/lib-esm/redoc-lib/src/services/models/Schema.d.ts +1 -2
- package/lib-esm/redoc-lib/src/services/models/Schema.js +1 -1
- package/lib-esm/services/ProStore.d.ts +1 -1
- package/lib-esm/services/ProStore.js +1 -1
- package/lib-esm/services/code-samples/httpsnippet/targets/csharp/httpclient.js +1 -1
- package/lib-esm/services/code-samples/httpsnippet/targets/go/native.js +1 -1
- package/lib-esm/services/code-samples/httpsnippet/targets/java/httpclient.js +1 -1
- package/lib-esm/services/code-samples/httpsnippet/targets/java8/apachehttp.js +1 -1
- package/lib-esm/services/code-samples/httpsnippet/targets/javascript/fetch.js +1 -1
- package/lib-esm/services/code-samples/httpsnippet/targets/node/fetch.js +1 -1
- package/lib-esm/services/code-samples/httpsnippet/targets/php/curl.js +1 -1
- package/lib-esm/services/code-samples/httpsnippet/targets/python/requests.js +1 -1
- package/lib-esm/services/code-samples/httpsnippet/targets/ruby/native.js +1 -1
- package/lib-esm/services/extendTheme.js +1 -1
- package/package.json +1 -1
- package/CHANGELOG.md +0 -33
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var _a,_b,_c,_d,_e,_f,_g,_h,_j,_k;import{__makeTemplateObject}from"tslib";import styled,{css,extensionsHook,mediaCSS,ZERO_BREAKPOINT}from"../styled-components";import{deprecatedCss}from"./mixins";export var PropertiesTableCaption=styled.caption(templateObject_1||(templateObject_1=__makeTemplateObject(["\n text-align: right;\n font-size: 0.9em;\n font-weight: normal;\n color: ",";\n"],["\n text-align: right;\n font-size: 0.9em;\n font-weight: normal;\n color: ",";\n"])),(function(n){return n.theme.colors.text.secondary}));var templateObject_1,templateObject_2,templateObject_3,templateObject_4,templateObject_5,templateObject_6,templateObject_7,templateObject_8,templateObject_9,templateObject_10,repeatingGradient=css(templateObject_2||(templateObject_2=__makeTemplateObject(["\n repeating-linear-gradient(0deg,\n ",",\n "," 3px,\n transparent 3px,\n transparent 5px,\n "," 5px);\n"],["\n repeating-linear-gradient(0deg,\n ",",\n "," 3px,\n transparent 3px,\n transparent 5px,\n "," 5px);\n"])),(function(n){return n.theme.schema.linesColor}),(function(n){return n.theme.schema.linesColor}),(function(n){return n.theme.schema.linesColor}));export var PropertyCell=styled.td(templateObject_3||(templateObject_3=__makeTemplateObject(["\n box-sizing: border-box;\n position: relative;\n padding: 10px;\n background-image: ",";\n background-repeat: no-repeat;\n background-size: 1px 100%;\n\n ","\n\n tr:first-of-type > & {\n background-image: ",";\n background-position: 0 10px;\n padding-top:
|
|
1
|
+
var _a,_b,_c,_d,_e,_f,_g,_h,_j,_k;import{__makeTemplateObject}from"tslib";import styled,{css,extensionsHook,mediaCSS,ZERO_BREAKPOINT}from"../styled-components";import{deprecatedCss}from"./mixins";export var PropertiesTableCaption=styled.caption(templateObject_1||(templateObject_1=__makeTemplateObject(["\n text-align: right;\n font-size: 0.9em;\n font-weight: normal;\n color: ",";\n"],["\n text-align: right;\n font-size: 0.9em;\n font-weight: normal;\n color: ",";\n"])),(function(n){return n.theme.colors.text.secondary}));var templateObject_1,templateObject_2,templateObject_3,templateObject_4,templateObject_5,templateObject_6,templateObject_7,templateObject_8,templateObject_9,templateObject_10,repeatingGradient=css(templateObject_2||(templateObject_2=__makeTemplateObject(["\n repeating-linear-gradient(0deg,\n ",",\n "," 3px,\n transparent 3px,\n transparent 5px,\n "," 5px);\n"],["\n repeating-linear-gradient(0deg,\n ",",\n "," 3px,\n transparent 3px,\n transparent 5px,\n "," 5px);\n"])),(function(n){return n.theme.schema.linesColor}),(function(n){return n.theme.schema.linesColor}),(function(n){return n.theme.schema.linesColor}));export var PropertyCell=styled.td(templateObject_3||(templateObject_3=__makeTemplateObject(["\n box-sizing: border-box;\n position: relative;\n padding: 10px;\n background-image: ",";\n background-repeat: no-repeat;\n background-size: 1px 100%;\n\n ","\n\n tr:first-of-type > & {\n background-image: ",";\n background-position: 0 10px;\n padding-top: 0;\n }\n\n tr.last > & {\n background-image: ",";\n padding-bottom: 0;\n ",";\n }\n\n tr.last + tr > & {\n background: none;\n }\n\n tr.last:first-child > & {\n background-image: ",";\n ",";\n }\n"],["\n box-sizing: border-box;\n position: relative;\n padding: 10px;\n background-image: ",";\n background-repeat: no-repeat;\n background-size: 1px 100%;\n\n ","\n\n tr:first-of-type > & {\n background-image: ",";\n background-position: 0 10px;\n padding-top: 0;\n }\n\n tr.last > & {\n background-image: ",";\n padding-bottom: 0;\n ",";\n }\n\n tr.last + tr > & {\n background: none;\n }\n\n tr.last:first-child > & {\n background-image: ",";\n ",";\n }\n"])),repeatingGradient,mediaCSS({display:(_a={},_a[ZERO_BREAKPOINT]="block",_a.small="table-cell",_a),overflow:(_b={},_b[ZERO_BREAKPOINT]="hidden",_b.small="initial",_b),padding:(_c={},_c[ZERO_BREAKPOINT]="0 20px",_c.small="10px",_c),marginBottom:(_d={},_d[ZERO_BREAKPOINT]="2px",_d.small=0,_d)}),repeatingGradient,repeatingGradient,mediaCSS({backgroundSize:(_e={},_e[ZERO_BREAKPOINT]="0.9px 100%",_e.small="0.9px 22px",_e)}),repeatingGradient,mediaCSS({backgroundSize:(_f={},_f[ZERO_BREAKPOINT]="0.9px 100%",_f.small="0.9px 20px",_f),backgroundPosition:(_g={},_g[ZERO_BREAKPOINT]="0 20px",_g.small="0 0",_g)}));export var PropertyCellWithInner=styled(PropertyCell)(templateObject_4||(templateObject_4=__makeTemplateObject(["\n padding: 0;\n"],["\n padding: 0;\n"])));export var PropertyNameCell=styled(PropertyCell)(templateObject_5||(templateObject_5=__makeTemplateObject(["\n vertical-align: top;\n line-height: 23px;\n white-space: nowrap;\n font-size: 14px;\n ","\n\n &.deprecated {\n ",";\n }\n\n ",";\n\n ",";\n"],["\n vertical-align: top;\n line-height: 23px;\n white-space: nowrap;\n font-size: 14px;\n ","\n\n &.deprecated {\n ",";\n }\n\n ",";\n\n ",";\n"])),(function(n){var e=n.theme;return mediaCSS({fontFamily:e.typography.fieldName.fontFamily})}),deprecatedCss,(function(n){return"field"!==n.kind?"font-style: italic":""}),extensionsHook("PropertyNameCell"));export var PropertyDetailsCell=styled.td(templateObject_6||(templateObject_6=__makeTemplateObject(["\n box-sizing: border-box;\n vertical-align: top;\n\n tr.expanded & {\n border-bottom: none;\n }\n\n tr.last > & {\n border: none;\n background-position: top left;\n background-repeat: no-repeat;\n background-size: 1px 100%;\n padding-bottom: 0;\n\n /* workaround for discriminator dropdown oveflowing scrolling container,\n fixes the issue for the last item in the schema only */\n & > div > div.dropdown > .dropdown-selector-content {\n position: relative;\n }\n }\n\n tr:first-of-type > & {\n padding-top: 0;\n }\n\n ","\n\n ",";\n"],["\n box-sizing: border-box;\n vertical-align: top;\n\n tr.expanded & {\n border-bottom: none;\n }\n\n tr.last > & {\n border: none;\n background-position: top left;\n background-repeat: no-repeat;\n background-size: 1px 100%;\n padding-bottom: 0;\n\n /* workaround for discriminator dropdown oveflowing scrolling container,\n fixes the issue for the last item in the schema only */\n & > div > div.dropdown > .dropdown-selector-content {\n position: relative;\n }\n }\n\n tr:first-of-type > & {\n padding-top: 0;\n }\n\n ","\n\n ",";\n"])),(function(n){var e,t,r,a=n.theme;return mediaCSS({borderBottom:(e={},e[ZERO_BREAKPOINT]="none",e.small="1px solid "+a.colors.border.light,e),borderLeft:(t={},t[ZERO_BREAKPOINT]="1px solid "+a.schema.linesColor,t.small="none",t),padding:(r={},r[ZERO_BREAKPOINT]="0 20px",r.small="10px 0",r),width:a.schema.defaultDetailsWidth,minWidth:"200px"})}),extensionsHook("PropertyDetailsCell"));export var PropertyBullet=styled.span(templateObject_7||(templateObject_7=__makeTemplateObject(["\n margin-right: 10px;\n ","\n\n &::before {\n content: '';\n display: inline-block;\n vertical-align: middle;\n width: 10px;\n height: 1px;\n background: ",";\n }\n\n ","\n\n ",";\n"],["\n margin-right: 10px;\n ","\n\n &::before {\n content: '';\n display: inline-block;\n vertical-align: middle;\n width: 10px;\n height: 1px;\n background: ",";\n }\n\n ","\n\n ",";\n"])),(function(n){var e=n.theme;return mediaCSS({color:e.schema.linesColor,fontFamily:e.typography.code.fontFamily})}),(function(n){return n.theme.schema.linesColor}),(function(n){var e,t,r=n.theme;return mediaCSS({width:r.schema.defaultDetailsWidth,borderLeft:(e={},e[ZERO_BREAKPOINT]="1px dashed "+r.schema.linesColor,e.small="none",e),padding:(t={},t[ZERO_BREAKPOINT]="5px 10px",t.small="10px",t)})}),extensionsHook("PropertyDetailsCell"));export var InnerPropertiesWrap=styled.div(templateObject_8||(templateObject_8=__makeTemplateObject(["\n padding: ",";\n"],["\n padding: ",";\n"])),(function(n){return n.theme.schema.nestingSpacing}));export var PropertiesTableWrap=styled.div(templateObject_9||(templateObject_9=__makeTemplateObject(["\n display: block;\n overflow-x: auto;\n padding: 5px; /* hack to show overflown anchor icons */\n margin: -5px;\n"],["\n display: block;\n overflow-x: auto;\n padding: 5px; /* hack to show overflown anchor icons */\n margin: -5px;\n"])));export var PropertiesTable=styled.table(templateObject_10||(templateObject_10=__makeTemplateObject(["\n border-collapse: separate;\n border-radius: ",";\n width: 100%;\n ","\n > tr, > tbody > tr {\n ","\n }\n\n > tr {\n vertical-align: middle;\n }\n\n ","\n\n &\n ",",\n &\n ","\n ","\n ",",\n &\n ","\n ","\n ","\n ","\n "," {\n margin-left: ",";\n margin-bottom: ",";\n background: ",";\n border-radius: ",";\n }\n\n &\n ","\n ",",\n &\n ","\n ","\n ","\n ",",\n &\n ","\n ","\n ","\n ","\n ","\n "," {\n background: #ffffff;\n }\n"],["\n border-collapse: separate;\n border-radius: ",";\n width: 100%;\n ","\n > tr, > tbody > tr {\n ","\n }\n\n > tr {\n vertical-align: middle;\n }\n\n ","\n\n &\n ",",\n &\n ","\n ","\n ",",\n &\n ","\n ","\n ","\n ","\n "," {\n margin-left: ",";\n margin-bottom: ",";\n background: ",";\n border-radius: ",";\n }\n\n &\n ","\n ",",\n &\n ","\n ","\n ","\n ",",\n &\n ","\n ","\n ","\n ","\n ","\n "," {\n background: #ffffff;\n }\n"])),(function(n){return n.theme.shape.borderRadius}),(function(n){var e,t=n.theme;return mediaCSS({fontSize:t.typography.fontSize,display:(e={},e[ZERO_BREAKPOINT]="block",e.small="table",e)})}),mediaCSS({display:(_h={},_h[ZERO_BREAKPOINT]="block",_h.small="table-row",_h),marginBottom:(_j={},_j[ZERO_BREAKPOINT]="2px",_j.small=0,_j),borderSpacing:(_k={},_k[ZERO_BREAKPOINT]=0,_k.small="0 2px",_k)}),(function(n){return"\n @media screen and (max-width: "+n.theme.breakpoints[0]+") and (-ms-high-contrast:none) {\n td {\n float: left;\n width: 100%;\n }\n }\n "}),InnerPropertiesWrap,InnerPropertiesWrap,InnerPropertiesWrap,InnerPropertiesWrap,InnerPropertiesWrap,InnerPropertiesWrap,InnerPropertiesWrap,InnerPropertiesWrap,InnerPropertiesWrap,(function(n){return n.theme.schema.nestingSpacing}),(function(n){return n.theme.schema.nestingSpacing}),(function(n){return n.theme.schema.nestedBackground}),(function(n){return n.theme.components.panels.borderRadius}),InnerPropertiesWrap,InnerPropertiesWrap,InnerPropertiesWrap,InnerPropertiesWrap,InnerPropertiesWrap,InnerPropertiesWrap,InnerPropertiesWrap,InnerPropertiesWrap,InnerPropertiesWrap,InnerPropertiesWrap,InnerPropertiesWrap,InnerPropertiesWrap);
|
|
2
2
|
//# sourceMappingURL=fields-layout.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__makeTemplateObject}from"tslib";import styled,{extensionsHook,mediaCSS}from"../styled-components";import{PropertyNameCell}from"./fields-layout";import{ShelfIcon}from"./icons";export var ClickablePropertyNameCell=styled(PropertyNameCell)(templateObject_1||(templateObject_1=__makeTemplateObject(["\n button {\n background-color: transparent;\n border: 0;\n outline: 0;\n cursor: pointer;\n padding: 0;\n ","\n &:focus {\n font-weight: ",";\n }\n }\n "," {\n margin-left: 4px;\n height: ",";\n width: ",";\n fill: ",";\n margin-top: -1px;\n }\n"],["\n button {\n background-color: transparent;\n border: 0;\n outline: 0;\n cursor: pointer;\n padding: 0;\n ","\n &:focus {\n font-weight: ",";\n }\n }\n "," {\n margin-left: 4px;\n height: ",";\n width: ",";\n fill: ",";\n margin-top: -1px;\n }\n"])),(function(e){var t=e.theme;return mediaCSS({fontFamily:t.typography.fieldName.fontFamily,fontSize:t.typography.fieldName.fontSize,color:t.colors.text.primary})}),(function(e){return e.theme.typography.fontWeightBold}),ShelfIcon,(function(e){return e.theme.schema.caretSize}),(function(e){return e.theme.schema.caretSize}),(function(e){return e.theme.schema.caretColor}));export var FieldLabel=styled.span(templateObject_2||(templateObject_2=__makeTemplateObject(["\n vertical-align: middle;\n line-height: 20px;\n ",";\n"],["\n vertical-align: middle;\n line-height: 20px;\n ",";\n"])),(function(e){var t=e.theme;return mediaCSS({fontSize:t.typography.fieldName.fontSize})}));export var TypePrefix=styled(FieldLabel)(templateObject_3||(templateObject_3=__makeTemplateObject(["\n color: ",";\n"],["\n color: ",";\n"])),(function(e){return e.theme.schema.typeNameColor}));export var TypeName=styled(FieldLabel)(templateObject_4||(templateObject_4=__makeTemplateObject(["\n color: ",";\n"],["\n color: ",";\n"])),(function(e){return e.theme.schema.typeNameColor}));export var TypeTitle=styled(FieldLabel)(templateObject_5||(templateObject_5=__makeTemplateObject(["\n color: ",";\n word-break: break-word;\n"],["\n color: ",";\n word-break: break-word;\n"])),(function(e){return e.theme.schema.typeTitleColor}));export var TypeFormat=TypeName;export var RequiredLabel=styled(FieldLabel.withComponent("div"))(templateObject_6||(templateObject_6=__makeTemplateObject(["\n color: ",";\n font-size: ",";\n font-weight: normal;\n line-height: 1;\n display: block;\n"],["\n color: ",";\n font-size: ",";\n font-weight: normal;\n line-height: 1;\n display: block;\n"])),(function(e){return e.theme.schema.requireLabelColor}),(function(e){return e.theme.schema.labelsTextSize}));export var RecursiveLabel=styled(FieldLabel)(templateObject_7||(templateObject_7=__makeTemplateObject(["\n color: ",";\n font-size: 13px;\n"],["\n color: ",";\n font-size: 13px;\n"])),(function(e){return e.theme.colors.warning.main}));export var ExampleValue=styled(FieldLabel)(templateObject_8||(templateObject_8=__makeTemplateObject(["\n border-radius: ",";\n ","\n\n ","\n\n & + & {\n margin-left: 0;\n }\n ",";\n line-height: 1.2em;\n display: inline-flex;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n"],["\n border-radius: ",";\n ","\n\n ","\n\n & + & {\n margin-left: 0;\n }\n ",";\n line-height: 1.2em;\n display: inline-flex;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n"])),(function(e){return e.theme.shape.borderRadius}),(function(e){var t=e.theme;return"\n background-color: "+t.colors.secondary.light+";\n color: "+t.colors.text.primary+";\n padding: 1px "+t.spacing.unit+"px;\n border: 1px solid "+t.colors.border.light+";\n font-size: 12px;\n "}),(function(e){var t=e.theme;return mediaCSS({fontFamily:t.typography.fieldName.fontFamily})}),extensionsHook("ExampleValue"));export var ExtensionValue=styled(ExampleValue)(templateObject_9||(templateObject_9=__makeTemplateObject([""],[""])));export var ConstraintItem=styled(FieldLabel)(templateObject_10||(templateObject_10=__makeTemplateObject(["\n border-radius: ",";\n ","\n\n ","\n\n & + & {\n margin-left: 0;\n }\n ",";\n"],["\n border-radius: ",";\n ","\n\n ","\n\n & + & {\n margin-left: 0;\n }\n ",";\n"])),(function(e){return e.theme.shape.borderRadius}),(function(e){var t=e.theme;return"\n background-color: "+t.colors.secondary.light+";\n color: "+t.colors.accent.dark+";\n margin: 0 "+t.spacing.unit+"px;\n padding: 1px "+t.spacing.unit+"px;\n border: 1px solid "+t.colors.border.light+";\n font-size: 12px;\n "}),(function(e){var t=e.theme;return mediaCSS({fontFamily:t.typography.fieldName.fontFamily})}),extensionsHook("ConstraintItem"));export var PatternLabel=styled(ConstraintItem)(templateObject_11||(templateObject_11=__makeTemplateObject([""],[""])));export var ToggleButton=styled.button(templateObject_12||(templateObject_12=__makeTemplateObject(["\n background-color: transparent;\n border: 0;\n color: ",";\n margin-left: ","px;\n border-radius: ",";\n cursor: pointer;\n outline-color: ",";\n font-size: 12px;\n"],["\n background-color: transparent;\n border: 0;\n color: ",";\n margin-left: ","px;\n border-radius: ",";\n cursor: pointer;\n outline-color: ",";\n font-size: 12px;\n"])),(function(e){return e.theme.colors.text.secondary}),(function(e){return e.theme.spacing.unit}),(function(e){return e.theme.shape.borderRadius}),(function(e){return e.theme.colors.text.secondary}));var templateObject_1,templateObject_2,templateObject_3,templateObject_4,templateObject_5,templateObject_6,templateObject_7,templateObject_8,templateObject_9,templateObject_10,templateObject_11,templateObject_12;
|
|
1
|
+
import{__makeTemplateObject}from"tslib";import styled,{extensionsHook,mediaCSS}from"../styled-components";import{PropertyNameCell}from"./fields-layout";import{ShelfIcon}from"./icons";export var ClickablePropertyNameCell=styled(PropertyNameCell)(templateObject_1||(templateObject_1=__makeTemplateObject(["\n button {\n background-color: transparent;\n border: 0;\n outline: 0;\n cursor: pointer;\n padding: 0;\n ","\n &:focus {\n font-weight: ",";\n }\n }\n "," {\n margin-left: 4px;\n height: ",";\n width: ",";\n fill: ",";\n margin-top: -1px;\n }\n\n ",";\n"],["\n button {\n background-color: transparent;\n border: 0;\n outline: 0;\n cursor: pointer;\n padding: 0;\n ","\n &:focus {\n font-weight: ",";\n }\n }\n "," {\n margin-left: 4px;\n height: ",";\n width: ",";\n fill: ",";\n margin-top: -1px;\n }\n\n ",";\n"])),(function(e){var t=e.theme;return mediaCSS({fontFamily:t.typography.fieldName.fontFamily,fontSize:t.typography.fieldName.fontSize,color:t.colors.text.primary})}),(function(e){return e.theme.typography.fontWeightBold}),ShelfIcon,(function(e){return e.theme.schema.caretSize}),(function(e){return e.theme.schema.caretSize}),(function(e){return e.theme.schema.caretColor}),extensionsHook("ClickablePropertyNameCell"));export var FieldLabel=styled.span(templateObject_2||(templateObject_2=__makeTemplateObject(["\n vertical-align: middle;\n line-height: 20px;\n ",";\n"],["\n vertical-align: middle;\n line-height: 20px;\n ",";\n"])),(function(e){var t=e.theme;return mediaCSS({fontSize:t.typography.fieldName.fontSize})}));export var TypePrefix=styled(FieldLabel)(templateObject_3||(templateObject_3=__makeTemplateObject(["\n color: ",";\n"],["\n color: ",";\n"])),(function(e){return e.theme.schema.typeNameColor}));export var TypeName=styled(FieldLabel)(templateObject_4||(templateObject_4=__makeTemplateObject(["\n color: ",";\n"],["\n color: ",";\n"])),(function(e){return e.theme.schema.typeNameColor}));export var TypeTitle=styled(FieldLabel)(templateObject_5||(templateObject_5=__makeTemplateObject(["\n color: ",";\n word-break: break-word;\n"],["\n color: ",";\n word-break: break-word;\n"])),(function(e){return e.theme.schema.typeTitleColor}));export var TypeFormat=TypeName;export var RequiredLabel=styled(FieldLabel.withComponent("div"))(templateObject_6||(templateObject_6=__makeTemplateObject(["\n color: ",";\n font-size: ",";\n font-weight: normal;\n line-height: 1;\n display: block;\n"],["\n color: ",";\n font-size: ",";\n font-weight: normal;\n line-height: 1;\n display: block;\n"])),(function(e){return e.theme.schema.requireLabelColor}),(function(e){return e.theme.schema.labelsTextSize}));export var RecursiveLabel=styled(FieldLabel)(templateObject_7||(templateObject_7=__makeTemplateObject(["\n color: ",";\n font-size: 13px;\n"],["\n color: ",";\n font-size: 13px;\n"])),(function(e){return e.theme.colors.warning.main}));export var ExampleValue=styled(FieldLabel)(templateObject_8||(templateObject_8=__makeTemplateObject(["\n border-radius: ",";\n ","\n\n ","\n\n & + & {\n margin-left: 0;\n }\n ",";\n line-height: 1.2em;\n display: inline-flex;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n"],["\n border-radius: ",";\n ","\n\n ","\n\n & + & {\n margin-left: 0;\n }\n ",";\n line-height: 1.2em;\n display: inline-flex;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n"])),(function(e){return e.theme.shape.borderRadius}),(function(e){var t=e.theme;return"\n background-color: "+t.colors.secondary.light+";\n color: "+t.colors.text.primary+";\n padding: 1px "+t.spacing.unit+"px;\n border: 1px solid "+t.colors.border.light+";\n font-size: 12px;\n "}),(function(e){var t=e.theme;return mediaCSS({fontFamily:t.typography.fieldName.fontFamily})}),extensionsHook("ExampleValue"));export var ExtensionValue=styled(ExampleValue)(templateObject_9||(templateObject_9=__makeTemplateObject([""],[""])));export var ConstraintItem=styled(FieldLabel)(templateObject_10||(templateObject_10=__makeTemplateObject(["\n border-radius: ",";\n ","\n\n ","\n\n & + & {\n margin-left: 0;\n }\n ",";\n"],["\n border-radius: ",";\n ","\n\n ","\n\n & + & {\n margin-left: 0;\n }\n ",";\n"])),(function(e){return e.theme.shape.borderRadius}),(function(e){var t=e.theme;return"\n background-color: "+t.colors.secondary.light+";\n color: "+t.colors.accent.dark+";\n margin: 0 "+t.spacing.unit+"px;\n padding: 1px "+t.spacing.unit+"px;\n border: 1px solid "+t.colors.border.light+";\n font-size: 12px;\n "}),(function(e){var t=e.theme;return mediaCSS({fontFamily:t.typography.fieldName.fontFamily})}),extensionsHook("ConstraintItem"));export var PatternLabel=styled(ConstraintItem)(templateObject_11||(templateObject_11=__makeTemplateObject([""],[""])));export var ToggleButton=styled.button(templateObject_12||(templateObject_12=__makeTemplateObject(["\n background-color: transparent;\n border: 0;\n color: ",";\n margin-left: ","px;\n border-radius: ",";\n cursor: pointer;\n outline-color: ",";\n font-size: 12px;\n"],["\n background-color: transparent;\n border: 0;\n color: ",";\n margin-left: ","px;\n border-radius: ",";\n cursor: pointer;\n outline-color: ",";\n font-size: 12px;\n"])),(function(e){return e.theme.colors.text.secondary}),(function(e){return e.theme.spacing.unit}),(function(e){return e.theme.shape.borderRadius}),(function(e){return e.theme.colors.text.secondary}));var templateObject_1,templateObject_2,templateObject_3,templateObject_4,templateObject_5,templateObject_6,templateObject_7,templateObject_8,templateObject_9,templateObject_10,templateObject_11,templateObject_12;
|
|
2
2
|
//# sourceMappingURL=fields.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__makeTemplateObject}from"tslib";import{lighten}from"polished";import styled,{mediaCSS}from"../styled-components";import{PrismDiv}from"./PrismDiv";export var SamplesControlButton=styled.button(templateObject_1||(templateObject_1=__makeTemplateObject(["\n
|
|
1
|
+
import{__makeTemplateObject}from"tslib";import{lighten}from"polished";import styled,{mediaCSS}from"../styled-components";import{PrismDiv}from"./PrismDiv";export var SamplesControlButton=styled.button(templateObject_1||(templateObject_1=__makeTemplateObject(["\n background-color: ",";\n border: 0;\n outline: 0;\n border-radius: ",";\n height: 20px;\n color: ",";\n padding: 2px 20px;\n font-size: 12px;\n line-height: 12px;\n cursor: pointer;\n min-width: 90px;\n\n :hover,\n :focus {\n background: ",";\n }\n"],["\n background-color: ",";\n border: 0;\n outline: 0;\n border-radius: ",";\n height: 20px;\n color: ",";\n padding: 2px 20px;\n font-size: 12px;\n line-height: 12px;\n cursor: pointer;\n min-width: 90px;\n\n :hover,\n :focus {\n background: ",";\n }\n"])),(function(n){return n.theme.rightPanel.panelControlsBackgroundColor}),(function(n){return n.theme.shape.borderRadius}),(function(n){return n.theme.colors.text.light}),(function(n){var t=n.theme;return lighten(.05,t.rightPanel.panelControlsBackgroundColor)}));export var SampleControls=styled.div(templateObject_2||(templateObject_2=__makeTemplateObject(["\n padding: 10px 0;\n opacity: 0.7;\n transition: opacity 0.3s ease;\n text-align: right;\n\n &:focus-within {\n opacity: 1;\n }\n\n > div,\n > "," {\n /* can have tooltip wrapper div also */\n margin-right: 10px;\n &:last-child {\n margin-right: 0;\n }\n }\n"],["\n padding: 10px 0;\n opacity: 0.7;\n transition: opacity 0.3s ease;\n text-align: right;\n\n &:focus-within {\n opacity: 1;\n }\n\n > div,\n > "," {\n /* can have tooltip wrapper div also */\n margin-right: 10px;\n &:last-child {\n margin-right: 0;\n }\n }\n"])),SamplesControlButton);export var SampleControlsWrap=styled.div(templateObject_3||(templateObject_3=__makeTemplateObject(["\n &:hover "," {\n opacity: 1;\n }\n"],["\n &:hover "," {\n opacity: 1;\n }\n"])),SampleControls);export var StyledPre=styled(PrismDiv.withComponent("pre"))(templateObject_4||(templateObject_4=__makeTemplateObject(["\n overflow-x: auto;\n margin: 0;\n font-family: ",";\n padding: 20px;\n ",";\n"],["\n overflow-x: auto;\n margin: 0;\n font-family: ",";\n padding: 20px;\n ",";\n"])),(function(n){return n.theme.typography.code.fontFamily}),(function(n){var t=n.theme;return mediaCSS({borderRadius:t.shape.borderRadius,backgroundColor:t.rightPanel.panelControlsBackgroundColor,color:t.colors.text.light,fontSize:t.typography.code.fontSize,whiteSpace:t.typography.code.wrap?"pre-wrap":"pre"})}));var templateObject_1,templateObject_2,templateObject_3,templateObject_4;
|
|
2
2
|
//# sourceMappingURL=samples.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign,__extends,__makeTemplateObject}from"tslib";import*as React from"react";import{PatternLabel,RecursiveLabel,TypeFormat,TypeName,TypePrefix,TypeTitle,ToggleButton,FieldLabel,ExampleValue}from"../../common-elements/fields";import{serializeParameterValue}from"../../utils";import{ExternalDocumentation}from"../ExternalDocumentation/ExternalDocumentation";import{Markdown}from"../Markdown/Markdown";import{EnumValues}from"./EnumValues";import{Extensions}from"./Extensions";import{ConstraintsView}from"./FieldContstraints";import{FieldDetail}from"./FieldDetail";import{Badge}from"../../common-elements/";import{l}from"../../services/Labels";import{OptionsContext}from"../OptionsProvider";import styled,{mediaCSS}from"../../styled-components";var MAX_PATTERN_LENGTH=45,FieldDetails=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return Object.defineProperty(t,"state",{enumerable:!0,configurable:!0,writable:!0,value:{patternShown:!1}}),Object.defineProperty(t,"togglePattern",{enumerable:!0,configurable:!0,writable:!0,value:function(){t.setState({patternShown:!t.state.patternShown})}}),t}return __extends(t,e),Object.defineProperty(t.prototype,"render",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this.props,t=e.showExamples,a=e.field,n=e.renderDiscriminatorSwitch,r=this.state.patternShown,i=this.context,m=i.enumSkipQuotes,o=i.hideSchemaTitles,c=i.hideSchemaPattern,p=a.schema,s=a.description,u=a.example,d=a.deprecated,E=a.examples,b=!!m||"header"===a.in,f=null;if(t&&(void 0!==u||void 0!==E))if(void 0!==E)f=React.createElement(Examples,{field:a});else{var
|
|
1
|
+
import{__assign,__extends,__makeTemplateObject}from"tslib";import*as React from"react";import{PatternLabel,RecursiveLabel,TypeFormat,TypeName,TypePrefix,TypeTitle,ToggleButton,FieldLabel,ExampleValue}from"../../common-elements/fields";import{serializeParameterValue}from"../../utils";import{ExternalDocumentation}from"../ExternalDocumentation/ExternalDocumentation";import{Markdown}from"../Markdown/Markdown";import{EnumValues}from"./EnumValues";import{Extensions}from"./Extensions";import{ConstraintsView}from"./FieldContstraints";import{FieldDetail}from"./FieldDetail";import{Badge}from"../../common-elements/";import{l}from"../../services/Labels";import{OptionsContext}from"../OptionsProvider";import styled,{mediaCSS}from"../../styled-components";var MAX_PATTERN_LENGTH=45,FieldDetails=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return Object.defineProperty(t,"state",{enumerable:!0,configurable:!0,writable:!0,value:{patternShown:!1}}),Object.defineProperty(t,"togglePattern",{enumerable:!0,configurable:!0,writable:!0,value:function(){t.setState({patternShown:!t.state.patternShown})}}),t}return __extends(t,e),Object.defineProperty(t.prototype,"render",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this.props,t=e.showExamples,a=e.field,n=e.renderDiscriminatorSwitch,r=this.state.patternShown,i=this.context,m=i.enumSkipQuotes,o=i.hideSchemaTitles,c=i.hideSchemaPattern,p=a.schema,s=a.description,u=a.example,d=a.deprecated,E=a.examples,b=!!m||"header"===a.in,f=null;if(t&&(void 0!==u||void 0!==E))if(void 0!==E)f=React.createElement(Examples,{field:a});else{var y=l("example")+":",x=!!a.in;f=React.createElement(FieldDetail,{label:y,value:getSerializedValue(a,a.example),raw:x})}return React.createElement("div",null,React.createElement(TypeWrapper,null,React.createElement(TypePrefix,null,p.typePrefix),React.createElement(TypeName,null,p.displayType),p.displayFormat&&React.createElement(TypeFormat,null," ","<",p.displayFormat,">"," "),p.contentEncoding&&React.createElement(TypeFormat,null," ","<",p.contentEncoding,">"," "),p.contentMediaType&&React.createElement(TypeFormat,null," ","<",p.contentMediaType,">"," "),p.title&&!o&&React.createElement(TypeTitle,null," (",p.title,") "),React.createElement(ConstraintsView,{constraints:p.constraints}),p.pattern&&!c&&React.createElement(React.Fragment,null,React.createElement(PatternLabel,null,r||p.pattern.length<MAX_PATTERN_LENGTH?p.pattern:p.pattern.substr(0,MAX_PATTERN_LENGTH)+"..."),p.pattern.length>MAX_PATTERN_LENGTH&&React.createElement(ToggleButton,{onClick:this.togglePattern},r?"Hide pattern":"Show pattern")),p.isCircular&&React.createElement(RecursiveLabel,null," ",l("recursive")," ")),d&&React.createElement("div",null,React.createElement(Badge,{type:"warning",style:{marginLeft:0}}," ",l("deprecated")," ")),React.createElement(FieldDetail,{raw:b,label:l("default")+":",value:p.default}),React.createElement("div",null,React.createElement(Markdown,{compact:!0,source:s})),!n&&React.createElement(EnumValues,{type:p.type,values:p["x-enumDescriptions"]||p.enum})," ",f,React.createElement(Extensions,{extensions:__assign(__assign({},a.extensions),p.extensions)}),p.externalDocs&&React.createElement(ExternalDocumentation,{externalDocs:p.externalDocs,compact:!0}),n&&n(this.props)||null,a.const&&React.createElement(FieldDetail,{label:l("const")+":",value:a.const})||null)}}),Object.defineProperty(t,"contextType",{enumerable:!0,configurable:!0,writable:!0,value:OptionsContext}),t}(React.PureComponent);export{FieldDetails};function Examples(e){var t=e.field;return t.examples?React.createElement(React.Fragment,null,React.createElement(FieldLabel,null," ",l("examples"),": "),React.createElement(ExamplesList,null,Object.entries(t.examples).map((function(e){var a=e[0],n=e[1];return React.createElement(ExampleWrap,{key:a},React.createElement(ExampleSummary,null,n.summary||a," "),n.description&&React.createElement(ExampleDescription,null,n.description," "),React.createElement(ExampleValue,null,getSerializedValue(t,n.value)))})))):null}function getSerializedValue(e,t){return e.in?decodeURIComponent(serializeParameterValue(e,t)):t}var templateObject_1,templateObject_2,templateObject_3,templateObject_4,templateObject_5,ExampleDescription=styled.div(templateObject_1||(templateObject_1=__makeTemplateObject([""],[""]))),ExampleSummary=styled.label(templateObject_2||(templateObject_2=__makeTemplateObject(["\n display: block;\n font-size: inherit;\n margin-bottom: 0.2em;\n font-weight: ",";\n"],["\n display: block;\n font-size: inherit;\n margin-bottom: 0.2em;\n font-weight: ",";\n"])),(function(e){return e.theme.typography.fontWeightBold})),ExampleWrap=styled.div(templateObject_3||(templateObject_3=__makeTemplateObject(["\n margin-top: 1em;\n ","\n"],["\n margin-top: 1em;\n ","\n"])),(function(e){var t=e.theme;return mediaCSS({fontSize:t.typography.fieldName.fontSize})})),ExamplesList=styled.div(templateObject_4||(templateObject_4=__makeTemplateObject(["\n padding-left: 1.5em;\n margin-bottom: 1em;\n"],["\n padding-left: 1.5em;\n margin-bottom: 1em;\n"]))),TypeWrapper=styled.div(templateObject_5||(templateObject_5=__makeTemplateObject(["\n line-height: 20px;\n"],["\n line-height: 20px;\n"])));
|
|
2
2
|
//# sourceMappingURL=FieldDetails.js.map
|
|
@@ -5,4 +5,4 @@ export * from './utils';
|
|
|
5
5
|
export * from './styled-components';
|
|
6
6
|
export { default as styled } from './styled-components';
|
|
7
7
|
export * from './types';
|
|
8
|
-
export type { AuthPanelHookProps } from './services/RedocNormalizedOptions';
|
|
8
|
+
export type { SecurityPanelHookProps, SecurityPanelHookProps as AuthPanelHookProps, } from './services/RedocNormalizedOptions';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign,__rest,__spreadArray}from"tslib";import{resolve as urlResolve}from"url";import{appendToMdHeading,IS_BROWSER}from"../utils/";import{JsonPointer}from"../utils/JsonPointer";import{getDefinitionName,isNamedDefinition,SECURITY_DEFINITIONS_COMPONENT_NAME,SECURITY_DEFINITIONS_JSX_NAME}from"../utils";import{buildComponentComment,MarkdownRenderer}from"./MarkdownRenderer";import{RedocNormalizedOptions}from"./RedocNormalizedOptions";var RefCounter=function(){function e(){Object.defineProperty(this,"_counter",{enumerable:!0,configurable:!0,writable:!0,value:{}})}return Object.defineProperty(e.prototype,"reset",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._counter={}}}),Object.defineProperty(e.prototype,"visit",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._counter[e]=this._counter[e]?this._counter[e]+1:1}}),Object.defineProperty(e.prototype,"exit",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._counter[e]=this._counter[e]&&this._counter[e]-1}}),Object.defineProperty(e.prototype,"visited",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return!!this._counter[e]}}),e}(),OpenAPIParser=function(){function e(e,r,t){var i=this;void 0===t&&(t=new RedocNormalizedOptions({})),Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"definitionUrl",{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,"hasSecurityDefinitions",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_refCounter",{enumerable:!0,configurable:!0,writable:!0,value:new RefCounter}),Object.defineProperty(this,"allowMergeRefs",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"byRef",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var r;if(i.definition){"#"!==e.charAt(0)&&(e="#"+e),e=decodeURIComponent(e);try{r=JsonPointer.get(i.definition,e)}catch(e){}return r||{}}}}),this.validate(e),this.preprocess(e),this.definition=e,this.hasSecurityDefinitions=this.containsSecurity(e),this.allowMergeRefs=e.openapi.startsWith("3.1");var n=IS_BROWSER?window.location.href:"";"string"==typeof r&&(this.definitionUrl=urlResolve(n,r))}return Object.defineProperty(e.prototype,"validate",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(void 0===e.openapi)throw new Error("Document must be valid OpenAPI 3.0.0 definition")}}),Object.defineProperty(e.prototype,"containsSecurity",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var r=e.info&&e.info.description||"";return MarkdownRenderer.containsComponent(r,SECURITY_DEFINITIONS_COMPONENT_NAME)||MarkdownRenderer.containsComponent(r,SECURITY_DEFINITIONS_JSX_NAME)}}),Object.defineProperty(e.prototype,"preprocess",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(e.info&&this.options.hideInfoDescription)e.info.description="";else if(!this.options.noAutoAuth&&e.info&&e.components&&e.components.securitySchemes){var r=e.info.description||"";if(!this.containsSecurity(e)){var t=buildComponentComment(SECURITY_DEFINITIONS_COMPONENT_NAME);e.info.description=appendToMdHeading(r,"Authentication",t)}}}}),Object.defineProperty(e.prototype,"isRef",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return!!e&&(void 0!==e.$ref&&null!==e.$ref)}}),Object.defineProperty(e.prototype,"resetVisited",{enumerable:!1,configurable:!0,writable:!0,value:function(){if("production"!==process.env.NODE_ENV)for(var e in this._refCounter._counter)this._refCounter._counter[e]>0&&console.warn("Not exited reference: "+e);this._refCounter=new RefCounter}}),Object.defineProperty(e.prototype,"exitRef",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.isRef(e)&&this._refCounter.exit(e.$ref)}}),Object.defineProperty(e.prototype,"deref",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,t){if(void 0===r&&(r=!1),void 0===t&&(t=!1),this.isRef(e)){var i=getDefinitionName(e.$ref);if(i&&this.options.ignoreNamedSchemas.has(i))return{type:"object",title:i};var n=this.byRef(e.$ref),o=this._refCounter.visited(e.$ref);if(this._refCounter.visit(e.$ref),o&&!r)return Object.assign({},n,{"x-circular-ref":!0});var a=n;return this.isRef(n)&&(a=this.deref(n,!1,t),this.exitRef(n)),this.allowMergeRefs?this.mergeRefs(e,n,t):a}return e}}),Object.defineProperty(e.prototype,"mergeRefs",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,t){e.$ref;var i=__rest(e,["$ref"]),n=Object.keys(i);return 0===n.length?r:t&&n.some((function(e){return"description"!==e&&"title"!==e&&"externalDocs"!==e}))?{allOf:[r,i]}:__assign(__assign({},r),i)}}),Object.defineProperty(e.prototype,"shallowDeref",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this.isRef(e)){var r=getDefinitionName(e.$ref);if(r&&this.options.ignoreNamedSchemas.has(r))return{type:"object",title:r};var t=this.byRef(e.$ref);return this.allowMergeRefs?this.mergeRefs(e,t,!1):t}return e}}),Object.defineProperty(e.prototype,"mergeAllOf",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,t,i){var n,o=this;if(void 0===t&&(t=!1),void 0===i&&(i=new Set),r&&i.add(r),void 0===(e=this.hoistOneOfs(e)).allOf)return e;var a=__assign(__assign({},e),{allOf:void 0,parentRefs:[],title:e.title||getDefinitionName(r)});void 0!==a.properties&&"object"==typeof a.properties&&(a.properties=__assign({},a.properties)),void 0!==a.items&&"object"==typeof a.items&&(a.items=__assign({},a.items));for(var
|
|
1
|
+
import{__assign,__rest,__spreadArray}from"tslib";import{resolve as urlResolve}from"url";import{appendToMdHeading,IS_BROWSER}from"../utils/";import{JsonPointer}from"../utils/JsonPointer";import{getDefinitionName,isNamedDefinition,SECURITY_DEFINITIONS_COMPONENT_NAME,SECURITY_DEFINITIONS_JSX_NAME}from"../utils";import{buildComponentComment,MarkdownRenderer}from"./MarkdownRenderer";import{RedocNormalizedOptions}from"./RedocNormalizedOptions";var RefCounter=function(){function e(){Object.defineProperty(this,"_counter",{enumerable:!0,configurable:!0,writable:!0,value:{}})}return Object.defineProperty(e.prototype,"reset",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._counter={}}}),Object.defineProperty(e.prototype,"visit",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._counter[e]=this._counter[e]?this._counter[e]+1:1}}),Object.defineProperty(e.prototype,"exit",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._counter[e]=this._counter[e]&&this._counter[e]-1}}),Object.defineProperty(e.prototype,"visited",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return!!this._counter[e]}}),e}(),OpenAPIParser=function(){function e(e,r,t){var i=this;void 0===t&&(t=new RedocNormalizedOptions({})),Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"definitionUrl",{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,"hasSecurityDefinitions",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_refCounter",{enumerable:!0,configurable:!0,writable:!0,value:new RefCounter}),Object.defineProperty(this,"allowMergeRefs",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"byRef",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var r;if(i.definition){"#"!==e.charAt(0)&&(e="#"+e),e=decodeURIComponent(e);try{r=JsonPointer.get(i.definition,e)}catch(e){}return r||{}}}}),this.validate(e),this.preprocess(e),this.definition=e,this.hasSecurityDefinitions=this.containsSecurity(e),this.allowMergeRefs=e.openapi.startsWith("3.1");var n=IS_BROWSER?window.location.href:"";"string"==typeof r&&(this.definitionUrl=urlResolve(n,r))}return Object.defineProperty(e.prototype,"validate",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(void 0===e.openapi)throw new Error("Document must be valid OpenAPI 3.0.0 definition")}}),Object.defineProperty(e.prototype,"containsSecurity",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var r=e.info&&e.info.description||"";return MarkdownRenderer.containsComponent(r,SECURITY_DEFINITIONS_COMPONENT_NAME)||MarkdownRenderer.containsComponent(r,SECURITY_DEFINITIONS_JSX_NAME)}}),Object.defineProperty(e.prototype,"preprocess",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(e.info&&this.options.hideInfoDescription)e.info.description="";else if(!this.options.noAutoAuth&&e.info&&e.components&&e.components.securitySchemes){var r=e.info.description||"";if(!this.containsSecurity(e)){var t=buildComponentComment(SECURITY_DEFINITIONS_COMPONENT_NAME);e.info.description=appendToMdHeading(r,"Authentication",t)}}}}),Object.defineProperty(e.prototype,"isRef",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return!!e&&(void 0!==e.$ref&&null!==e.$ref)}}),Object.defineProperty(e.prototype,"resetVisited",{enumerable:!1,configurable:!0,writable:!0,value:function(){if("production"!==process.env.NODE_ENV)for(var e in this._refCounter._counter)this._refCounter._counter[e]>0&&console.warn("Not exited reference: "+e);this._refCounter=new RefCounter}}),Object.defineProperty(e.prototype,"exitRef",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.isRef(e)&&this._refCounter.exit(e.$ref)}}),Object.defineProperty(e.prototype,"deref",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,t){if(void 0===r&&(r=!1),void 0===t&&(t=!1),this.isRef(e)){var i=getDefinitionName(e.$ref);if(i&&this.options.ignoreNamedSchemas.has(i))return{type:"object",title:i};var n=this.byRef(e.$ref),o=this._refCounter.visited(e.$ref);if(this._refCounter.visit(e.$ref),o&&!r)return Object.assign({},n,{"x-circular-ref":!0});var a=n;return this.isRef(n)&&(a=this.deref(n,!1,t),this.exitRef(n)),this.allowMergeRefs?this.mergeRefs(e,n,t):a}return e}}),Object.defineProperty(e.prototype,"mergeRefs",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,t){e.$ref;var i=__rest(e,["$ref"]),n=Object.keys(i);return 0===n.length?r:t&&n.some((function(e){return"description"!==e&&"title"!==e&&"externalDocs"!==e}))?{allOf:[r,i]}:__assign(__assign({},r),i)}}),Object.defineProperty(e.prototype,"shallowDeref",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this.isRef(e)){var r=getDefinitionName(e.$ref);if(r&&this.options.ignoreNamedSchemas.has(r))return{type:"object",title:r};var t=this.byRef(e.$ref);return this.allowMergeRefs?this.mergeRefs(e,t,!1):t}return e}}),Object.defineProperty(e.prototype,"mergeAllOf",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,t,i){var n,o=this;if(void 0===t&&(t=!1),void 0===i&&(i=new Set),r&&i.add(r),void 0===(e=this.hoistOneOfs(e)).allOf)return e;var a=__assign(__assign({},e),{allOf:void 0,parentRefs:[],title:e.title||getDefinitionName(r)});void 0!==a.properties&&"object"==typeof a.properties&&(a.properties=__assign({},a.properties)),void 0!==a.items&&"object"==typeof a.items&&(a.items=__assign({},a.items));for(var f=0,s=e.allOf.map((function(e){var r;if(!(e&&e.$ref&&i.has(e.$ref))){var n=o.deref(e,t,!0),f=e.$ref||void 0,s=o.mergeAllOf(n,f,t,i);return null===(r=a.parentRefs)||void 0===r||r.push.apply(r,s.parentRefs||[]),{$ref:f,schema:s}}})).filter((function(e){return void 0!==e}));f<s.length;f++){var l=s[f],u=l.$ref,p=l.schema;if(a.type!==p.type&&void 0!==a.type&&void 0!==p.type&&console.warn('Incompatible types in allOf at "'+r+'": "'+a.type+'" and "'+p.type+'"'),void 0!==p.type&&(a.type=p.type),void 0!==p.properties)for(var c in a.properties=a.properties||{},p.properties)if(a.properties[c]){var d=this.mergeAllOf({allOf:[a.properties[c],p.properties[c]]},r+"/properties/"+c);a.properties[c]=d,this.exitParents(d)}else a.properties[c]=p.properties[c];void 0!==p.items&&(a.items=a.items||{},a.items=this.mergeAllOf({allOf:[a.items,p.items]},r+"/items")),void 0!==p.required&&(a.required=(a.required||[]).concat(p.required)),a=__assign(__assign({},p),a),u&&(null===(n=a.parentRefs)||void 0===n||n.push(u),void 0===a.title&&isNamedDefinition(u))}return a}}),Object.defineProperty(e.prototype,"findDerived",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var r={},t=this.definition.components&&this.definition.components.schemas||{};for(var i in t){var n=this.deref(t[i]);void 0!==n.allOf&&n.allOf.find((function(r){return void 0!==r.$ref&&e.indexOf(r.$ref)>-1}))&&(r["#/components/schemas/"+i]=[n["x-discriminator-value"]||i])}return r}}),Object.defineProperty(e.prototype,"exitParents",{enumerable:!1,configurable:!0,writable:!0,value:function(e){for(var r=0,t=e.parentRefs||[];r<t.length;r++){var i=t[r];this.exitRef({$ref:i})}}}),Object.defineProperty(e.prototype,"hoistOneOfs",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var r=this;if(void 0===e.allOf)return e;for(var t=e.allOf,i=function(e){var i=t[e];if(Array.isArray(i.oneOf)){var n=t.slice(0,e),o=t.slice(e+1);return{value:{oneOf:i.oneOf.map((function(e){var t=r.mergeAllOf({allOf:__spreadArray(__spreadArray(__spreadArray([],n,!0),[e],!1),o,!0)});return r.exitParents(t),t}))}}}},n=0;n<t.length;n++){var o=i(n);if("object"==typeof o)return o.value}return e}}),e}();export{OpenAPIParser};
|
|
2
2
|
//# sourceMappingURL=OpenAPIParser.js.map
|
|
@@ -16,7 +16,7 @@ export interface ExternalSource {
|
|
|
16
16
|
pathParams?: any;
|
|
17
17
|
properties?: any;
|
|
18
18
|
}
|
|
19
|
-
export interface
|
|
19
|
+
export interface SecurityPanelHookProps {
|
|
20
20
|
operation: OperationModel;
|
|
21
21
|
server: Server;
|
|
22
22
|
onChange: (securityDetails: unknown) => void;
|
|
@@ -40,7 +40,7 @@ interface HooksConfig {
|
|
|
40
40
|
AfterOperation?: HookConfig<{
|
|
41
41
|
operation: OperationModel;
|
|
42
42
|
}>;
|
|
43
|
-
|
|
43
|
+
ReplaceTryItSecurityPanel?: HookConfig<SecurityPanelHookProps>;
|
|
44
44
|
onInit?: (args: {
|
|
45
45
|
store: ProStore;
|
|
46
46
|
}) => void;
|
|
@@ -48,6 +48,8 @@ interface HooksConfig {
|
|
|
48
48
|
securityRequirementId: string;
|
|
49
49
|
}) => string;
|
|
50
50
|
sanitize?: (raw: string) => string;
|
|
51
|
+
/** @deprecated Use ReplaceTryItSecurityPanel instead */
|
|
52
|
+
ReplaceTryItAuthPanel?: HookConfig<SecurityPanelHookProps>;
|
|
51
53
|
}
|
|
52
54
|
export interface RedocRawOptions {
|
|
53
55
|
theme?: ThemeInterface;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign,__decorate}from"tslib";import{observable,makeObservable}from"mobx";import defaultTheme,{resolveTheme}from"../theme";import{isNumeric,mergeObjects,querySelector}from"../utils";import{setRedocLabels}from"./Labels";export function argValueToBoolean(e,a){return void 0===e?a||!1:"string"==typeof e?"false"!==e:e}function argValueToNumber(e){return"string"==typeof e?parseInt(e,10):"number"==typeof e?e:void 0}function argValueToInt(e){return"string"==typeof e?parseInt(e,10):"number"==typeof e?Math.ceil(e):void 0}function argValueToExpandLevel(e,a){return void 0===a&&(a=0),"all"===e?1/0:argValueToInt(e)||a}var RedocNormalizedOptions=function(){function e(a,t){var r,i,o,l,n,s;void 0===t&&(t={}),Object.defineProperty(this,"theme",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"scrollYOffset",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"hideHostname",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"hideInfoDescription",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"expandResponses",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"requiredPropsFirst",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sortPropsAlphabetically",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sortEnumValuesAlphabetically",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sortOperationsAlphabetically",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sortTagsAlphabetically",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"noAutoAuth",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"nativeScrollbars",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pathInMiddlePanel",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"untrustedDefinition",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"hideDownloadButton",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"disableSearch",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"showChangeLayoutButton",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onlyRequiredInSamples",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"showConsole",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sendXUserAgentInTryIt",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"generatedPayloadSamplesMaxDepth",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"showExtensions",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"hideSingleRequestSampleTab",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"hideRequestPayloadSample",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"menuToggle",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"jsonSampleExpandLevel",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"enumSkipQuotes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"hideSchemaTitles",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"simpleOneOfTypeLabel",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"payloadSampleIdx",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"expandSingleSchemaField",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"schemaExpansionLevel",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"samplesTabsMaxCount",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"unstable_tryItButtonOverride",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"allowedMdComponents",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"expandDefaultServerVariables",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"maxDisplayedEnumValues",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ignoreNamedSchemas",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"unstable_ignoreMimeParameters",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"unstable_externalCodeSamples",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"hooks",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"hideSchemaPattern",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),makeObservable(this);var u=null===(r=(a=__assign(__assign({},t),a)).theme)||void 0===r?void 0:r.extensionsHook;(null===(i=a.theme)||void 0===i?void 0:i.menu)&&!(null===(o=a.theme)||void 0===o?void 0:o.sidebar)&&(console.warn('Theme setting "menu" is deprecated. Rename to "sidebar"'),a.theme.sidebar=a.theme.menu),(null===(l=a.theme)||void 0===l?void 0:l.codeSample)&&!(null===(n=a.theme)||void 0===n?void 0:n.codeBlock)&&(console.warn('Theme setting "codeSample" is deprecated. Rename to "codeBlock"'),a.theme.codeBlock=a.theme.codeSample),this.theme=resolveTheme(mergeObjects({},defaultTheme,__assign(__assign({},a.theme),{extensionsHook:void 0}))),this.theme.mediaQueries={print:"@media print"};for(var b=0,d=Object.entries(this.theme.breakpoints);b<d.length;b++){var m=d[b],c=m[0],p=m[1];this.theme.mediaQueries[c]="@media screen and (min-width: "+p+")"}this.theme.extensionsHook=u,setRedocLabels(a.labels),this.scrollYOffset=e.normalizeScrollYOffset(a.scrollYOffset),this.hideHostname=e.normalizeHideHostname(a.hideHostname),this.expandResponses=e.normalizeExpandResponses(a.expandResponses),this.requiredPropsFirst=argValueToBoolean(a.requiredPropsFirst),this.sortPropsAlphabetically=argValueToBoolean(a.sortPropsAlphabetically),this.sortEnumValuesAlphabetically=argValueToBoolean(a.sortEnumValuesAlphabetically),this.sortOperationsAlphabetically=argValueToBoolean(a.sortOperationsAlphabetically),this.sortTagsAlphabetically=argValueToBoolean(a.sortTagsAlphabetically),this.noAutoAuth=argValueToBoolean(a.noAutoAuth),this.nativeScrollbars=argValueToBoolean(a.nativeScrollbars),this.pathInMiddlePanel=argValueToBoolean(a.pathInMiddlePanel),this.untrustedDefinition=argValueToBoolean(a.untrustedDefinition),this.hideDownloadButton=argValueToBoolean(a.hideDownloadButton),this.hideInfoDescription=argValueToBoolean(a.hideInfoDescription),this.disableSearch=argValueToBoolean(a.disableSearch),this.onlyRequiredInSamples=argValueToBoolean(a.onlyRequiredInSamples),this.generatedPayloadSamplesMaxDepth=argValueToInt(a.generatedPayloadSamplesMaxDepth)||8,this.sendXUserAgentInTryIt=argValueToBoolean(a.sendXUserAgentInTryIt),this.showExtensions=e.normalizeShowExtensions(a.showExtensions),this.hideSingleRequestSampleTab=argValueToBoolean(a.hideSingleRequestSampleTab),this.hideRequestPayloadSample=argValueToBoolean(a.hideRequestPayloadSample),this.menuToggle=argValueToBoolean(a.menuToggle,!0),this.jsonSampleExpandLevel=argValueToExpandLevel(a.jsonSampleExpandLevel,2),this.enumSkipQuotes=argValueToBoolean(a.enumSkipQuotes),this.hideSchemaTitles=argValueToBoolean(a.hideSchemaTitles),this.simpleOneOfTypeLabel=argValueToBoolean(a.simpleOneOfTypeLabel),this.payloadSampleIdx=e.normalizePayloadSampleIdx(a.payloadSampleIdx),this.expandSingleSchemaField=argValueToBoolean(a.expandSingleSchemaField),this.schemaExpansionLevel=argValueToExpandLevel(a.schemaExpansionLevel),this.samplesTabsMaxCount=argValueToInt(a.samplesTabsMaxCount)||5,this.unstable_tryItButtonOverride=a.unstable_tryItButtonOverride||null,this.unstable_ignoreMimeParameters=argValueToBoolean(a.unstable_ignoreMimeParameters),this.allowedMdComponents=a.allowedMdComponents||{},this.expandDefaultServerVariables=argValueToBoolean(a.expandDefaultServerVariables),this.maxDisplayedEnumValues=argValueToNumber(a.maxDisplayedEnumValues);var h=Array.isArray(a.ignoreNamedSchemas)?a.ignoreNamedSchemas:null===(s=a.ignoreNamedSchemas)||void 0===s?void 0:s.split(",").map((function(e){return e.trim()}));this.ignoreNamedSchemas=new Set(h),this.unstable_externalCodeSamples=a.unstable_externalCodeSamples||[],this.hooks=a.hooks||{},this.hideSchemaPattern=argValueToBoolean(a.hideSchemaPattern)}return Object.defineProperty(e,"normalizeExpandResponses",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if("all"===e)return"all";if("string"==typeof e){var a={};return e.split(",").forEach((function(e){a[e.trim()]=!0})),a}return void 0!==e&&console.warn('expandResponses must be a string but received value "'+e+'" of type '+typeof e),{}}}),Object.defineProperty(e,"normalizeHideHostname",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return!!e}}),Object.defineProperty(e,"normalizeScrollYOffset",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if("string"==typeof e&&!isNumeric(e)){var a=querySelector(e);a||console.warn("scrollYOffset value is a selector to non-existing element. Using offset 0 by default");var t=a&&a.getBoundingClientRect().bottom||0;return function(){return t}}return"number"==typeof e||isNumeric(e)?function(){return"number"==typeof e?e:parseFloat(e)}:"function"==typeof e?function(){var a=e();return"number"!=typeof a&&console.warn('scrollYOffset should return number but returned value "'+a+'" of type '+typeof a),a}:(void 0!==e&&console.warn("Wrong value for scrollYOffset ReDoc option: should be string, number or function"),function(){return 0})}}),Object.defineProperty(e,"normalizeShowExtensions",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(void 0===e)return!1;if(""===e)return!0;if("string"!=typeof e)return e;switch(e){case"true":return!0;case"false":return!1;default:return e.split(",").map((function(e){return e.trim()}))}}}),Object.defineProperty(e,"normalizePayloadSampleIdx",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return"number"==typeof e?Math.max(0,e):"string"==typeof e&&isFinite(e)?parseInt(e,10):0}}),__decorate([observable],e.prototype,"showConsole",void 0),e}();export{RedocNormalizedOptions};
|
|
1
|
+
import{__assign,__decorate}from"tslib";import{observable,makeObservable}from"mobx";import defaultTheme,{resolveTheme}from"../theme";import{isNumeric,mergeObjects,querySelector}from"../utils";import{setRedocLabels}from"./Labels";export function argValueToBoolean(e,a){return void 0===e?a||!1:"string"==typeof e?"false"!==e:e}function argValueToNumber(e){return"string"==typeof e?parseInt(e,10):"number"==typeof e?e:void 0}function argValueToInt(e){return"string"==typeof e?parseInt(e,10):"number"==typeof e?Math.ceil(e):void 0}function argValueToExpandLevel(e,a){return void 0===a&&(a=0),"all"===e?1/0:argValueToInt(e)||a}var RedocNormalizedOptions=function(){function e(a,t){var r,i,o,l,n,s;void 0===t&&(t={}),Object.defineProperty(this,"theme",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"scrollYOffset",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"hideHostname",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"hideInfoDescription",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"expandResponses",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"requiredPropsFirst",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sortPropsAlphabetically",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sortEnumValuesAlphabetically",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sortOperationsAlphabetically",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sortTagsAlphabetically",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"noAutoAuth",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"nativeScrollbars",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pathInMiddlePanel",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"untrustedDefinition",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"hideDownloadButton",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"disableSearch",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"showChangeLayoutButton",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onlyRequiredInSamples",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"showConsole",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sendXUserAgentInTryIt",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"generatedPayloadSamplesMaxDepth",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"showExtensions",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"hideSingleRequestSampleTab",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"hideRequestPayloadSample",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"menuToggle",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"jsonSampleExpandLevel",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"enumSkipQuotes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"hideSchemaTitles",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"simpleOneOfTypeLabel",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"payloadSampleIdx",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"expandSingleSchemaField",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"schemaExpansionLevel",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"samplesTabsMaxCount",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"unstable_tryItButtonOverride",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"allowedMdComponents",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"expandDefaultServerVariables",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"maxDisplayedEnumValues",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ignoreNamedSchemas",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"unstable_ignoreMimeParameters",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"unstable_externalCodeSamples",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"hooks",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"hideSchemaPattern",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),makeObservable(this);var u=null===(r=(a=__assign(__assign({},t),a)).theme)||void 0===r?void 0:r.extensionsHook;(null===(i=a.theme)||void 0===i?void 0:i.menu)&&!(null===(o=a.theme)||void 0===o?void 0:o.sidebar)&&(console.warn('Theme setting "menu" is deprecated. Rename to "sidebar"'),a.theme.sidebar=a.theme.menu),(null===(l=a.theme)||void 0===l?void 0:l.codeSample)&&!(null===(n=a.theme)||void 0===n?void 0:n.codeBlock)&&(console.warn('Theme setting "codeSample" is deprecated. Rename to "codeBlock"'),a.theme.codeBlock=a.theme.codeSample),this.theme=resolveTheme(mergeObjects({},defaultTheme,__assign(__assign({},a.theme),{extensionsHook:void 0}))),this.theme.mediaQueries={print:"@media print"};for(var b=0,d=Object.entries(this.theme.breakpoints);b<d.length;b++){var c=d[b],m=c[0],h=c[1];this.theme.mediaQueries[m]="@media screen and (min-width: "+h+")"}this.theme.extensionsHook=u,setRedocLabels(a.labels),this.scrollYOffset=e.normalizeScrollYOffset(a.scrollYOffset),this.hideHostname=e.normalizeHideHostname(a.hideHostname),this.expandResponses=e.normalizeExpandResponses(a.expandResponses),this.requiredPropsFirst=argValueToBoolean(a.requiredPropsFirst),this.sortPropsAlphabetically=argValueToBoolean(a.sortPropsAlphabetically),this.sortEnumValuesAlphabetically=argValueToBoolean(a.sortEnumValuesAlphabetically),this.sortOperationsAlphabetically=argValueToBoolean(a.sortOperationsAlphabetically),this.sortTagsAlphabetically=argValueToBoolean(a.sortTagsAlphabetically),this.noAutoAuth=argValueToBoolean(a.noAutoAuth),this.nativeScrollbars=argValueToBoolean(a.nativeScrollbars),this.pathInMiddlePanel=argValueToBoolean(a.pathInMiddlePanel),this.untrustedDefinition=argValueToBoolean(a.untrustedDefinition),this.hideDownloadButton=argValueToBoolean(a.hideDownloadButton),this.hideInfoDescription=argValueToBoolean(a.hideInfoDescription),this.disableSearch=argValueToBoolean(a.disableSearch),this.onlyRequiredInSamples=argValueToBoolean(a.onlyRequiredInSamples),this.generatedPayloadSamplesMaxDepth=argValueToInt(a.generatedPayloadSamplesMaxDepth)||8,this.sendXUserAgentInTryIt=argValueToBoolean(a.sendXUserAgentInTryIt),this.showExtensions=e.normalizeShowExtensions(a.showExtensions),this.hideSingleRequestSampleTab=argValueToBoolean(a.hideSingleRequestSampleTab),this.hideRequestPayloadSample=argValueToBoolean(a.hideRequestPayloadSample),this.menuToggle=argValueToBoolean(a.menuToggle,!0),this.jsonSampleExpandLevel=argValueToExpandLevel(a.jsonSampleExpandLevel,2),this.enumSkipQuotes=argValueToBoolean(a.enumSkipQuotes),this.hideSchemaTitles=argValueToBoolean(a.hideSchemaTitles),this.simpleOneOfTypeLabel=argValueToBoolean(a.simpleOneOfTypeLabel),this.payloadSampleIdx=e.normalizePayloadSampleIdx(a.payloadSampleIdx),this.expandSingleSchemaField=argValueToBoolean(a.expandSingleSchemaField),this.schemaExpansionLevel=argValueToExpandLevel(a.schemaExpansionLevel),this.samplesTabsMaxCount=argValueToInt(a.samplesTabsMaxCount)||5,this.unstable_tryItButtonOverride=a.unstable_tryItButtonOverride||null,this.unstable_ignoreMimeParameters=argValueToBoolean(a.unstable_ignoreMimeParameters),this.allowedMdComponents=a.allowedMdComponents||{},this.expandDefaultServerVariables=argValueToBoolean(a.expandDefaultServerVariables),this.maxDisplayedEnumValues=argValueToNumber(a.maxDisplayedEnumValues);var p=Array.isArray(a.ignoreNamedSchemas)?a.ignoreNamedSchemas:null===(s=a.ignoreNamedSchemas)||void 0===s?void 0:s.split(",").map((function(e){return e.trim()}));this.ignoreNamedSchemas=new Set(p),this.unstable_externalCodeSamples=a.unstable_externalCodeSamples||[],this.hooks=a.hooks||{},this.hooks.ReplaceTryItAuthPanel&&!this.hooks.ReplaceTryItSecurityPanel&&(console.warn("[warn] ReplaceTryItAuthPanel is deprecated, use ReplaceTryItSecurityPanel instead"),this.hooks.ReplaceTryItSecurityPanel=this.hooks.ReplaceTryItAuthPanel),this.hideSchemaPattern=argValueToBoolean(a.hideSchemaPattern)}return Object.defineProperty(e,"normalizeExpandResponses",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if("all"===e)return"all";if("string"==typeof e){var a={};return e.split(",").forEach((function(e){a[e.trim()]=!0})),a}return void 0!==e&&console.warn('expandResponses must be a string but received value "'+e+'" of type '+typeof e),{}}}),Object.defineProperty(e,"normalizeHideHostname",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return!!e}}),Object.defineProperty(e,"normalizeScrollYOffset",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if("string"==typeof e&&!isNumeric(e)){var a=querySelector(e);a||console.warn("scrollYOffset value is a selector to non-existing element. Using offset 0 by default");var t=a&&a.getBoundingClientRect().bottom||0;return function(){return t}}return"number"==typeof e||isNumeric(e)?function(){return"number"==typeof e?e:parseFloat(e)}:"function"==typeof e?function(){var a=e();return"number"!=typeof a&&console.warn('scrollYOffset should return number but returned value "'+a+'" of type '+typeof a),a}:(void 0!==e&&console.warn("Wrong value for scrollYOffset ReDoc option: should be string, number or function"),function(){return 0})}}),Object.defineProperty(e,"normalizeShowExtensions",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(void 0===e)return!1;if(""===e)return!0;if("string"!=typeof e)return e;switch(e){case"true":return!0;case"false":return!1;default:return e.split(",").map((function(e){return e.trim()}))}}}),Object.defineProperty(e,"normalizePayloadSampleIdx",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return"number"==typeof e?Math.max(0,e):"string"==typeof e&&isFinite(e)?parseInt(e,10):0}}),__decorate([observable],e.prototype,"showConsole",void 0),e}();export{RedocNormalizedOptions};
|
|
2
2
|
//# sourceMappingURL=RedocNormalizedOptions.js.map
|
|
@@ -42,8 +42,7 @@ export declare class SchemaModel {
|
|
|
42
42
|
oneOfType: string;
|
|
43
43
|
discriminatorProp: string;
|
|
44
44
|
activeOneOf: number;
|
|
45
|
-
rawSchema:
|
|
46
|
-
parentRefs: string[];
|
|
45
|
+
rawSchema: OpenAPISchema;
|
|
47
46
|
schema: MergedOpenAPISchema;
|
|
48
47
|
extensions?: GenericObject;
|
|
49
48
|
'x-enumDescriptions': {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign,__decorate,__spreadArray}from"tslib";import{action,observable,makeObservable}from"mobx";import{FieldModel}from"./Field";import{detectType,extractExtensions,humanizeConstraints,isNamedDefinition,isPrimitiveType,JsonPointer,pluralizeType,sortByField,sortByRequired}from"../../utils/";import{l}from"../Labels";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,"parentRefs",{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.shallowDeref(i),this.parentRefs=i.parentRefs||this.rawSchema.parentRefs||[],this.schema=e.mergeAllOf(this.rawSchema,this.pointer,n),this.init(e,n),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,t,r;return!!(e.indexOf(this.pointer)>-1||(null===(i=this.parent)||void 0===i?void 0:i.parentRefs.some((function(i){return e.indexOf(i)>-1}))))||null!==(r=null===(t=this.parent)||void 0===t?void 0:t.hasCircularParent(__spreadArray([this.pointer],e,!0)))&&void 0!==r&&r}}),Object.defineProperty(e.prototype,"init",{enumerable:!1,configurable:!0,writable:!0,value:function(i,t){var r=this,n=this.schema;if(this.isCircular=n["x-circular-ref"]||this.hasCircularParent(this.parentRefs),this.title=n.title||isNamedDefinition(this.pointer)&&JsonPointer.baseName(this.pointer)||"",this.description=n.description||"",this.type=n.type||detectType(n),this.format=n.format,this.enum=n.enum||[],this["x-enumDescriptions"]=n["x-enumDescriptions"],this.example=n.example,this.deprecated=!!n.deprecated,this.pattern=n.pattern,this.externalDocs=n.externalDocs,this.constraints=humanizeConstraints(n),this.displayFormat=this.format,this.isPrimitive=isPrimitiveType(n,this.type),this.default=n.default,this.readOnly=!!n.readOnly,this.writeOnly=!!n.writeOnly,this.const=n.const||"",this.contentEncoding=n.contentEncoding,this.contentMediaType=n.contentMediaType,this.minItems=n.minItems,this.maxItems=n.maxItems,(n.nullable||n["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(t||void 0===getDiscriminator(n)){if(t&&Array.isArray(n.oneOf)&&n.oneOf.find((function(e){return e.$ref===r.pointer}))&&delete n.oneOf,void 0!==n.oneOf)return this.initOneOf(n.oneOf,i),this.oneOfType="One of",void(void 0!==n.anyOf&&console.warn("oneOf and anyOf are not supported on the same level. Skipping anyOf at "+this.pointer));if(void 0!==n.anyOf)return this.initOneOf(n.anyOf,i),void(this.oneOfType="Any of");if(this.hasType("array")&&n.items&&(this.items=new e(i,n.items,this.pointer+"/items",this.options,!1,this,this.deps),this.displayType=pluralizeType(this.items.displayType),this.displayFormat=this.items.format,this.typePrefix=this.items.typePrefix+l("arrayOf"),this.title=this.title||this.items.title,this.isPrimitive=this.items.isPrimitive,void 0===this.example&&void 0!==this.items.example&&(this.example=[this.items.example]),this.items.isPrimitive&&(this.enum=this.items.enum,this["x-enumDescriptions"]=this.items["x-enumDescriptions"]),Array.isArray(this.type))){var a=this.type.filter((function(e){return"array"!==e}));a.length&&(this.displayType+=" or "+a.join(" or "))}this.enum.length&&this.options.sortEnumValuesAlphabetically&&this.enum.sort()}else this.initDiscriminator(n,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,__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 u=(null==n?void 0:n.mapping)||{},f=(null==n?void 0:n["x-explicitMappingOnly"])||!1;0===Object.keys(u).length&&(f=!1);var d={};for(var b in u){var c=u[b];Array.isArray(d[c])?d[c].push(b):d[c]=[b]}for(var h=__assign(f?{}:__assign({},a),d),m=[],y=0,v=Object.keys(h);y<v.length;y++){var O=h[c=v[y]];if(Array.isArray(O))for(var g=0,P=O;g<P.length;g++){var w=P[g];m.push({$ref:c,name:w})}else m.push({$ref:c,name:O})}var j=Object.keys(u);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}))}}),__decorate([observable],e.prototype,"activeOneOf",void 0),__decorate([action],e.prototype,"activateOneOf",null),e}();export{SchemaModel};function buildFields(e,i,t,r,n,a){var s=i.properties||{},o=i.additionalProperties,l=i.default||{},p=Object.keys(s||[]).map((function(o){var p=s[o];p||(console.warn('Field "'+o+'" is invalid, skipping.\n Field must be an object but got '+typeof p+' at "'+t+'"'),p={});var u=void 0!==i.required&&i.required.indexOf(o)>-1;return new FieldModel(e,{name:o,required:u,schema:__assign(__assign({},p),{default:void 0===p.default?l[o]:p.default})},t+"/properties/"+o,r,n,a)}));return r.sortPropsAlphabetically&&(p=sortByField(p,"name")),r.requiredPropsFirst&&(p=sortByRequired(p,r.sortPropsAlphabetically?void 0:i.required)),"object"!=typeof o&&!0!==o||p.push(new FieldModel(e,{name:("object"==typeof o&&o["x-additionalPropertiesName"]||"property name").concat("*"),required:!1,schema:!0===o?{}:o,kind:"additionalProperties"},t+"/additionalProperties",r,n,a)),p}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,__spreadArray}from"tslib";import{action,observable,makeObservable}from"mobx";import{FieldModel}from"./Field";import{detectType,extractExtensions,humanizeConstraints,isNamedDefinition,isPrimitiveType,JsonPointer,pluralizeType,sortByField,sortByRequired}from"../../utils/";import{l}from"../Labels";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.shallowDeref(i),this.schema=e.mergeAllOf(this.rawSchema,this.pointer,n),this.init(e,n),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=this,n=this.schema;if(this.isCircular=n["x-circular-ref"]||this.hasCircularParent(__spreadArray([this.pointer],this.schema.parentRefs||[],!0)),this.title=n.title||isNamedDefinition(this.pointer)&&JsonPointer.baseName(this.pointer)||"",this.description=n.description||"",this.type=n.type||detectType(n),this.format=n.format,this.enum=n.enum||[],this["x-enumDescriptions"]=n["x-enumDescriptions"],this.example=n.example,this.deprecated=!!n.deprecated,this.pattern=n.pattern,this.externalDocs=n.externalDocs,this.constraints=humanizeConstraints(n),this.displayFormat=this.format,this.isPrimitive=isPrimitiveType(n,this.type),this.default=n.default,this.readOnly=!!n.readOnly,this.writeOnly=!!n.writeOnly,this.const=n.const||"",this.contentEncoding=n.contentEncoding,this.contentMediaType=n.contentMediaType,this.minItems=n.minItems,this.maxItems=n.maxItems,(n.nullable||n["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(t||void 0===getDiscriminator(n)){if(t&&Array.isArray(n.oneOf)&&n.oneOf.find((function(e){return e.$ref===r.pointer}))&&delete n.oneOf,void 0!==n.oneOf)return this.initOneOf(n.oneOf,i),this.oneOfType="One of",void(void 0!==n.anyOf&&console.warn("oneOf and anyOf are not supported on the same level. Skipping anyOf at "+this.pointer));if(void 0!==n.anyOf)return this.initOneOf(n.anyOf,i),void(this.oneOfType="Any of");if(this.hasType("array")&&n.items&&(this.items=new e(i,n.items,this.pointer+"/items",this.options,!1,this,this.deps),this.displayType=pluralizeType(this.items.displayType),this.displayFormat=this.items.format,this.typePrefix=this.items.typePrefix+l("arrayOf"),this.title=this.title||this.items.title,this.isPrimitive=this.items.isPrimitive,void 0===this.example&&void 0!==this.items.example&&(this.example=[this.items.example]),this.items.isPrimitive&&(this.enum=this.items.enum,this["x-enumDescriptions"]=this.items["x-enumDescriptions"]),Array.isArray(this.type))){var a=this.type.filter((function(e){return"array"!==e}));a.length&&(this.displayType+=" or "+a.join(" or "))}this.enum.length&&this.options.sortEnumValuesAlphabetically&&this.enum.sort()}else this.initDiscriminator(n,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 u=(null==n?void 0:n.mapping)||{},f=(null==n?void 0:n["x-explicitMappingOnly"])||!1;0===Object.keys(u).length&&(f=!1);var d={};for(var b in u){var c=u[b];Array.isArray(d[c])?d[c].push(b):d[c]=[b]}for(var h=__assign(f?{}:__assign({},a),d),m=[],y=0,v=Object.keys(h);y<v.length;y++){var O=h[c=v[y]];if(Array.isArray(O))for(var g=0,P=O;g<P.length;g++){var w=P[g];m.push({$ref:c,name:w})}else m.push({$ref:c,name:O})}var j=Object.keys(u);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}))}}),__decorate([observable],e.prototype,"activeOneOf",void 0),__decorate([action],e.prototype,"activateOneOf",null),e}();export{SchemaModel};function buildFields(e,i,t,r,n,a){var s=i.properties||{},o=i.additionalProperties,l=i.default||{},p=Object.keys(s||[]).map((function(o){var p=s[o];p||(console.warn('Field "'+o+'" is invalid, skipping.\n Field must be an object but got '+typeof p+' at "'+t+'"'),p={});var u=void 0!==i.required&&i.required.indexOf(o)>-1;return new FieldModel(e,{name:o,required:u,schema:__assign(__assign({},p),{default:void 0===p.default?l[o]:p.default})},t+"/properties/"+o,r,n,a)}));return r.sortPropsAlphabetically&&(p=sortByField(p,"name")),r.requiredPropsFirst&&(p=sortByRequired(p,r.sortPropsAlphabetically?void 0:i.required)),"object"!=typeof o&&!0!==o||p.push(new FieldModel(e,{name:("object"==typeof o&&o["x-additionalPropertiesName"]||"property name").concat("*"),required:!1,schema:!0===o?{}:o,kind:"additionalProperties"},t+"/additionalProperties",r,n,a)),p}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
|
|
@@ -45,7 +45,7 @@ export declare type RedocProUserOptionsExt = {
|
|
|
45
45
|
routingStrategy?: 'hash' | 'browser';
|
|
46
46
|
routingBasePath?: string;
|
|
47
47
|
theme?: RedocProTheme;
|
|
48
|
-
|
|
48
|
+
downloadDefinitionUrl?: string;
|
|
49
49
|
ctrlFHijack?: boolean;
|
|
50
50
|
unstable_externalDescription?: string;
|
|
51
51
|
linkForId?: ((id: string) => string) | null;
|
|
@@ -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{debounce}from"lodash";import{IS_BROWSER,MarkerService,RedocNormalizedOptions,ScrollService,SecurityDefs,SpecStore,SECURITY_DEFINITIONS_COMPONENT_NAME,SECURITY_DEFINITIONS_JSX_NAME,SCHEMA_DEFINITION_JSX_NAME,SchemaDefinition,createParsedDocument}from"../redoc-lib";import{FakeHistoryService,ProHashHistoryService,PushStateHistoryService}from"./history";import{ProMenu}from"./ProMenu";import{DeepSearchStore,RemoteSearch,SEARCH_MAX_DEPTH}from"./SearchStore";import{extendTheme}from"./extendTheme";import{RedocResponse,PullRight}from"../components/pluggable";import{MultipleSpecsStore}from"./MultipleSpecsStore";import{VersionedSpecStore}from"./VersionedSpecStore";import parseToken from"./check";import{normalizePath}from"./utils";import{fromStorage,toStorage,toLocalStorage,fromLocalStorage,setGlobalStore}from"../utils";import{LayoutVariant}from"./store-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}),Object.defineProperty(this,"activateSampleLanguage",{enumerable:!0,configurable:!0,writable:!0,value:debounce((function(e){return n.setActiveSampleLanguage(e)}),500)}),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=Array.isArray(e),a=e&&Array.isArray(e.versions),s=this.options.disableSidebar?new FakeHistoryService(this.options):"browser"===this.options.routingStrategy?new PushStateHistoryService(this.options,r||a):new ProHashHistoryService(this.options,r||a);this.definition=r?new MultipleSpecsStore(e,this.options):a?new VersionedSpecStore(e,this.options,s.currentId.split("/")[0]):new SpecStore(e,t,this.options),i.downloadSpecUrl&&(this.definition.info.downloadLink=i.downloadSpecUrl,this.definition.info.downloadFileName=""),this.scroll=new ScrollService(this.options),this.options.disableSidebar||ProMenu.updateOnHistory(s.currentId,this.scroll),this.menu=new ProMenu(this.definition,this.scroll,this.options,s),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),this.options.showConsole=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||"summary-only",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":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";break;default:this.options.pagination="none",this.options.routingStrategy="hash"}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||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=fromStorage("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,toStorage("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,"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,t){var i,o,n,r;return __awaiter(this,void 0,void 0,(function(){var a,s,l,p,u,c,h;return __generator(this,(function(d){switch(d.label){case 0:return a=void 0!==e&&this.definition.specs?this.definition.specs[e].parser.definition:this.definition.parser.definition,s=JSON.parse(JSON.stringify(a)),l=__assign(__assign({},getSpecVersionObj(s)),{components:s.components,paths:(c={},c[t.path]=(h={},h[t.httpVerb]=null===(o=null===(i=s.paths)||void 0===i?void 0:i[t.path])||void 0===o?void 0:o[t.httpVerb],h.parameters=null===(r=null===(n=s.paths)||void 0===n?void 0:n[t.path])||void 0===r?void 0:r.parameters,h),c)}),p=new Config({}),u=createParsedDocument(l),[4,bundle({config:p,doc:u,dereference:!0})];case 1:return d.sent(),[2,s]}}))}))}}),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 MultipleSpecsStore||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,i=Math.max(0,e),o=Math.min(this.menu.flatItems.length,i+5),n=[],r=i;r<o;r++){var a;(a=this.menu.getElementAt(r))&&(a&&n.push(a))}"item"===this.options.pagination&&(this.menu.flatItems[e]&&this.menu.flatItems[e].parent&&(a=this.menu.getElementAt(null===(t=this.menu.flatItems[e].parent)||void 0===t?void 0:t.absoluteIdx))&&n.push(a));this.marker.addOnly(n),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([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[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[SCHEMA_DEFINITION_JSX_NAME]={component:SchemaDefinition,propsSelector:function(e){return{parser:e.definition.parser,options:e.options,layout:e.layout,showRightPanel:e.showRightPanel}}},_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{debounce}from"lodash";import{IS_BROWSER,MarkerService,RedocNormalizedOptions,ScrollService,SecurityDefs,SpecStore,SECURITY_DEFINITIONS_COMPONENT_NAME,SECURITY_DEFINITIONS_JSX_NAME,SCHEMA_DEFINITION_JSX_NAME,SchemaDefinition,createParsedDocument}from"../redoc-lib";import{FakeHistoryService,ProHashHistoryService,PushStateHistoryService}from"./history";import{ProMenu}from"./ProMenu";import{DeepSearchStore,RemoteSearch,SEARCH_MAX_DEPTH}from"./SearchStore";import{extendTheme}from"./extendTheme";import{RedocResponse,PullRight}from"../components/pluggable";import{MultipleSpecsStore}from"./MultipleSpecsStore";import{VersionedSpecStore}from"./VersionedSpecStore";import parseToken from"./check";import{normalizePath}from"./utils";import{fromStorage,toStorage,toLocalStorage,fromLocalStorage,setGlobalStore}from"../utils";import{LayoutVariant}from"./store-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}),Object.defineProperty(this,"activateSampleLanguage",{enumerable:!0,configurable:!0,writable:!0,value:debounce((function(e){return n.setActiveSampleLanguage(e)}),500)}),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=Array.isArray(e),a=e&&Array.isArray(e.versions),s=this.options.disableSidebar?new FakeHistoryService(this.options):"browser"===this.options.routingStrategy?new PushStateHistoryService(this.options,r||a):new ProHashHistoryService(this.options,r||a);this.definition=r?new MultipleSpecsStore(e,this.options):a?new VersionedSpecStore(e,this.options,s.currentId.split("/")[0]):new SpecStore(e,t,this.options),i.downloadDefinitionUrl&&(this.definition.info.downloadLink=i.downloadDefinitionUrl,this.definition.info.downloadFileName=""),this.scroll=new ScrollService(this.options),this.options.disableSidebar||ProMenu.updateOnHistory(s.currentId,this.scroll),this.menu=new ProMenu(this.definition,this.scroll,this.options,s),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),this.options.showConsole=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||"summary-only",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":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";break;default:this.options.pagination="none",this.options.routingStrategy="hash"}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||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=fromStorage("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,toStorage("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,"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,t){var i,o,n,r;return __awaiter(this,void 0,void 0,(function(){var a,s,l,p,u,c,h;return __generator(this,(function(d){switch(d.label){case 0:return a=void 0!==e&&this.definition.specs?this.definition.specs[e].parser.definition:this.definition.parser.definition,s=JSON.parse(JSON.stringify(a)),l=__assign(__assign({},getSpecVersionObj(s)),{components:s.components,paths:(c={},c[t.path]=(h={},h[t.httpVerb]=null===(o=null===(i=s.paths)||void 0===i?void 0:i[t.path])||void 0===o?void 0:o[t.httpVerb],h.parameters=null===(r=null===(n=s.paths)||void 0===n?void 0:n[t.path])||void 0===r?void 0:r.parameters,h),c)}),p=new Config({}),u=createParsedDocument(l),[4,bundle({config:p,doc:u,dereference:!0})];case 1:return d.sent(),[2,s]}}))}))}}),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 MultipleSpecsStore||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,i=Math.max(0,e),o=Math.min(this.menu.flatItems.length,i+5),n=[],r=i;r<o;r++){var a;(a=this.menu.getElementAt(r))&&(a&&n.push(a))}"item"===this.options.pagination&&(this.menu.flatItems[e]&&this.menu.flatItems[e].parent&&(a=this.menu.getElementAt(null===(t=this.menu.flatItems[e].parent)||void 0===t?void 0:t.absoluteIdx))&&n.push(a));this.marker.addOnly(n),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([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[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[SCHEMA_DEFINITION_JSX_NAME]={component:SchemaDefinition,propsSelector:function(e){return{parser:e.definition.parser,options:e.options,layout:e.layout,showRightPanel:e.showRightPanel}}},_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 stringifyObject from"stringify-object";import{CodeBuilder}from"../../helpers/code-builder";import{HTTPSnippet}from"../..";import{addIndentation,buildUrlExpression,printUrlVariablesDeclarations}from"../../helpers/code-helpers";import{normalizeMimeType}from"../../../../utils";import{capitalizeFirst}from"../../../generator";import{Lang}from"../../helpers/constants";var handler=function(t,e,a){var s,n,i,r,o=a.target,p=a.client,l=Object.assign({indent:" ",withWrapper:!0},e),u=new CodeBuilder({indentation:l.indent,variablesPrefix:l.variablesPrefix,capitalize:!0,lang:Lang.CSHARP}),c=formatHttpMethod(t.method);if(l.withComments&&addComments(u),l.withWrapper&&(u.push("using System;"),u.push("using System.Net.Http;"),u.push("using System.Threading.Tasks;"),(
|
|
1
|
+
import{__assign}from"tslib";import stringifyObject from"stringify-object";import{CodeBuilder}from"../../helpers/code-builder";import{HTTPSnippet}from"../..";import{addIndentation,buildUrlExpression,printUrlVariablesDeclarations}from"../../helpers/code-helpers";import{normalizeMimeType}from"../../../../utils";import{capitalizeFirst}from"../../../generator";import{Lang}from"../../helpers/constants";var handler=function(t,e,a){var s,n,i,r,o=a.target,p=a.client,l=Object.assign({indent:" ",withWrapper:!0},e),u=new CodeBuilder({indentation:l.indent,variablesPrefix:l.variablesPrefix,capitalize:!0,lang:Lang.CSHARP}),c=formatHttpMethod(t.method);if(l.withComments&&addComments(u),l.withWrapper&&(u.push("using System;"),u.push("using System.Net.Http;"),u.push("using System.Threading.Tasks;"),(w("application/json")||w("application/xml")||t.basicAuth)&&u.push("using System.Text;"),(w("application/x-www-form-urlencoded")||(null===(s=t.securityOAuth2ExtraCalls)||void 0===s?void 0:s.length))&&u.push("using System.Collections.Generic;"),(w("application/json")||(null===(n=t.securityOAuth2ExtraCalls)||void 0===n?void 0:n.length))&&u.push("using Newtonsoft.Json.Linq;"),t.headersObj&&"application/octet-stream"===t.headersObj["Content-Type"]&&(u.push("using System.IO;"),u.push("using System.Net.Http.Headers;")),u.blank(),u.push("public class Program"),u.push("{"),u.push(1,"public static async Task Main(string[] args)"),u.push(1,"{"),u.push(2,"using (var client = new HttpClient())"),u.push(2,"{")),null===(i=t.securityOAuth2ExtraCalls)||void 0===i?void 0:i.length){var h=new HTTPSnippet(null===(r=t.securityOAuth2ExtraCalls)||void 0===r?void 0:r[0]).convert(o,p,__assign(__assign({},l),{withImports:!1,withWrapper:!1,withComments:!1,variablesPrefix:"oauth2"}));u.push(h),u.push(3,"var oauth2Response = await oauth2Request.Content.ReadAsStringAsync();"),u.push(3,"JObject inputJObject = JObject.Parse(oauth2Response);"),u.push(3,'var accessToken = inputJObject["access_token"].ToString();'),u.blank()}var d=Object.keys(t.allHeaders).filter((function(t){switch(t.toLowerCase()){case"content-type":case"content-length":case"accept-encoding":return!1;default:return!0}}));if(d.length&&d.forEach((function(e){var a;u.push(3,'client.DefaultRequestHeaders.Add("%s", %s);',e,(null===(a=t.securityOAuth2ExtraCalls)||void 0===a?void 0:a.length)?'"Bearer " + accessToken':'"'+t.allHeaders[e]+'"')})),t.basicAuth){var m=t.basicAuth,g=m.username,f=m.password;u.push(3,'var base64String = Convert.ToBase64String(Encoding.ASCII.GetBytes("'+g+":"+f+'"));'),u.push(3,'client.DefaultRequestHeaders.Add("Authorization", "Basic "+ base64String);')}if(t.postData)switch(normalizeMimeType(t.postData.mimeType)){case"application/x-www-form-urlencoded":t.postData.params&&(u.blank(),u.push(3,"List<KeyValuePair<string, string>> postData = new List<KeyValuePair<string, string>>();"),t.postData.params.forEach((function(t){u.push(3,'postData.Add(new KeyValuePair<string, string>("%s", "%s"));',t.name,t.value)})),u.blank());break;case"multipart/form-data":t.postData.params&&(u.blank(),u.push(3,"MultipartFormDataContent postData = new MultipartFormDataContent();"),t.postData.params.forEach((function(t){u.push(3,'postData.Add(new StringContent("%s"), "%s");',t.value,t.name)})));break;case"application/json":t.postData.jsonObj&&(u.push(3,'JObject json = JObject.Parse(@"'+addIndentation(stringifyObject(t.postData.jsonObj,{indent:l.indent,inlineCharacterLimit:25}).replace(/"/g,'""'),{level:3,firstLine:!1})+'");'),u.push(3,'var postData = new StringContent(json.ToString(), Encoding.UTF8, "application/json");'));break;case"application/xml":t.postData.text&&(t.postData.text.trim().split("\n").forEach((function(t,e){var a=(0===e?'string xml = @"':"")+t.replace(/"/g,'""');u.push(0===e?3:4,a)})),u.push(3,'";'),u.push(3,'var postData = new StringContent(xml, Encoding.UTF8, "application/xml");'))}else b()&&(u.push(3,"var ms = new MemoryStream();"),u.push(3,"var postData = new StreamContent(ms);"),u.push(3,'postData.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");'));return printUrlVariablesDeclarations(t,u,3),u.push(3,"var %s = await client.%sAsync(%s%s);",u.var("request"),c,buildUrlExpression(t,u),l.withImports?isDataMethod(t.method)?"application/x-www-form-urlencoded"===normalizeMimeType(t.postData&&t.postData.mimeType)?", new FormUrlEncodedContent(postData)":"delete"===t.method?"":t.postData&&t.postData.params||b()?", postData":", null":"":", new FormUrlEncodedContent(postData)"),l.withWrapper&&(u.push(3,"var response = await request.Content.ReadAsStringAsync();"),u.blank(),u.push(3,"Console.WriteLine(response);"),u.push(2,"}"),u.push(1,"}"),u.push("}")),u.join();function w(e){return t.postData&&normalizeMimeType(t.postData.mimeType)===e}function b(){return t.headersObj&&"application/octet-stream"===t.headersObj["Content-Type"]}};export var info={key:"httpclient",title:"HttpClient",link:"https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient",description:".NET Standard HTTP Client"};export default handler;function addComments(t){t.push("/*"),t.push(" * Requires >= .NET 5"),t.push(" *"),t.push(' * Requires package "Newtonsoft.Json" >= 9.01'),t.push(" * See here for installation details:"),t.push(" * https://www.newtonsoft.com/json"),t.push(" */"),t.blank()}function formatHttpMethod(t){return capitalizeFirst(t.toLowerCase())}function isDataMethod(t){return t&&["POST","PUT","DELETE","PATCH"].includes(t.toUpperCase())}
|
|
2
2
|
//# sourceMappingURL=httpclient.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign}from"tslib";import{CodeBuilder}from"../../helpers/code-builder";import{HTTPSnippet}from"../..";import{Lang}from"../../helpers/constants";import{buildUrlExpression,printUrlVariablesDeclarations}from"../../helpers/code-helpers";import{normalizeMimeType}from"../../../../utils";var indent=1,contentType={X_FORM_URLENCODED:"application/x-www-form-urlencoded",JSON:"application/json",FORM_DATA:"multipart/form-data"};function hasMimeType(e,t){return void 0===e&&(e={}),normalizeMimeType(e.mimeType)===t}var handler=function(e,t,n){var a,r,s,i,o,p,d=n.target,l=n.client,u=__assign({capitalize:!0,showBoilerplate:!0,checkErrors:!1,printBody:!0,timeout:-1,indent:" "},t),h=null===(a=e.securityOAuth2ExtraCalls)||void 0===a?void 0:a[0],c=u.checkErrors?"err":"_",v=e.method.toUpperCase(),m=new CodeBuilder({indentation:u.indent,variablesPrefix:u.variablesPrefix,capitalize:u.capitalize,lang:Lang.GO}),y=function(){u.checkErrors&&m.push(indent,"if err != nil {").push(indent+1,"panic(err)").push(indent,"}")};if(u.showBoilerplate&&(m.push("package main").blank().push("import (").push(indent,'"fmt"'),u.timeout>0&&m.push(indent,'"time"'),h&&m.push(indent,'"encoding/json"'),hasMimeType(e.postData,contentType.FORM_DATA)&&(m.push(indent,'"mime/multipart"'),m.push(indent,'"io"'),m.push(indent,'"bytes"')),(hasMimeType(e.postData,contentType.X_FORM_URLENCODED)||hasMimeType(null===(s=null===(r=e.securityOAuth2ExtraCalls)||void 0===r?void 0:r[0])||void 0===s?void 0:s.postData,contentType.X_FORM_URLENCODED))&&(m.push(indent,'"net/url"'),m.push(indent,'"strconv"')),(hasMimeType(e.postData,contentType.JSON)||hasMimeType(null===(o=null===(i=e.securityOAuth2ExtraCalls)||void 0===i?void 0:i[0])||void 0===o?void 0:o.postData,contentType.JSON))&&m.push(indent,'"bytes"'),(e.postData&&!hasMimeType(e.postData,contentType.JSON)||h)&&m.push(indent,'"strings"'),m.push(indent,'"net/http"'),u.printBody&&m.push(indent,'"io/ioutil"'),m.push(")").blank().push("func main() {")),Object.keys(e.allHeaders).length&&Object.keys(e.allHeaders).forEach((function(t){e.allHeaders[t]='"'+e.allHeaders[t]+'"'})),h){var f="oAuth2",b=u.checkErrors?c+" := ":"",w=u.capitalize?"Res":"res",T=new HTTPSnippet(h).convert(d,l,__assign(__assign({},u),{printBody:!1,variablesPrefix:f,showBoilerplate:!1}));m.push(T).blank().push(indent,"var oAuth2"+w+"Body struct {").push(indent+1,"Access_token string").push(indent,"}").push(indent,b+"json.NewDecoder("+f+w+".Body).Decode(&"+f+w+"Body)").blank(),y(),e.allHeaders.Authorization='"Bearer " + oAuth2'+w+"Body.Access_token"}if(printUrlVariablesDeclarations(e,m,indent),u.timeout>0&&(l=m.var("client"),m.push(indent,"%s := http.Client{",l).push(indent+1,"Timeout: time.Duration(%s * time.Second),",u.timeout).push(indent,"}").blank()),m.push(indent,m.var("reqUrl")+" := "+buildUrlExpression(e,m)),e.postData){var D=void 0;switch(normalizeMimeType(e.postData.mimeType)){case contentType.X_FORM_URLENCODED:m.push(indent,"%s := url.Values{}",m.var("data")),e.postData.params.forEach((function(e){m.push(indent,'%s.Set("%s", "%s")',m.var("data"),e.name,e.value)})),m.push(indent,'%s, %s := http.NewRequest("%s", %s, strings.NewReader(%s.Encode()))',m.var("req"),c,v,m.var("reqUrl"),m.var("data")),e.allHeaders["Content-Length"]="strconv.Itoa(len("+m.var("data")+".Encode()))";break;case contentType.JSON:D=JSON.stringify(e.postData.jsonObj,null,2).split("\n").map((function(e){return u.indent+e})).join("\n").trim(),m.push(indent,"var "+m.var("data")+" = []byte(`"+D+"`)"),m.push(indent,'%s, %s := http.NewRequest("%s", %s, bytes.NewBuffer(%s))',m.var("req"),c,v,m.var("reqUrl"),m.var("data"));break;case contentType.FORM_DATA:m.push(indent,"%s := &bytes.Buffer{}",m.var("data")).push(indent,"writer := multipart.NewWriter(%s)",m.var("data")),e.postData.params.forEach((function(e){if(!e.fileName&&!e.contentType)return m.push(indent,'%s, _ := writer.CreateFormField("%s")',m.var(e.name+"Fw"),e.name).push(indent,'_, %s = io.Copy(%s, strings.NewReader("%s"))',c,m.var(e.name+"Fw"),e.value),void y();e.fileName&&(m.push(indent,'%s, %s = writer.CreateFormFile("%s", "%s")',m.var(e.name+"Fw"),c,e.name,e.fileName),y())})),m.push(indent,"writer.Close()").blank().push(indent,"%s := bytes.NewReader(%s.Bytes())",m.var("payload"),m.var("data")).push(indent,'%s, %s := http.NewRequest("%s", %s, %s)',m.var("req"),c,v,m.var("reqUrl"),m.var("payload")),e.allHeaders["Content-Type"]="writer.FormDataContentType()";break;default:e.postData.text&&m.push(indent,"%s := strings.NewReader(%s)",m.var("payload"),JSON.stringify(null===(p=e.postData)||void 0===p?void 0:p.text)).push(indent,'%s, %s := http.NewRequest("%s", %s, %s)',m.var("req"),c,v,m.var("reqUrl"),m.var("payload"))}}else m.push(indent,'%s, %s := http.NewRequest("%s", %s, nil)',m.var("req"),c,v,m.var("reqUrl"));if(Object.getOwnPropertyNames(e.queryObj).length){for(var O in m.blank().push(indent,m.var("query")+" := "+m.var("req")+".URL.Query()"),e.queryObj)m.push(indent,m.var("query")+'.Add("'+O+'", "'+e.queryObj[O]+'")');m.push(indent,m.var("req")+".URL.RawQuery = "+m.var("query")+".Encode()").blank()}
|
|
1
|
+
import{__assign}from"tslib";import{CodeBuilder}from"../../helpers/code-builder";import{HTTPSnippet}from"../..";import{Lang}from"../../helpers/constants";import{buildUrlExpression,printUrlVariablesDeclarations}from"../../helpers/code-helpers";import{normalizeMimeType}from"../../../../utils";var indent=1,contentType={X_FORM_URLENCODED:"application/x-www-form-urlencoded",JSON:"application/json",FORM_DATA:"multipart/form-data"};function hasMimeType(e,t){return void 0===e&&(e={}),normalizeMimeType(e.mimeType)===t}var handler=function(e,t,n){var a,r,s,i,o,p,d=n.target,l=n.client,u=__assign({capitalize:!0,showBoilerplate:!0,checkErrors:!1,printBody:!0,timeout:-1,indent:" "},t),h=null===(a=e.securityOAuth2ExtraCalls)||void 0===a?void 0:a[0],c=u.checkErrors?"err":"_",v=e.method.toUpperCase(),m=new CodeBuilder({indentation:u.indent,variablesPrefix:u.variablesPrefix,capitalize:u.capitalize,lang:Lang.GO}),y=function(){u.checkErrors&&m.push(indent,"if err != nil {").push(indent+1,"panic(err)").push(indent,"}")};if(u.showBoilerplate&&(m.push("package main").blank().push("import (").push(indent,'"fmt"'),u.timeout>0&&m.push(indent,'"time"'),h&&m.push(indent,'"encoding/json"'),hasMimeType(e.postData,contentType.FORM_DATA)&&(m.push(indent,'"mime/multipart"'),m.push(indent,'"io"'),m.push(indent,'"bytes"')),(hasMimeType(e.postData,contentType.X_FORM_URLENCODED)||hasMimeType(null===(s=null===(r=e.securityOAuth2ExtraCalls)||void 0===r?void 0:r[0])||void 0===s?void 0:s.postData,contentType.X_FORM_URLENCODED))&&(m.push(indent,'"net/url"'),m.push(indent,'"strconv"')),(hasMimeType(e.postData,contentType.JSON)||hasMimeType(null===(o=null===(i=e.securityOAuth2ExtraCalls)||void 0===i?void 0:i[0])||void 0===o?void 0:o.postData,contentType.JSON))&&m.push(indent,'"bytes"'),(e.postData&&!hasMimeType(e.postData,contentType.JSON)||h)&&m.push(indent,'"strings"'),m.push(indent,'"net/http"'),u.printBody&&m.push(indent,'"io/ioutil"'),m.push(")").blank().push("func main() {")),Object.keys(e.allHeaders).length&&Object.keys(e.allHeaders).forEach((function(t){e.allHeaders[t]='"'+e.allHeaders[t]+'"'})),h){var f="oAuth2",b=u.checkErrors?c+" := ":"",w=u.capitalize?"Res":"res",T=new HTTPSnippet(h).convert(d,l,__assign(__assign({},u),{printBody:!1,variablesPrefix:f,showBoilerplate:!1}));m.push(T).blank().push(indent,"var oAuth2"+w+"Body struct {").push(indent+1,"Access_token string").push(indent,"}").push(indent,b+"json.NewDecoder("+f+w+".Body).Decode(&"+f+w+"Body)").blank(),y(),e.allHeaders.Authorization='"Bearer " + oAuth2'+w+"Body.Access_token"}if(printUrlVariablesDeclarations(e,m,indent),u.timeout>0&&(l=m.var("client"),m.push(indent,"%s := http.Client{",l).push(indent+1,"Timeout: time.Duration(%s * time.Second),",u.timeout).push(indent,"}").blank()),m.push(indent,m.var("reqUrl")+" := "+buildUrlExpression(e,m)),e.postData){var D=void 0;switch(normalizeMimeType(e.postData.mimeType)){case contentType.X_FORM_URLENCODED:m.push(indent,"%s := url.Values{}",m.var("data")),e.postData.params.forEach((function(e){m.push(indent,'%s.Set("%s", "%s")',m.var("data"),e.name,e.value)})),m.push(indent,'%s, %s := http.NewRequest("%s", %s, strings.NewReader(%s.Encode()))',m.var("req"),c,v,m.var("reqUrl"),m.var("data")),e.allHeaders["Content-Length"]="strconv.Itoa(len("+m.var("data")+".Encode()))";break;case contentType.JSON:D=JSON.stringify(e.postData.jsonObj,null,2).split("\n").map((function(e){return u.indent+e})).join("\n").trim(),m.push(indent,"var "+m.var("data")+" = []byte(`"+D+"`)"),m.push(indent,'%s, %s := http.NewRequest("%s", %s, bytes.NewBuffer(%s))',m.var("req"),c,v,m.var("reqUrl"),m.var("data"));break;case contentType.FORM_DATA:m.push(indent,"%s := &bytes.Buffer{}",m.var("data")).push(indent,"writer := multipart.NewWriter(%s)",m.var("data")),e.postData.params.forEach((function(e){if(!e.fileName&&!e.contentType)return m.push(indent,'%s, _ := writer.CreateFormField("%s")',m.var(e.name+"Fw"),e.name).push(indent,'_, %s = io.Copy(%s, strings.NewReader("%s"))',c,m.var(e.name+"Fw"),e.value),void y();e.fileName&&(m.push(indent,'%s, %s = writer.CreateFormFile("%s", "%s")',m.var(e.name+"Fw"),c,e.name,e.fileName),y())})),m.push(indent,"writer.Close()").blank().push(indent,"%s := bytes.NewReader(%s.Bytes())",m.var("payload"),m.var("data")).push(indent,'%s, %s := http.NewRequest("%s", %s, %s)',m.var("req"),c,v,m.var("reqUrl"),m.var("payload")),e.allHeaders["Content-Type"]="writer.FormDataContentType()";break;default:e.postData.text&&m.push(indent,"%s := strings.NewReader(%s)",m.var("payload"),JSON.stringify(null===(p=e.postData)||void 0===p?void 0:p.text)).push(indent,'%s, %s := http.NewRequest("%s", %s, %s)',m.var("req"),c,v,m.var("reqUrl"),m.var("payload"))}}else m.push(indent,'%s, %s := http.NewRequest("%s", %s, nil)',m.var("req"),c,v,m.var("reqUrl"));if(Object.getOwnPropertyNames(e.queryObj).length){for(var O in m.blank().push(indent,m.var("query")+" := "+m.var("req")+".URL.Query()"),e.queryObj)m.push(indent,m.var("query")+'.Add("'+O+'", "'+e.queryObj[O]+'")');m.push(indent,m.var("req")+".URL.RawQuery = "+m.var("query")+".Encode()").blank()}if(y(),e.basicAuth){var q=e.basicAuth,N=q.username,g=q.password;m.push(indent,'%s.SetBasicAuth("'+N+'", "'+g+'")',m.var("req"))}return Object.keys(e.allHeaders).length&&Object.keys(e.allHeaders).forEach((function(t){m.push(indent,'%s.Header.Add("%s", %s)',m.var("req"),t,e.allHeaders[t])})),m.push(indent,"%s, %s := %s.Do(%s)",m.var("res"),c,l,m.var("req")),y(),u.printBody&&(m.push(indent,"defer %s.Body.Close()",m.var("res")).push(indent,"%s, %s := ioutil.ReadAll(%s.Body)",m.var("body"),c,m.var("res")),y()),m.blank().push(indent,"fmt.Println(%s)",m.var("res")),u.printBody&&m.push(indent,"fmt.Println(string(%s))",m.var("body")),u.showBoilerplate&&m.push("}"),m.join()};export var info={key:"native",title:"NewRequest",link:"http://golang.org/pkg/net/http/#NewRequest",description:"Golang HTTP client request"};export default handler;
|
|
2
2
|
//# sourceMappingURL=native.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign}from"tslib";import{CodeBuilder}from"../../helpers/code-builder";import{HTTPSnippet}from"../..";import{normalizeMimeType}from"../../../../utils";import{addIndentation,buildUrlExpression,printUrlVariablesDeclarations}from"../../helpers/code-helpers";import{Lang}from"../../helpers/constants";var URL_ENCODED="application/x-www-form-urlencoded",hasQueryParams=function(t){return!(!t.uriObj.query||!Object.keys(t.uriObj.query).length)},getBody=function(t){return t.postData&&t.postData.mimeType===URL_ENCODED?"HttpRequest.BodyPublishers.ofString(form)":t.postData?"HttpRequest.BodyPublishers.ofString(payload)":["POST","PUT","PATCH"].includes(t.method.toUpperCase())?'HttpRequest.BodyPublishers.ofString("some body text")':""},handler=function(t,a,e){var s,r,n,i=e.target,o=e.client,p=Object.assign({indent:" ",withWrapper:!0},a),l=new CodeBuilder({indentation:p.indent,variablesPrefix:p.variablesPrefix,capitalize:!0,lang:Lang.JAVA}),u=!1;if(p.withComments&&addComments(l,t),p.withImports&&addImports(l,t),p.withWrapper&&(l.push("public class App {"),l.push(1,"public static void main(String[] args) throws Exception {"),l.push(2,"var httpClient = HttpClient.newBuilder().build();"),l.blank()),null===(s=t.securityOAuth2ExtraCalls)||void 0===s?void 0:s.length){var h=new HTTPSnippet(null===(r=t.securityOAuth2ExtraCalls)||void 0===r?void 0:r[0]).convert(i,o,__assign(__assign({},p),{withImports:!1,withWrapper:!1,withComments:!1,variablesPrefix:"oauth2"}));l.push(h),l.blank(),l.push(2,"var oauth2Response = httpClient.send(oauth2Request, HttpResponse.BodyHandlers.ofString());"),l.push(2,'var accessToken = new JSONObject(oauth2Response.body()).getString("access_token");'),l.blank()}if(t.postData)switch(normalizeMimeType(t.postData.mimeType)){case URL_ENCODED:t.postData.params&&(l.push(2,"HashMap<String, String> params = new HashMap<>();"),t.postData.params.forEach((function(t){l.push(2,'params.put("%s", "%s");',t.name,t.value)})),l.blank(),l.push(2,"var form = params.keySet().stream()"),l.push(3,'.map(key -> key + "=" + URLEncoder.encode(params.get(key), StandardCharsets.UTF_8))'),l.push(3,'.collect(Collectors.joining("&"));'),l.blank());break;case"application/json":t.postData.jsonObj&&(l.push(2,'var payload = String.join("\\n"\n '+addIndentation(JSON.stringify(t.postData.jsonObj,null,1).replace(/"/g,'\\"').replace(/^/gm,', "').replace(/$/gm,'"'),{level:3,indent:p.indent,firstLine:!1})),l.push(2,");"),l.blank());break;case"application/xml":t.postData.text&&(l.push(2,'var payload = String.join("\\n"'),t.postData.text.trim().split("\n").forEach((function(t){var a=t.replace(/"/g,'\\"');l.push(3,', "'+a+'"')})),l.push(2,");"),l.blank());break;case"multipart/form-data":u=!0,l.unshift("# multipart/form-data is not supported yet\n")}if(hasQueryParams(t)){l.push(2,"HashMap<String, String> params = new HashMap<>();");for(var d=0,m=Object.entries(t.uriObj.query);d<m.length;d++){var c=m[d],v=c[0],g=c[1];l.push(2,'params.put("%s", "%s");',v,g)}l.blank(),l.push(2,"var query = params.keySet().stream()"),l.push(3,'.map(key -> key + "=" + URLEncoder.encode(params.get(key), StandardCharsets.UTF_8))'),l.push(3,'.collect(Collectors.joining("&"));'),l.blank()}l.push(2,"var "+l.var("host")+' = "%s";',t.uriObj.protocol+"//"+t.uriObj.host),printUrlVariablesDeclarations(t,l,2);var
|
|
1
|
+
import{__assign}from"tslib";import{CodeBuilder}from"../../helpers/code-builder";import{HTTPSnippet}from"../..";import{normalizeMimeType}from"../../../../utils";import{addIndentation,buildUrlExpression,printUrlVariablesDeclarations}from"../../helpers/code-helpers";import{Lang}from"../../helpers/constants";var URL_ENCODED="application/x-www-form-urlencoded",hasQueryParams=function(t){return!(!t.uriObj.query||!Object.keys(t.uriObj.query).length)},getBody=function(t){return t.postData&&t.postData.mimeType===URL_ENCODED?"HttpRequest.BodyPublishers.ofString(form)":t.postData?"HttpRequest.BodyPublishers.ofString(payload)":["POST","PUT","PATCH"].includes(t.method.toUpperCase())?'HttpRequest.BodyPublishers.ofString("some body text")':""},handler=function(t,a,e){var s,r,n,i=e.target,o=e.client,p=Object.assign({indent:" ",withWrapper:!0},a),l=new CodeBuilder({indentation:p.indent,variablesPrefix:p.variablesPrefix,capitalize:!0,lang:Lang.JAVA}),u=!1;if(p.withComments&&addComments(l,t),p.withImports&&addImports(l,t),p.withWrapper&&(l.push("public class App {"),l.push(1,"public static void main(String[] args) throws Exception {"),l.push(2,"var httpClient = HttpClient.newBuilder().build();"),l.blank()),null===(s=t.securityOAuth2ExtraCalls)||void 0===s?void 0:s.length){var h=new HTTPSnippet(null===(r=t.securityOAuth2ExtraCalls)||void 0===r?void 0:r[0]).convert(i,o,__assign(__assign({},p),{withImports:!1,withWrapper:!1,withComments:!1,variablesPrefix:"oauth2"}));l.push(h),l.blank(),l.push(2,"var oauth2Response = httpClient.send(oauth2Request, HttpResponse.BodyHandlers.ofString());"),l.push(2,'var accessToken = new JSONObject(oauth2Response.body()).getString("access_token");'),l.blank()}if(t.postData)switch(normalizeMimeType(t.postData.mimeType)){case URL_ENCODED:t.postData.params&&(l.push(2,"HashMap<String, String> params = new HashMap<>();"),t.postData.params.forEach((function(t){l.push(2,'params.put("%s", "%s");',t.name,t.value)})),l.blank(),l.push(2,"var form = params.keySet().stream()"),l.push(3,'.map(key -> key + "=" + URLEncoder.encode(params.get(key), StandardCharsets.UTF_8))'),l.push(3,'.collect(Collectors.joining("&"));'),l.blank());break;case"application/json":t.postData.jsonObj&&(l.push(2,'var payload = String.join("\\n"\n '+addIndentation(JSON.stringify(t.postData.jsonObj,null,1).replace(/"/g,'\\"').replace(/^/gm,', "').replace(/$/gm,'"'),{level:3,indent:p.indent,firstLine:!1})),l.push(2,");"),l.blank());break;case"application/xml":t.postData.text&&(l.push(2,'var payload = String.join("\\n"'),t.postData.text.trim().split("\n").forEach((function(t){var a=t.replace(/"/g,'\\"');l.push(3,', "'+a+'"')})),l.push(2,");"),l.blank());break;case"multipart/form-data":u=!0,l.unshift("# multipart/form-data is not supported yet\n")}if(hasQueryParams(t)){l.push(2,"HashMap<String, String> params = new HashMap<>();");for(var d=0,m=Object.entries(t.uriObj.query);d<m.length;d++){var c=m[d],v=c[0],g=c[1];l.push(2,'params.put("%s", "%s");',v,g)}l.blank(),l.push(2,"var query = params.keySet().stream()"),l.push(3,'.map(key -> key + "=" + URLEncoder.encode(params.get(key), StandardCharsets.UTF_8))'),l.push(3,'.collect(Collectors.joining("&"));'),l.blank()}l.push(2,"var "+l.var("host")+' = "%s";',t.uriObj.protocol+"//"+t.uriObj.host),printUrlVariablesDeclarations(t,l,2);var b=__assign(__assign({},t),{pathname:t.uriObj.pathname});l.push(2,"var "+l.var("pathname")+" = %s;",buildUrlExpression(b,l)),l.push(2,"var "+l.var("request")+" = HttpRequest.newBuilder()"),"PATCH"===t.method.toUpperCase()?l.push(3,'.method("PATCH", %s)',getBody(t)):l.push(3,".%s(%s)",t.method.toUpperCase(),getBody(t)),l.push(3,".uri(URI.create("+l.var("host")+" + "+l.var("pathname")+" %s))",hasQueryParams(t)?"+ '?' + query":""),(null===(n=t.securityOAuth2ExtraCalls)||void 0===n?void 0:n.length)&&(t.allHeaders.Authorization='"Bearer " + accessToken');var y=Object.keys(t.allHeaders);if(y.length&&y.forEach((function(a){var e;l.push(3,'.header("%s", %s)',a,"Authorization"===a&&(null===(e=t.securityOAuth2ExtraCalls)||void 0===e?void 0:e.length)?t.allHeaders[a]:'"'+t.allHeaders[a]+'"')})),t.basicAuth){var f=t.basicAuth,C=f.username,j=f.password;l.push(3,'.header("Authorization", "Basic " + Base64.getEncoder().encodeToString(("'+C+":"+j+'").getBytes()))')}return l.push(3,".build();"),p.withWrapper&&(l.blank(),l.push(2,"var response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());"),l.blank(),l.push(2,"System.out.println(response.body());"),l.push(1,"}"),l.push("}")),u&&l.clean(),l.join()};export var info={key:"httpclient",title:"HttpClient",link:"https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpClient.html",description:"HttpClient (Java SE 11 & JDK 11 )"};export default handler;function addComments(t,a){var e;t.push("/**"),t.push(" * Requires JDK >= 11"),(null===(e=a.securityOAuth2ExtraCalls)||void 0===e?void 0:e.length)&&(t.push(" *"),t.push(' * Requires package "org.json" >= 20201115'),t.push(" * See here for installation details:"),t.push(" * https://search.maven.org/artifact/org.json/json")),t.push(" */"),t.blank()}function addImports(t,a){var e,s,r,n;t.push("import java.net.*;"),t.push("import java.net.http.*;"),t.push("import java.util.*;"),(normalizeMimeType(null===(e=a.postData)||void 0===e?void 0:e.mimeType)===URL_ENCODED&&(null===(s=a.postData)||void 0===s?void 0:s.params)||(null===(r=a.securityOAuth2ExtraCalls)||void 0===r?void 0:r.length)||hasQueryParams(a))&&(t.push("import java.nio.charset.StandardCharsets;"),t.push("import java.util.stream.Collectors;")),(null===(n=a.securityOAuth2ExtraCalls)||void 0===n?void 0:n.length)&&t.push("import org.json.JSONObject;"),t.blank()}
|
|
2
2
|
//# sourceMappingURL=httpclient.js.map
|