@redocly/reference-docs 2.25.0 → 2.25.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 +76 -76
- package/bin/cli/commands/redocly-docs-cli.min.js.LICENSE.txt +1 -1
- package/dist/console.redocly-reference-docs.min.js +112 -112
- package/dist/oauth2-redirect.js +1 -1
- package/dist/redocly-reference-docs.min.js +851 -851
- package/lib/components/console/CodemirrorInput.js +1 -1
- package/lib/components/console/RequestBody.js +1 -1
- package/lib/components/console/RequestBodyForm.js +1 -1
- package/lib/models/file-upload.d.ts +0 -5
- package/lib/models/file-upload.js +1 -1
- package/lib/redoc-lib/src/services/RedocNormalizedOptions.d.ts +1 -1
- package/lib/redoc-lib/src/services/RedocNormalizedOptions.js +1 -1
- package/lib/redoc-lib/src/services/models/ApiInfo.js +1 -1
- package/lib/redoc-lib/src/utils/openapi.js +1 -1
- package/lib/services/ProStore.js +1 -1
- package/lib/services/code-samples/generator.js +1 -1
- package/lib/services/code-samples/httpsnippet/index.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/r/httr.js +1 -1
- package/lib/services/code-samples/httpsnippet/targets/ruby/native.js +1 -1
- package/lib/services/code-samples/httpsnippet/targets/shell/curl.js +1 -1
- package/lib/types.d.ts +14 -0
- package/lib/types.js +2 -0
- package/lib/utils.d.ts +1 -0
- package/lib/utils.js +1 -1
- package/lib-esm/components/console/CodemirrorInput.js +1 -1
- package/lib-esm/components/console/RequestBody.js +1 -1
- package/lib-esm/components/console/RequestBodyForm.js +1 -1
- package/lib-esm/models/file-upload.d.ts +0 -5
- package/lib-esm/models/file-upload.js +1 -1
- package/lib-esm/redoc-lib/src/services/RedocNormalizedOptions.d.ts +1 -1
- package/lib-esm/redoc-lib/src/services/RedocNormalizedOptions.js +1 -1
- package/lib-esm/redoc-lib/src/services/models/ApiInfo.js +1 -1
- package/lib-esm/redoc-lib/src/utils/openapi.js +1 -1
- package/lib-esm/services/ProStore.js +1 -1
- package/lib-esm/services/code-samples/generator.js +1 -1
- package/lib-esm/services/code-samples/httpsnippet/index.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/r/httr.js +1 -1
- package/lib-esm/services/code-samples/httpsnippet/targets/ruby/native.js +1 -1
- package/lib-esm/services/code-samples/httpsnippet/targets/shell/curl.js +1 -1
- package/lib-esm/types.d.ts +14 -0
- package/lib-esm/types.js +2 -0
- package/lib-esm/utils.d.ts +1 -0
- package/lib-esm/utils.js +1 -1
- package/package.json +2 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CodemirrorInput=void 0;var tslib_1=require("tslib"),React=(0,tslib_1.__importStar)(require("react")),informed_1=require("informed"),react_codemirror2_react_17_1=require("react-codemirror2-react-17"),redoc_lib_1=require("../../redoc-lib");require("./codemirror-helpers");var templateObject_1,CodeMirrorStyles=(0,redoc_lib_1.createGlobalStyle)(templateObject_1||(templateObject_1=(0,tslib_1.__makeTemplateObject)(["\n .cm-s-material.CodeMirror {\n background-color: ","!important;\n color: ","!important;\n font-family: ",";\n line-height: 18px;\n padding: 10px;\n }\n\n .CodeMirror-lint-mark-error {\n background-size: 4px;\n background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAGCAYAAAD+Bd/7AAAAVUlEQVR42mNgQAL/GRjigPg/EP8FYntkCX4gtoVKgvE/BoabcEVAhj6S5DUgfgFl/wFJ2gPxL6iuT1DF+kD2R5AYA5KRj6CS/FAMYvszIBltz4AFAAD9fz0YtLg13wAAAABJRU5ErkJggg==') !important;\n }\n\n .cm-s-material.CodeMirror-focused div.CodeMirror-selected {\n background: rgba(255, 255, 255, 0.3) !important;\n }\n\n .cm-s-material .CodeMirror-code .cm-string.cm-property {\n color: #9EFAA7;\n }\n\n .cm-s-material .CodeMirror-code .cm-string {\n color: #FEE39E;\n }\n\n .cm-s-material .CodeMirror-code .cm-atom {\n color: ",";\n }\n\n div .cm-s-material .CodeMirror-matchingbracket {\n outline: 1px solid grey;\n text-decoration: none;\n }\n\n .react-codemirror2 {\n display: flex;\n flex-direction: column;\n justify-content: flex-start;\n overflow: hidden;\n\n flex: 1;\n }\n\n .CodeMirror {\n flex: 1;\n border-radius: ",";\n }\n"],["\n .cm-s-material.CodeMirror {\n background-color: ","!important;\n color: ","!important;\n font-family: ",";\n line-height: 18px;\n padding: 10px;\n }\n\n .CodeMirror-lint-mark-error {\n background-size: 4px;\n background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAGCAYAAAD+Bd/7AAAAVUlEQVR42mNgQAL/GRjigPg/EP8FYntkCX4gtoVKgvE/BoabcEVAhj6S5DUgfgFl/wFJ2gPxL6iuT1DF+kD2R5AYA5KRj6CS/FAMYvszIBltz4AFAAD9fz0YtLg13wAAAABJRU5ErkJggg==') !important;\n }\n\n .cm-s-material.CodeMirror-focused div.CodeMirror-selected {\n background: rgba(255, 255, 255, 0.3) !important;\n }\n\n .cm-s-material .CodeMirror-code .cm-string.cm-property {\n color: #9EFAA7;\n }\n\n .cm-s-material .CodeMirror-code .cm-string {\n color: #FEE39E;\n }\n\n .cm-s-material .CodeMirror-code .cm-atom {\n color: ",";\n }\n\n div .cm-s-material .CodeMirror-matchingbracket {\n outline: 1px solid grey;\n text-decoration: none;\n }\n\n .react-codemirror2 {\n display: flex;\n flex-direction: column;\n justify-content: flex-start;\n overflow: hidden;\n\n flex: 1;\n }\n\n .CodeMirror {\n flex: 1;\n border-radius: ",";\n }\n"])),(function(e){return e.theme.rightPanel.panelControlsBackgroundColor}),(function(e){return e.theme.colors.text.light}),(function(e){return e.theme.typography.code.fontFamily}),(function(e){return e.theme.colors.text.light}),(function(e){return e.theme.components.panels.borderRadius})),CodemirrorInput=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return Object.defineProperty(r,"editor",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"_onKeyUp",{enumerable:!0,configurable:!0,writable:!0,value:function(e,t){/^[a-zA-Z0-9_":]$/.test(t.key)&&r.editor.execCommand("autocomplete")}}),Object.defineProperty(r,"initEditor",{enumerable:!0,configurable:!0,writable:!0,value:function(e){r.editor=e,e.on("keyup",r._onKeyUp)}}),Object.defineProperty(r,"refreshEditor",{enumerable:!0,configurable:!0,writable:!0,value:function(){r.editor.refresh()}}),r}return(0,tslib_1.__extends)(r,e),Object.defineProperty(r.prototype,"componentDidMount",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;setTimeout((function(){e.editor.refresh()}),0),document.addEventListener("click",this.refreshEditor)}}),Object.defineProperty(r.prototype,"componentWillUnmount",{enumerable:!1,configurable:!0,writable:!0,value:function(){document.removeEventListener("click",this.refreshEditor)}}),Object.defineProperty(r.prototype,"render",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this,r=this.props.fieldState.value,t=this.props.fieldApi,n=t.setValue,o=t.setTouched,i=t.setError,a=this.props,c=a.onChange,l=a.onBlur,d=a.forwardedRef;return React.createElement(React.Fragment,null,React.createElement(CodeMirrorStyles,null),React.createElement(react_codemirror2_react_17_1.Controlled,{editorDidMount:this.initEditor,value:r||"",ref:d||void 0,onBeforeChange:function(e,r,t){n(t),c&&c(t)},onBlur:function(e){o(),l&&l(e)},options:{mode:this.props.mode||
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CodemirrorInput=void 0;var tslib_1=require("tslib"),React=(0,tslib_1.__importStar)(require("react")),informed_1=require("informed"),react_codemirror2_react_17_1=require("react-codemirror2-react-17"),redoc_lib_1=require("../../redoc-lib");require("./codemirror-helpers");var templateObject_1,types_1=require("../../types"),CodeMirrorStyles=(0,redoc_lib_1.createGlobalStyle)(templateObject_1||(templateObject_1=(0,tslib_1.__makeTemplateObject)(["\n .cm-s-material.CodeMirror {\n background-color: ","!important;\n color: ","!important;\n font-family: ",";\n line-height: 18px;\n padding: 10px;\n }\n\n .CodeMirror-lint-mark-error {\n background-size: 4px;\n background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAGCAYAAAD+Bd/7AAAAVUlEQVR42mNgQAL/GRjigPg/EP8FYntkCX4gtoVKgvE/BoabcEVAhj6S5DUgfgFl/wFJ2gPxL6iuT1DF+kD2R5AYA5KRj6CS/FAMYvszIBltz4AFAAD9fz0YtLg13wAAAABJRU5ErkJggg==') !important;\n }\n\n .cm-s-material.CodeMirror-focused div.CodeMirror-selected {\n background: rgba(255, 255, 255, 0.3) !important;\n }\n\n .cm-s-material .CodeMirror-code .cm-string.cm-property {\n color: #9EFAA7;\n }\n\n .cm-s-material .CodeMirror-code .cm-string {\n color: #FEE39E;\n }\n\n .cm-s-material .CodeMirror-code .cm-atom {\n color: ",";\n }\n\n div .cm-s-material .CodeMirror-matchingbracket {\n outline: 1px solid grey;\n text-decoration: none;\n }\n\n .react-codemirror2 {\n display: flex;\n flex-direction: column;\n justify-content: flex-start;\n overflow: hidden;\n\n flex: 1;\n }\n\n .CodeMirror {\n flex: 1;\n border-radius: ",";\n }\n"],["\n .cm-s-material.CodeMirror {\n background-color: ","!important;\n color: ","!important;\n font-family: ",";\n line-height: 18px;\n padding: 10px;\n }\n\n .CodeMirror-lint-mark-error {\n background-size: 4px;\n background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAGCAYAAAD+Bd/7AAAAVUlEQVR42mNgQAL/GRjigPg/EP8FYntkCX4gtoVKgvE/BoabcEVAhj6S5DUgfgFl/wFJ2gPxL6iuT1DF+kD2R5AYA5KRj6CS/FAMYvszIBltz4AFAAD9fz0YtLg13wAAAABJRU5ErkJggg==') !important;\n }\n\n .cm-s-material.CodeMirror-focused div.CodeMirror-selected {\n background: rgba(255, 255, 255, 0.3) !important;\n }\n\n .cm-s-material .CodeMirror-code .cm-string.cm-property {\n color: #9EFAA7;\n }\n\n .cm-s-material .CodeMirror-code .cm-string {\n color: #FEE39E;\n }\n\n .cm-s-material .CodeMirror-code .cm-atom {\n color: ",";\n }\n\n div .cm-s-material .CodeMirror-matchingbracket {\n outline: 1px solid grey;\n text-decoration: none;\n }\n\n .react-codemirror2 {\n display: flex;\n flex-direction: column;\n justify-content: flex-start;\n overflow: hidden;\n\n flex: 1;\n }\n\n .CodeMirror {\n flex: 1;\n border-radius: ",";\n }\n"])),(function(e){return e.theme.rightPanel.panelControlsBackgroundColor}),(function(e){return e.theme.colors.text.light}),(function(e){return e.theme.typography.code.fontFamily}),(function(e){return e.theme.colors.text.light}),(function(e){return e.theme.components.panels.borderRadius})),CodemirrorInput=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return Object.defineProperty(r,"editor",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"_onKeyUp",{enumerable:!0,configurable:!0,writable:!0,value:function(e,t){/^[a-zA-Z0-9_":]$/.test(t.key)&&r.editor.execCommand("autocomplete")}}),Object.defineProperty(r,"initEditor",{enumerable:!0,configurable:!0,writable:!0,value:function(e){r.editor=e,e.on("keyup",r._onKeyUp)}}),Object.defineProperty(r,"refreshEditor",{enumerable:!0,configurable:!0,writable:!0,value:function(){r.editor.refresh()}}),r}return(0,tslib_1.__extends)(r,e),Object.defineProperty(r.prototype,"componentDidMount",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;setTimeout((function(){e.editor.refresh()}),0),document.addEventListener("click",this.refreshEditor)}}),Object.defineProperty(r.prototype,"componentWillUnmount",{enumerable:!1,configurable:!0,writable:!0,value:function(){document.removeEventListener("click",this.refreshEditor)}}),Object.defineProperty(r.prototype,"render",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this,r=this.props.fieldState.value,t=this.props.fieldApi,n=t.setValue,o=t.setTouched,i=t.setError,a=this.props,c=a.onChange,l=a.onBlur,d=a.forwardedRef;return React.createElement(React.Fragment,null,React.createElement(CodeMirrorStyles,null),React.createElement(react_codemirror2_react_17_1.Controlled,{editorDidMount:this.initEditor,value:r||"",ref:d||void 0,onBeforeChange:function(e,r,t){n(t),c&&c(t)},onBlur:function(e){o(),l&&l(e)},options:{mode:this.props.mode||types_1.MediaTypes.JSON,theme:"material",matchBrackets:!0,autoCloseBrackets:!0,tabSize:2,foldGutter:!0,extraKeys:{"Cmd-Space":function(){return e.editor.showHint({completeSingle:!0})},"Ctrl-Space":function(){return e.editor.showHint({completeSingle:!0})}},hintOptions:{id:this.props.id,completeSingle:!1,schema:this.props.schema},lint:{id:this.props.id,schema:this.props.schema,setError:i}}}))}}),r}(React.Component);exports.CodemirrorInput=CodemirrorInput,exports.default=(0,informed_1.asField)(CodemirrorInput);
|
|
2
2
|
//# sourceMappingURL=CodemirrorInput.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var _this=this;Object.defineProperty(exports,"__esModule",{value:!0}),exports.RequestBody=void 0;var tslib_1=require("tslib"),React=(0,tslib_1.__importStar)(require("react")),react_1=require("react"),mobx_react_1=require("mobx-react"),deepmerge_1=(0,tslib_1.__importDefault)(require("deepmerge")),redoc_lib_1=require("../../redoc-lib"),Samples_1=require("../Samples"),utils_1=require("../../services/utils"),helper_1=require("../common/FileUpload/helper"),
|
|
1
|
+
"use strict";var _this=this;Object.defineProperty(exports,"__esModule",{value:!0}),exports.RequestBody=void 0;var tslib_1=require("tslib"),React=(0,tslib_1.__importStar)(require("react")),react_1=require("react"),mobx_react_1=require("mobx-react"),deepmerge_1=(0,tslib_1.__importDefault)(require("deepmerge")),redoc_lib_1=require("../../redoc-lib"),Samples_1=require("../Samples"),utils_1=require("../../services/utils"),helper_1=require("../common/FileUpload/helper"),types_1=require("../../types"),Dropdown_1=require("../common/Dropdown"),RequestBodyForm_1=require("./RequestBodyForm"),RequestMimeLabel_1=require("./RequestMimeLabel"),CodemirrorInput_1=(0,tslib_1.__importDefault)(require("./CodemirrorInput")),RequestBodyComponent=(0,mobx_react_1.observer)((function(e){var r,t=e.body.content,a=e.console.formApi,i=function(r){var a;if(!t||!t.hasSample)return"";var i=null===(a=t.active)||void 0===a?void 0:a.examples;if(!(null==i?void 0:i[r]))return"";var o=null==i?void 0:i[r].value,l=e.properties?(0,deepmerge_1.default)(o,e.properties,{arrayMerge:utils_1.arrayMergeStrategy}):o;return JSON.stringify(l,null,2)},o=null===(r=null==t?void 0:t.operation)||void 0===r?void 0:r.activeExampleName,l=function(e){var r;null===(r=null==t?void 0:t.operation)||void 0===r||r.activateExampleName(e),a.setValue("body",i(e))},n=function(r){if(!r)return"";if(r.mime===types_1.MediaTypes.URL_ENCODED)return r.value;var t=r.value,a=e.properties?(0,deepmerge_1.default)(t,e.properties,{arrayMerge:utils_1.arrayMergeStrategy}):t;return JSON.stringify(a,null,2)},u=function(e,r){return(0,tslib_1.__awaiter)(void 0,void 0,void 0,(function(){return(0,tslib_1.__generator)(this,(function(t){return(0,a.setValue)("body."+e,r),[2]}))}))};(0,react_1.useEffect)((function(){!1!==o?o&&a.setValue("body",i(o)):a.setValue("body",JSON.stringify(e.properties||{},null,2))}),[o]);var s=e.validate,d=e.body;return React.createElement(React.Fragment,null,React.createElement(redoc_lib_1.MediaTypesSwitch,{content:d.content,renderDropdown:function(e){return React.createElement(redoc_lib_1.DropdownOrLabel,(0,tslib_1.__assign)({},e,{variant:"dark",fullWidth:!0,Label:RequestMimeLabel_1.RequestMimeLabel,Dropdown:Dropdown_1.Dropdown}))}},(function(r){var t,i=r.examples||{},o=Object.keys(i),d=r.schema,m=(0,helper_1.isRootFileUpload)(d||{},r.name)||r.name===types_1.MediaTypes.MULTIPART||r.name===types_1.MediaTypes.URL_ENCODED,p=(0,Samples_1.useExampleKey)(r.operation,i).exampleKey,_=i[p];return React.createElement(React.Fragment,null,o.length&&1!==o.length&&React.createElement(Samples_1.ExampleSwitch,{examples:i,onChange:l,exampleKey:p})||null,m?React.createElement(RequestBodyForm_1.RequestBodyForm,{mediaType:r,formApi:a,onChange:u.bind(_this)}):React.createElement(CodemirrorInput_1.default,{id:"body"+e.id,field:"body",initialValue:n(_),schema:((null===(t=null==e?void 0:e.resolvedBody)||void 0===t?void 0:t.content[r.name])||{}).schema,mode:r.name,validate:s}))})))}));exports.RequestBody=React.memo(RequestBodyComponent);
|
|
2
2
|
//# sourceMappingURL=RequestBody.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getRequestBodyFormFields=exports.RequestBodyForm=void 0;var tslib_1=require("tslib"),react_1=(0,tslib_1.__importStar)(require("react")),mobx_react_1=require("mobx-react"),helper_1=require("../common/FileUpload/helper"),form_1=require("../common/form"),redoc_lib_1=require("../../redoc-lib"),FileUpload_1=require("../common/FileUpload"),TextField_1=require("../common/TextField"),models_1=require("../../models"),Samples_1=require("../Samples");function getRequestBodyFormFields(e){var t,l,r,o,a;return((null===(l=null===(t=e.schema)||void 0===t?void 0:t.oneOf)||void 0===l?void 0:l.length)?(null===(r=e.schema)||void 0===r?void 0:r.oneOf[null===(o=e.schema)||void 0===o?void 0:o.activeOneOf].fields)||[]:(null===(a=e.schema)||void 0===a?void 0:a.fields)||[]).filter((function(e){return!e.schema.readOnly}))}exports.RequestBodyForm=(0,mobx_react_1.observer)((function(e){var t,l=e.mediaType,r=e.onChange,o=e.formApi,a=l.examples||{},n=(0,Samples_1.useExampleKey)(l.operation,a).exampleKey,i=null===(t=a[n])||void 0===t?void 0:t.rawValue,m=getRequestBodyFormFields(l);(0,react_1.useEffect)((function(){return o&&m.forEach((function(e){var t,l,r=null==i?void 0:i[e.name],a=null!==(l=null!==(t=e.example)&&void 0!==t?t:null==r?void 0:r.example)&&void 0!==l?l:r,n="object"==typeof a?JSON.stringify(a):a;void 0!==a&&o.setValue("body."+e.name,""+n)}))}),[n]);var d=l.schema||{};return(0,helper_1.isRootFileUpload)(d,l.name)?react_1.default.createElement(FileFormControlWrapper,null,react_1.default.createElement(form_1.FormControl,null,react_1.default.createElement(StyledFileUpload,{fullWidth:!0,id:"body."+l.name,name:"body."+l.name,accept:(0,helper_1.mimeTypeToAccept)(l.name),schema:d,contentName:l.name,onChange:r}))):d.type===models_1.DefinitionTypes.OBJECT||m?react_1.default.createElement(FileFormControlWrapper,null,m.map((function(e){var t=e.schema||{},o=l.name===
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getRequestBodyFormFields=exports.RequestBodyForm=void 0;var tslib_1=require("tslib"),react_1=(0,tslib_1.__importStar)(require("react")),mobx_react_1=require("mobx-react"),helper_1=require("../common/FileUpload/helper"),form_1=require("../common/form"),redoc_lib_1=require("../../redoc-lib"),FileUpload_1=require("../common/FileUpload"),TextField_1=require("../common/TextField"),models_1=require("../../models"),types_1=require("../../types"),Samples_1=require("../Samples");function getRequestBodyFormFields(e){var t,l,r,o,a;return((null===(l=null===(t=e.schema)||void 0===t?void 0:t.oneOf)||void 0===l?void 0:l.length)?(null===(r=e.schema)||void 0===r?void 0:r.oneOf[null===(o=e.schema)||void 0===o?void 0:o.activeOneOf].fields)||[]:(null===(a=e.schema)||void 0===a?void 0:a.fields)||[]).filter((function(e){return!e.schema.readOnly}))}exports.RequestBodyForm=(0,mobx_react_1.observer)((function(e){var t,l=e.mediaType,r=e.onChange,o=e.formApi,a=l.examples||{},n=(0,Samples_1.useExampleKey)(l.operation,a).exampleKey,i=null===(t=a[n])||void 0===t?void 0:t.rawValue,m=getRequestBodyFormFields(l);(0,react_1.useEffect)((function(){return o&&m.forEach((function(e){var t,l,r=null==i?void 0:i[e.name],a=null!==(l=null!==(t=e.example)&&void 0!==t?t:null==r?void 0:r.example)&&void 0!==l?l:r,n="object"==typeof a?JSON.stringify(a):a;void 0!==a&&o.setValue("body."+e.name,""+n)}))}),[n]);var d=l.schema||{};return(0,helper_1.isRootFileUpload)(d,l.name)?react_1.default.createElement(FileFormControlWrapper,null,react_1.default.createElement(form_1.FormControl,null,react_1.default.createElement(StyledFileUpload,{fullWidth:!0,id:"body."+l.name,name:"body."+l.name,accept:(0,helper_1.mimeTypeToAccept)(l.name),schema:d,contentName:l.name,onChange:r}))):d.type===models_1.DefinitionTypes.OBJECT||m?react_1.default.createElement(FileFormControlWrapper,null,m.map((function(e){var t=e.schema||{},o=l.name===types_1.MediaTypes.MULTIPART&&(0,helper_1.isMultipartFileUploadProperty)(t),a=t.contentMediaType||"",n=o?react_1.default.createElement(StyledFileUpload,{fullWidth:!0,id:"body."+e.name,name:"body."+e.name,accept:(0,helper_1.mimeTypeToAccept)(a),multiple:"array"===t.type,schema:t,contentName:e.name,onChange:r}):react_1.default.createElement(TextField_1.FormTextField,{fullWidth:!0,id:"body."+e.name,field:"body."+e.name,placeholder:t.description||e.name});return react_1.default.createElement(form_1.FormControl,{key:e.name},react_1.default.createElement(form_1.FormLabel,null,e.name,":"),n)}))):(console.warn('Invalid schema for request body and mime type: "'+l.name+'"',d),null)})),exports.getRequestBodyFormFields=getRequestBodyFormFields;var templateObject_1,templateObject_2,FileFormControlWrapper=redoc_lib_1.styled.div(templateObject_1||(templateObject_1=(0,tslib_1.__makeTemplateObject)(["\n > div {\n margin-top: 10px;\n }\n"],["\n > div {\n margin-top: 10px;\n }\n"]))),StyledFileUpload=(0,redoc_lib_1.styled)(FileUpload_1.FileUpload)(templateObject_2||(templateObject_2=(0,tslib_1.__makeTemplateObject)(["\n ","\n ",";\n ","\n"],["\n ","\n ",";\n ","\n"])),TextField_1.invertedInputStyles,(function(e){return"password"===e.inputType?"padding-right: 40px;":""}),(function(e){return e.fullWidth?"width: 100%;":""}));
|
|
2
2
|
//# sourceMappingURL=RequestBodyForm.js.map
|
|
@@ -8,9 +8,4 @@ export declare enum FileUploadFormats {
|
|
|
8
8
|
BASE64 = "base64",
|
|
9
9
|
BINARY = "binary"
|
|
10
10
|
}
|
|
11
|
-
export declare enum MediaTypes {
|
|
12
|
-
OCTET_STREAM = "application/octet-stream",
|
|
13
|
-
MULTIPART = "multipart/form-data",
|
|
14
|
-
URL_ENCODED = "application/x-www-form-urlencoded"
|
|
15
|
-
}
|
|
16
11
|
export declare type UploadFileType = File | File[] | string | string[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var DefinitionTypes,FileUploadFormats
|
|
1
|
+
"use strict";var DefinitionTypes,FileUploadFormats;Object.defineProperty(exports,"__esModule",{value:!0}),exports.FileUploadFormats=exports.DefinitionTypes=void 0,function(e){e.STRING="string",e.ARRAY="array",e.OBJECT="object"}(DefinitionTypes=exports.DefinitionTypes||(exports.DefinitionTypes={})),function(e){e.BYTE="byte",e.BASE64="base64",e.BINARY="binary"}(FileUploadFormats=exports.FileUploadFormats||(exports.FileUploadFormats={}));
|
|
2
2
|
//# sourceMappingURL=file-upload.js.map
|
|
@@ -28,7 +28,7 @@ export interface HookRawHtml {
|
|
|
28
28
|
}
|
|
29
29
|
declare type HookResult = JSX.Element | HookRawHtml | null;
|
|
30
30
|
export declare type HookConfig<T> = (props: T) => HookResult;
|
|
31
|
-
interface HooksConfig {
|
|
31
|
+
export interface HooksConfig {
|
|
32
32
|
BeforeOperation?: HookConfig<{
|
|
33
33
|
operation: OperationModel;
|
|
34
34
|
}>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.RedocNormalizedOptions=void 0;var tslib_1=require("tslib"),mobx_1=require("mobx"),theme_1=(0,tslib_1.__importStar)(require("../theme")),utils_1=require("../utils"),Labels_1=require("./Labels"),RedocNormalizedOptions=function(){function e(a,i){var t,l,r,o,n,s;void 0===i&&(i={}),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,"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,"downloadDefinitionUrl",{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,"hideSecuritySection",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"showSecuritySchemeType",{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,"expandDefaultRequest",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"expandDefaultResponse",{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}),Object.defineProperty(this,"hideOneOfDescription",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"hideFab",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"schemaDefinitionsTagName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"minCharacterLengthToInitSearch",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"maxResponseHeadersToShowInTryIt",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"showWebhookVerb",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"showObjectSchemaExamples",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"disableTryItRequestUrlEncoding",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),(0,mobx_1.makeObservable)(this);var u=null===(t=(a=(0,tslib_1.__assign)((0,tslib_1.__assign)({},i),a)).theme)||void 0===t?void 0:t.extensionsHook;(null===(l=a.theme)||void 0===l?void 0:l.menu)&&!(null===(r=a.theme)||void 0===r?void 0:r.sidebar)&&(console.warn('Theme setting "menu" is deprecated. Rename to "sidebar"'),a.theme.sidebar=a.theme.menu),(null===(o=a.theme)||void 0===o?void 0:o.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=(0,theme_1.resolveTheme)((0,utils_1.mergeObjects)({},theme_1.default,(0,tslib_1.__assign)((0,tslib_1.__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 h=d[b],c=h[0],m=h[1];this.theme.mediaQueries[c]="@media screen and (min-width: "+m+")"}this.theme.extensionsHook=u,(0,Labels_1.setRedocLabels)(a.labels),this.scrollYOffset=e.normalizeScrollYOffset(a.scrollYOffset),this.hideHostname=e.normalizeHideHostname(a.hideHostname),this.expandResponses=e.normalizeExpandResponses(a.expandResponses),this.requiredPropsFirst=(0,utils_1.argValueToBoolean)(a.requiredPropsFirst),this.sortPropsAlphabetically=(0,utils_1.argValueToBoolean)(a.sortPropsAlphabetically),this.sortEnumValuesAlphabetically=(0,utils_1.argValueToBoolean)(a.sortEnumValuesAlphabetically),this.sortOperationsAlphabetically=(0,utils_1.argValueToBoolean)(a.sortOperationsAlphabetically),this.sortTagsAlphabetically=(0,utils_1.argValueToBoolean)(a.sortTagsAlphabetically),this.nativeScrollbars=(0,utils_1.argValueToBoolean)(a.nativeScrollbars),this.pathInMiddlePanel=(0,utils_1.argValueToBoolean)(a.pathInMiddlePanel),this.untrustedDefinition=(0,utils_1.argValueToBoolean)(a.untrustedDefinition),this.hideDownloadButton=void 0===a.hideDownloadButton?null:(0,utils_1.argValueToBoolean)(a.hideDownloadButton),this.downloadDefinitionUrl=a.downloadDefinitionUrl,this.hideInfoDescription=(0,utils_1.argValueToBoolean)(a.hideInfoDescription),this.disableSearch=(0,utils_1.argValueToBoolean)(a.disableSearch),this.onlyRequiredInSamples=(0,utils_1.argValueToBoolean)(a.onlyRequiredInSamples),this.generatedPayloadSamplesMaxDepth=(0,utils_1.argValueToInt)(a.generatedPayloadSamplesMaxDepth)||8,this.sendXUserAgentInTryIt=(0,utils_1.argValueToBoolean)(a.sendXUserAgentInTryIt),this.showExtensions=e.normalizeShowExtensions(a.showExtensions),this.hideSingleRequestSampleTab=(0,utils_1.argValueToBoolean)(a.hideSingleRequestSampleTab),this.hideRequestPayloadSample=(0,utils_1.argValueToBoolean)(a.hideRequestPayloadSample),this.menuToggle=(0,utils_1.argValueToBoolean)(a.menuToggle,!0),this.jsonSampleExpandLevel=(0,utils_1.argValueToExpandLevel)(a.jsonSampleExpandLevel,2),this.enumSkipQuotes=(0,utils_1.argValueToBoolean)(a.enumSkipQuotes),this.hideSchemaTitles=(0,utils_1.argValueToBoolean)(a.hideSchemaTitles),this.hideSecuritySection=(0,utils_1.argValueToBoolean)(a.hideSecuritySection),this.showSecuritySchemeType=(0,utils_1.argValueToBoolean)(a.showSecuritySchemeType),this.simpleOneOfTypeLabel=(0,utils_1.argValueToBoolean)(a.simpleOneOfTypeLabel),this.payloadSampleIdx=e.normalizePayloadSampleIdx(a.payloadSampleIdx),this.expandSingleSchemaField=(0,utils_1.argValueToBoolean)(a.expandSingleSchemaField),this.schemaExpansionLevel=(0,utils_1.argValueToExpandLevel)(a.schemaExpansionLevel),this.samplesTabsMaxCount=(0,utils_1.argValueToInt)(a.samplesTabsMaxCount)||5,this.unstable_tryItButtonOverride=a.unstable_tryItButtonOverride||null,this.unstable_ignoreMimeParameters=(0,utils_1.argValueToBoolean)(a.unstable_ignoreMimeParameters),this.allowedMdComponents=a.allowedMdComponents||{},this.expandDefaultServerVariables=(0,utils_1.argValueToBoolean)(a.expandDefaultServerVariables),this.expandDefaultRequest=(0,utils_1.argValueToBoolean)(a.expandDefaultRequest,!0),this.expandDefaultResponse=(0,utils_1.argValueToBoolean)(a.expandDefaultResponse,!0),this.maxDisplayedEnumValues=(0,utils_1.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=(0,utils_1.argValueToBoolean)(a.hideSchemaPattern),this.hideOneOfDescription=(0,utils_1.argValueToBoolean)(a.hideOneOfDescription),this.hideFab=(0,utils_1.argValueToBoolean)(a.hideFab),this.schemaDefinitionsTagName=a.schemaDefinitionsTagName,this.minCharacterLengthToInitSearch=(0,utils_1.argValueToNumber)(a.minCharacterLengthToInitSearch)||3,this.maxResponseHeadersToShowInTryIt=(0,utils_1.argValueToNumber)(a.maxResponseHeadersToShowInTryIt)||0,this.showWebhookVerb=(0,utils_1.argValueToBoolean)(a.showWebhookVerb),this.showObjectSchemaExamples=(0,utils_1.argValueToBoolean)(a.showObjectSchemaExamples),this.disableTryItRequestUrlEncoding=(0,utils_1.argValueToBoolean)(a.disableTryItRequestUrlEncoding,!1)}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&&!(0,utils_1.isNumeric)(e)){var a=(0,utils_1.querySelector)(e);a||console.warn("scrollYOffset value is a selector to non-existing element. Using offset 0 by default");var i=a&&a.getBoundingClientRect().bottom||0;return function(){return i}}return"number"==typeof e||(0,utils_1.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}}),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"showConsole",void 0),e}();exports.RedocNormalizedOptions=RedocNormalizedOptions;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.RedocNormalizedOptions=void 0;var tslib_1=require("tslib"),mobx_1=require("mobx"),theme_1=(0,tslib_1.__importStar)(require("../theme")),utils_1=require("../utils"),utils_2=require("../../../utils"),types_1=require("../../../types"),Labels_1=require("./Labels"),RedocNormalizedOptions=function(){function e(a,i){var t,l,r,o,n,s;void 0===i&&(i={}),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,"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,"downloadDefinitionUrl",{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,"hideSecuritySection",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"showSecuritySchemeType",{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,"expandDefaultRequest",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"expandDefaultResponse",{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}),Object.defineProperty(this,"hideOneOfDescription",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"hideFab",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"schemaDefinitionsTagName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"minCharacterLengthToInitSearch",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"maxResponseHeadersToShowInTryIt",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"showWebhookVerb",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"showObjectSchemaExamples",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"disableTryItRequestUrlEncoding",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),(0,mobx_1.makeObservable)(this);var u=null===(t=(a=(0,tslib_1.__assign)((0,tslib_1.__assign)({},i),a)).theme)||void 0===t?void 0:t.extensionsHook;(null===(l=a.theme)||void 0===l?void 0:l.menu)&&!(null===(r=a.theme)||void 0===r?void 0:r.sidebar)&&(console.warn('Theme setting "menu" is deprecated. Rename to "sidebar"'),a.theme.sidebar=a.theme.menu),(null===(o=a.theme)||void 0===o?void 0:o.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=(0,theme_1.resolveTheme)((0,utils_1.mergeObjects)({},theme_1.default,(0,tslib_1.__assign)((0,tslib_1.__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 h=d[b],c=h[0],m=h[1];this.theme.mediaQueries[c]="@media screen and (min-width: "+m+")"}this.theme.extensionsHook=u,(0,Labels_1.setRedocLabels)(a.labels),this.scrollYOffset=e.normalizeScrollYOffset(a.scrollYOffset),this.hideHostname=e.normalizeHideHostname(a.hideHostname),this.expandResponses=e.normalizeExpandResponses(a.expandResponses),this.requiredPropsFirst=(0,utils_1.argValueToBoolean)(a.requiredPropsFirst),this.sortPropsAlphabetically=(0,utils_1.argValueToBoolean)(a.sortPropsAlphabetically),this.sortEnumValuesAlphabetically=(0,utils_1.argValueToBoolean)(a.sortEnumValuesAlphabetically),this.sortOperationsAlphabetically=(0,utils_1.argValueToBoolean)(a.sortOperationsAlphabetically),this.sortTagsAlphabetically=(0,utils_1.argValueToBoolean)(a.sortTagsAlphabetically),this.nativeScrollbars=(0,utils_1.argValueToBoolean)(a.nativeScrollbars),this.pathInMiddlePanel=(0,utils_1.argValueToBoolean)(a.pathInMiddlePanel),this.untrustedDefinition=(0,utils_1.argValueToBoolean)(a.untrustedDefinition),this.hideDownloadButton=void 0===a.hideDownloadButton?null:(0,utils_1.argValueToBoolean)(a.hideDownloadButton),this.downloadDefinitionUrl=a.downloadDefinitionUrl,this.hideInfoDescription=(0,utils_1.argValueToBoolean)(a.hideInfoDescription),this.disableSearch=(0,utils_1.argValueToBoolean)(a.disableSearch),this.onlyRequiredInSamples=(0,utils_1.argValueToBoolean)(a.onlyRequiredInSamples),this.generatedPayloadSamplesMaxDepth=(0,utils_1.argValueToInt)(a.generatedPayloadSamplesMaxDepth)||8,this.sendXUserAgentInTryIt=(0,utils_1.argValueToBoolean)(a.sendXUserAgentInTryIt),this.showExtensions=e.normalizeShowExtensions(a.showExtensions),this.hideSingleRequestSampleTab=(0,utils_1.argValueToBoolean)(a.hideSingleRequestSampleTab),this.hideRequestPayloadSample=(0,utils_1.argValueToBoolean)(a.hideRequestPayloadSample),this.menuToggle=(0,utils_1.argValueToBoolean)(a.menuToggle,!0),this.jsonSampleExpandLevel=(0,utils_1.argValueToExpandLevel)(a.jsonSampleExpandLevel,2),this.enumSkipQuotes=(0,utils_1.argValueToBoolean)(a.enumSkipQuotes),this.hideSchemaTitles=(0,utils_1.argValueToBoolean)(a.hideSchemaTitles),this.hideSecuritySection=(0,utils_1.argValueToBoolean)(a.hideSecuritySection),this.showSecuritySchemeType=(0,utils_1.argValueToBoolean)(a.showSecuritySchemeType),this.simpleOneOfTypeLabel=(0,utils_1.argValueToBoolean)(a.simpleOneOfTypeLabel),this.payloadSampleIdx=e.normalizePayloadSampleIdx(a.payloadSampleIdx),this.expandSingleSchemaField=(0,utils_1.argValueToBoolean)(a.expandSingleSchemaField),this.schemaExpansionLevel=(0,utils_1.argValueToExpandLevel)(a.schemaExpansionLevel),this.samplesTabsMaxCount=(0,utils_1.argValueToInt)(a.samplesTabsMaxCount)||5,this.unstable_tryItButtonOverride=a.unstable_tryItButtonOverride||null,this.unstable_ignoreMimeParameters=(0,utils_1.argValueToBoolean)(a.unstable_ignoreMimeParameters),this.allowedMdComponents=a.allowedMdComponents||{},this.expandDefaultServerVariables=(0,utils_1.argValueToBoolean)(a.expandDefaultServerVariables),this.expandDefaultRequest=(0,utils_1.argValueToBoolean)(a.expandDefaultRequest,!0),this.expandDefaultResponse=(0,utils_1.argValueToBoolean)(a.expandDefaultResponse,!0),this.maxDisplayedEnumValues=(0,utils_1.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||(0,utils_2.getWindowReferenceOptions)(types_1.WindowReferenceOptions.HOOKS)||{},this.hooks.ReplaceTryItAuthPanel&&!this.hooks.ReplaceTryItSecurityPanel&&(console.warn("[warn] ReplaceTryItAuthPanel is deprecated, use ReplaceTryItSecurityPanel instead"),this.hooks.ReplaceTryItSecurityPanel=this.hooks.ReplaceTryItAuthPanel),this.hideSchemaPattern=(0,utils_1.argValueToBoolean)(a.hideSchemaPattern),this.hideOneOfDescription=(0,utils_1.argValueToBoolean)(a.hideOneOfDescription),this.hideFab=(0,utils_1.argValueToBoolean)(a.hideFab),this.schemaDefinitionsTagName=a.schemaDefinitionsTagName,this.minCharacterLengthToInitSearch=(0,utils_1.argValueToNumber)(a.minCharacterLengthToInitSearch)||3,this.maxResponseHeadersToShowInTryIt=(0,utils_1.argValueToNumber)(a.maxResponseHeadersToShowInTryIt)||0,this.showWebhookVerb=(0,utils_1.argValueToBoolean)(a.showWebhookVerb),this.showObjectSchemaExamples=(0,utils_1.argValueToBoolean)(a.showObjectSchemaExamples),this.disableTryItRequestUrlEncoding=(0,utils_1.argValueToBoolean)(a.disableTryItRequestUrlEncoding,!1)}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&&!(0,utils_1.isNumeric)(e)){var a=(0,utils_1.querySelector)(e);a||console.warn("scrollYOffset value is a selector to non-existing element. Using offset 0 by default");var i=a&&a.getBoundingClientRect().bottom||0;return function(){return i}}return"number"==typeof e||(0,utils_1.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}}),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"showConsole",void 0),e}();exports.RedocNormalizedOptions=RedocNormalizedOptions;
|
|
2
2
|
//# sourceMappingURL=RedocNormalizedOptions.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ApiInfoModel=void 0;var utils_1=require("../../utils/"),ApiInfoModel=function(){function e(e){Object.defineProperty(this,"parser",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"title",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{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,"summary",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"termsOfService",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"contact",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"license",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"downloadFileName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.assign(this,e.definition.info),this.description=e.definition.info.description||"",this.summary=e.definition.info.summary||"";var i=this.description.search(/^##?\s+/m);i>-1&&(this.description=this.description.substring(0,i)),this.downloadFileName=this.getDownloadFileName()}return Object.defineProperty(e.prototype,"downloadLink",{get:function(){if(this.parser.definitionUrl)return this.parser.definitionUrl;if(utils_1.IS_BROWSER&&window.Blob&&window.URL&&window.URL.createObjectURL){var e=new Blob([JSON.stringify(this.parser.definition,null,2)],{type:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ApiInfoModel=void 0;var types_1=require("../../../../types"),utils_1=require("../../utils/"),ApiInfoModel=function(){function e(e){Object.defineProperty(this,"parser",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"title",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{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,"summary",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"termsOfService",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"contact",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"license",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"downloadFileName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.assign(this,e.definition.info),this.description=e.definition.info.description||"",this.summary=e.definition.info.summary||"";var i=this.description.search(/^##?\s+/m);i>-1&&(this.description=this.description.substring(0,i)),this.downloadFileName=this.getDownloadFileName()}return Object.defineProperty(e.prototype,"downloadLink",{get:function(){if(this.parser.definitionUrl)return this.parser.definitionUrl;if(utils_1.IS_BROWSER&&window.Blob&&window.URL&&window.URL.createObjectURL){var e=new Blob([JSON.stringify(this.parser.definition,null,2)],{type:types_1.MediaTypes.JSON});return window.URL.createObjectURL(e)}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"getDownloadFileName",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(!this.parser.definitionUrl)return"swagger.json"}}),e}();exports.ApiInfoModel=ApiInfoModel;
|
|
2
2
|
//# sourceMappingURL=ApiInfo.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getContentWithLegacyExamples=exports.pluralizeType=exports.extractExtensions=exports.isRedocExtension=exports.shortenHTTPVerb=exports.SCHEMA_DEFINITION_JSX_NAME=exports.SECURITY_DEFINITIONS_JSX_NAME=exports.SECURITY_DEFINITIONS_COMPONENT_NAME=exports.normalizeServers=exports.expandDefaultServerVariables=exports.mergeSimilarMediaTypes=exports.mergeParams=exports.sortByField=exports.sortByRequired=exports.humanizeConstraints=exports.humanizeNumberRange=exports.getDefinitionName=exports.isNamedDefinition=exports.langFromMime=exports.serializeParameterValue=exports.serializeParameterValueWithMime=exports.serializeQueryParameter=exports.urlFormEncodePayload=exports.isFormUrlEncoded=exports.isJsonLike=exports.isPrimitiveType=exports.detectType=exports.getOperationSummary=exports.isOperationName=exports.getStatusCodeType=exports.isStatusCode=void 0;var tslib_1=require("tslib"),path_1=require("path"),url_template_1=(0,tslib_1.__importDefault)(require("url-template")),dom_1=require("./dom"),helpers_1=require("./helpers");function isWildcardStatusCode(e){return"string"==typeof e&&/\dxx/i.test(e)}function isStatusCode(e){return"default"===e||(0,helpers_1.isNumeric)(e)||isWildcardStatusCode(e)}function getStatusCodeType(e,r){if(void 0===r&&(r=!1),"default"===e)return r?"error":"success";var t="string"==typeof e?parseInt(e,10):e;if(isWildcardStatusCode(e)&&(t*=100),t<100||t>599)throw new Error("invalid HTTP code");var i="success";return t>=300&&t<400?i="redirect":t>=400?i="error":t<200&&(i="info"),i}exports.isStatusCode=isStatusCode,exports.getStatusCodeType=getStatusCodeType;var operationNames={get:!0,post:!0,put:!0,head:!0,patch:!0,delete:!0,options:!0,$ref:!0};function isOperationName(e){return e in operationNames}function getOperationSummary(e){return e.summary||e.operationId||e.description&&e.description.substring(0,50)||"<no summary>"}exports.isOperationName=isOperationName,exports.getOperationSummary=getOperationSummary;var schemaKeywordTypes={multipleOf:"number",maximum:"number",exclusiveMaximum:"number",minimum:"number",exclusiveMinimum:"number",maxLength:"string",minLength:"string",pattern:"string",contentEncoding:"string",contentMediaType:"string",items:"array",maxItems:"array",minItems:"array",uniqueItems:"array",maxProperties:"object",minProperties:"object",required:"object",additionalProperties:"object",unevaluatedProperties:"object",patternProperties:"object",properties:"object"};function detectType(e){if(void 0!==e.type&&!Array.isArray(e.type))return e.type;for(var r=0,t=Object.keys(schemaKeywordTypes);r<t.length;r++){var i=t[r],a=schemaKeywordTypes[i];if(void 0!==e[i])return a}return"any"}function isPrimitiveType(e,r){if(void 0===r&&(r=e.type),void 0!==e.oneOf||void 0!==e.anyOf)return!1;if(e.if&&e.then||e.if&&e.else)return!1;var t=!0,i=Array.isArray(r);return("object"===r||i&&(null==r?void 0:r.includes("object")))&&(t=void 0!==e.properties?0===Object.keys(e.properties).length:void 0===e.additionalProperties&&void 0===e.unevaluatedProperties),!Array.isArray(e.items)&&!Array.isArray(e.prefixItems)&&(void 0!==e.items&&"boolean"!=typeof e.items&&("array"===r||i&&(null==r?void 0:r.includes("array")))&&(t=isPrimitiveType(e.items,e.items.type)),t)}function isJsonLike(e){return-1!==e.search(/json/i)}function isFormUrlEncoded(e){return"application/x-www-form-urlencoded"===e}function delimitedEncodeField(e,r,t){return Array.isArray(e)?e.map((function(e){return e.toString()})).join(t):"object"==typeof e?Object.keys(e).map((function(r){return""+r+t+e[r]})).join(t):r+"="+e.toString()}function deepObjectEncodeField(e,r){return Array.isArray(e)?(console.warn("deepObject style cannot be used with array value:"+e.toString()),""):"object"==typeof e?Object.keys(e).map((function(t){return e[t]?r+"["+t+"]="+e[t]:void 0})).filter(Boolean).join("&"):(console.warn("deepObject style cannot be used with non-object value:"+e.toString()),"")}function serializeFormValue(e,r,t){var i,a="__redoc_param_name__",n=r?"*":"";return url_template_1.default.parse("{?"+a+n+"}").expand((i={},i[a]=t,i)).substring(1).replace(/__redoc_param_name__/g,e)}function urlFormEncodePayload(e,r){if(void 0===r&&(r={}),Array.isArray(e))throw new Error("Payload must have fields: "+e.toString());return Object.keys(e).map((function(t){var i=e[t],a=r[t]||{},n=a.style,o=void 0===n?"form":n,s=a.explode,u=void 0===s||s;switch(o){case"form":return serializeFormValue(t,u,i);case"spaceDelimited":return delimitedEncodeField(i,t,"%20");case"pipeDelimited":return delimitedEncodeField(i,t,"|");case"deepObject":return deepObjectEncodeField(i,t);default:return console.warn("Incorrect or unsupported encoding style: "+o),""}})).join("&")}function serializePathParameter(e,r,t,i){var a,n=t?"*":"",o="";"label"===r?o=".":"matrix"===r&&(o=";");var s="__redoc_param_name__";return url_template_1.default.parse("{"+o+s+n+"}").expand((a={},a[s]=i,a)).replace(/__redoc_param_name__/g,e)}function serializeQueryParameter(e,r,t,i){switch(r){case"form":return serializeFormValue(e,t,i);case"spaceDelimited":return Array.isArray(i)?t?serializeFormValue(e,t,i):e+"="+i.join("%20"):(console.warn("The style spaceDelimited is only applicable to arrays"),"");case"pipeDelimited":return Array.isArray(i)?t?serializeFormValue(e,t,i):e+"="+i.join("|"):(console.warn("The style pipeDelimited is only applicable to arrays"),"");case"deepObject":return!t||Array.isArray(i)||"object"!=typeof i?(console.warn("The style deepObject is only applicable for objects with explode=true"),""):deepObjectEncodeField(i,e);default:return console.warn("Unexpected style for query: "+r),""}}function serializeHeaderParameter(e,r,t){var i;if("simple"===e){var a=r?"*":"",n="__redoc_param_name__",o=url_template_1.default.parse("{"+n+a+"}");return decodeURIComponent(o.expand(((i={})[n]=t,i)))}return console.warn("Unexpected style for header: "+e),""}function serializeCookieParameter(e,r,t,i){return"form"===r?serializeFormValue(e,t,i):(console.warn("Unexpected style for cookie: "+r),"")}function serializeParameterValueWithMime(e,r){return isJsonLike(r)?JSON.stringify(e):(console.warn("Parameter serialization as "+r+" is not supported"),"")}function serializeParameterValue(e,r){var t=e.name,i=e.style,a=e.explode,n=void 0!==a&&a,o=e.serializationMime;if(o)switch(e.in){case"path":case"header":return serializeParameterValueWithMime(r,o);case"cookie":case"query":return t+"="+serializeParameterValueWithMime(r,o);default:return console.warn("Unexpected parameter location: "+e.in),""}if(!i)return console.warn("Missing style attribute or content for parameter "+t),"";switch(e.in){case"path":return serializePathParameter(t,i,n,r);case"query":return serializeQueryParameter(t,i,n,r);case"header":return serializeHeaderParameter(i,n,r);case"cookie":return serializeCookieParameter(t,i,n,r);default:return console.warn("Unexpected parameter location: "+e.in),""}}function langFromMime(e){return-1!==e.search(/xml/i)?"xml":"clike"}exports.detectType=detectType,exports.isPrimitiveType=isPrimitiveType,exports.isJsonLike=isJsonLike,exports.isFormUrlEncoded=isFormUrlEncoded,exports.urlFormEncodePayload=urlFormEncodePayload,exports.serializeQueryParameter=serializeQueryParameter,exports.serializeParameterValueWithMime=serializeParameterValueWithMime,exports.serializeParameterValue=serializeParameterValue,exports.langFromMime=langFromMime;var DEFINITION_NAME_REGEX=/^#\/components\/(schemas|pathItems)\/([^/]+)$/;function isNamedDefinition(e){return DEFINITION_NAME_REGEX.test(e||"")}function getDefinitionName(e){var r;return null===(r=null==e?void 0:e.match(DEFINITION_NAME_REGEX))||void 0===r?void 0:r.pop()}function humanizeMultipleOfConstraint(e){if(void 0!==e){var r=e.toString(10);return/^0\.0*1$/.test(r)?"decimal places <= "+r.split(".")[1].length:"multiple of "+r}}function humanizeRangeConstraint(e,r,t){var i;return void 0!==r&&void 0!==t?i=r===t?"= "+r+" "+e:"[ "+r+" .. "+t+" ] "+e:void 0!==t?i="<= "+t+" "+e:void 0!==r&&(i=1===r?"non-empty":">= "+r+" "+e),i}function humanizeNumberRange(e){var r,t,i="number"==typeof e.exclusiveMinimum?Math.min(e.exclusiveMinimum,null!==(r=e.minimum)&&void 0!==r?r:1/0):e.minimum,a="number"==typeof e.exclusiveMaximum?Math.max(e.exclusiveMaximum,null!==(t=e.maximum)&&void 0!==t?t:-1/0):e.maximum,n="number"==typeof e.exclusiveMinimum||e.exclusiveMinimum,o="number"==typeof e.exclusiveMaximum||e.exclusiveMaximum;return void 0!==i&&void 0!==a?(n?"( ":"[ ")+i+" .. "+a+(o?" )":" ]"):void 0!==a?(o?"< ":"<= ")+a:void 0!==i?(n?"> ":">= ")+i:void 0}function humanizeConstraints(e){var r=[],t=humanizeRangeConstraint("characters",e.minLength,e.maxLength);void 0!==t&&r.push(t);var i=humanizeRangeConstraint("items",e.minItems,e.maxItems);void 0!==i&&r.push(i);var a=humanizeRangeConstraint("properties",e.minProperties,e.maxProperties);void 0!==a&&r.push(a);var n=humanizeMultipleOfConstraint(e.multipleOf);void 0!==n&&r.push(n);var o=humanizeNumberRange(e);return void 0!==o&&r.push(o),e.uniqueItems&&r.push("unique"),r}function sortByRequired(e,r){void 0===r&&(r=[]);var t=[],i=[],a=[];return e.forEach((function(e){e.required?r.includes(e.name)?i.push(e):a.push(e):t.push(e)})),i.sort((function(e,t){return r.indexOf(e.name)-r.indexOf(t.name)})),(0,tslib_1.__spreadArray)((0,tslib_1.__spreadArray)((0,tslib_1.__spreadArray)([],i,!0),a,!0),t,!0)}function sortByField(e,r){return(0,tslib_1.__spreadArray)([],e,!0).sort((function(e,t){return e[r].localeCompare(t[r])}))}function mergeParams(e,r,t){void 0===r&&(r=[]),void 0===t&&(t=[]);var i={};return t.forEach((function(r){r=e.shallowDeref(r),i[r.name+"_"+r.in]=!0})),(r=r.filter((function(r){return r=e.shallowDeref(r),!i[r.name+"_"+r.in]}))).concat(t)}function mergeSimilarMediaTypes(e){var r={};return Object.keys(e).forEach((function(t){var i=e[t],a=t.split(";")[0].trim();r[a]?r[a]=(0,tslib_1.__assign)((0,tslib_1.__assign)({},r[a]),i):r[a]=i})),r}function expandDefaultServerVariables(e,r){return void 0===r&&(r={}),e.replace(/(?:{)([\w-.]+)(?:})/g,(function(e,t){return r[t]&&r[t].default||e}))}function normalizeServers(e,r){var t=void 0===e?(0,helpers_1.removeQueryString)(function(){if(!dom_1.IS_BROWSER)return"";var e=window.location.href;return e.endsWith(".html")?(0,path_1.dirname)(e):e}()):(0,path_1.dirname)(e);return 0===r.length&&(r=[{url:"/"}]),r.map((function(e){return(0,tslib_1.__assign)((0,tslib_1.__assign)({},e),{url:(r=e.url,(0,helpers_1.resolveUrl)(t,r)),description:e.description||""});var r}))}exports.isNamedDefinition=isNamedDefinition,exports.getDefinitionName=getDefinitionName,exports.humanizeNumberRange=humanizeNumberRange,exports.humanizeConstraints=humanizeConstraints,exports.sortByRequired=sortByRequired,exports.sortByField=sortByField,exports.mergeParams=mergeParams,exports.mergeSimilarMediaTypes=mergeSimilarMediaTypes,exports.expandDefaultServerVariables=expandDefaultServerVariables,exports.normalizeServers=normalizeServers,exports.SECURITY_DEFINITIONS_COMPONENT_NAME="security-definitions",exports.SECURITY_DEFINITIONS_JSX_NAME="SecurityDefinitions",exports.SCHEMA_DEFINITION_JSX_NAME="SchemaDefinition";var shortenHTTPVerb=function(e){return{delete:"del",options:"opts"}[e]||e};function isRedocExtension(e){return e in{"x-circular-ref":!0,"x-code-samples":!0,"x-codeSamples":!0,"x-displayName":!0,"x-examples":!0,"x-ignoredHeaderParameters":!0,"x-logo":!0,"x-nullable":!0,"x-servers":!0,"x-tagGroups":!0,"x-traitTag":!0,"x-additionalPropertiesName":!0,"x-explicitMappingOnly":!0,"x-enumDescriptions":!0,"x-hideTryItPanel":!0}}function extractExtensions(e,r){return Object.keys(e).filter((function(e){return!0===r?e.startsWith("x-")&&!isRedocExtension(e):e.startsWith("x-")&&r.indexOf(e)>-1})).reduce((function(r,t){return r[t]=e[t],r}),{})}function pluralizeType(e){return e.split(" or ").map((function(e){return e.replace(/^(string|object|number|integer|array|boolean)s?( ?.*)/,"$1s$2")})).join(" or ")}function getContentWithLegacyExamples(e){var r=e.content,t=e["x-examples"],i=e["x-example"];if(t){r=(0,tslib_1.__assign)({},r);for(var a=0,n=Object.keys(t);a<n.length;a++){var o=t[l=n[a]];r[l]=(0,tslib_1.__assign)((0,tslib_1.__assign)({},r[l]),{examples:o})}}else if(i){r=(0,tslib_1.__assign)({},r);for(var s=0,u=Object.keys(i);s<u.length;s++){var l,m=i[l=u[s]];r[l]=(0,tslib_1.__assign)((0,tslib_1.__assign)({},r[l]),{example:m})}}return r}exports.shortenHTTPVerb=shortenHTTPVerb,exports.isRedocExtension=isRedocExtension,exports.extractExtensions=extractExtensions,exports.pluralizeType=pluralizeType,exports.getContentWithLegacyExamples=getContentWithLegacyExamples;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getContentWithLegacyExamples=exports.pluralizeType=exports.extractExtensions=exports.isRedocExtension=exports.shortenHTTPVerb=exports.SCHEMA_DEFINITION_JSX_NAME=exports.SECURITY_DEFINITIONS_JSX_NAME=exports.SECURITY_DEFINITIONS_COMPONENT_NAME=exports.normalizeServers=exports.expandDefaultServerVariables=exports.mergeSimilarMediaTypes=exports.mergeParams=exports.sortByField=exports.sortByRequired=exports.humanizeConstraints=exports.humanizeNumberRange=exports.getDefinitionName=exports.isNamedDefinition=exports.langFromMime=exports.serializeParameterValue=exports.serializeParameterValueWithMime=exports.serializeQueryParameter=exports.urlFormEncodePayload=exports.isFormUrlEncoded=exports.isJsonLike=exports.isPrimitiveType=exports.detectType=exports.getOperationSummary=exports.isOperationName=exports.getStatusCodeType=exports.isStatusCode=void 0;var tslib_1=require("tslib"),path_1=require("path"),url_template_1=(0,tslib_1.__importDefault)(require("url-template")),types_1=require("../../../types"),dom_1=require("./dom"),helpers_1=require("./helpers");function isWildcardStatusCode(e){return"string"==typeof e&&/\dxx/i.test(e)}function isStatusCode(e){return"default"===e||(0,helpers_1.isNumeric)(e)||isWildcardStatusCode(e)}function getStatusCodeType(e,r){if(void 0===r&&(r=!1),"default"===e)return r?"error":"success";var t="string"==typeof e?parseInt(e,10):e;if(isWildcardStatusCode(e)&&(t*=100),t<100||t>599)throw new Error("invalid HTTP code");var i="success";return t>=300&&t<400?i="redirect":t>=400?i="error":t<200&&(i="info"),i}exports.isStatusCode=isStatusCode,exports.getStatusCodeType=getStatusCodeType;var operationNames={get:!0,post:!0,put:!0,head:!0,patch:!0,delete:!0,options:!0,$ref:!0};function isOperationName(e){return e in operationNames}function getOperationSummary(e){return e.summary||e.operationId||e.description&&e.description.substring(0,50)||"<no summary>"}exports.isOperationName=isOperationName,exports.getOperationSummary=getOperationSummary;var schemaKeywordTypes={multipleOf:"number",maximum:"number",exclusiveMaximum:"number",minimum:"number",exclusiveMinimum:"number",maxLength:"string",minLength:"string",pattern:"string",contentEncoding:"string",contentMediaType:"string",items:"array",maxItems:"array",minItems:"array",uniqueItems:"array",maxProperties:"object",minProperties:"object",required:"object",additionalProperties:"object",unevaluatedProperties:"object",patternProperties:"object",properties:"object"};function detectType(e){if(void 0!==e.type&&!Array.isArray(e.type))return e.type;for(var r=0,t=Object.keys(schemaKeywordTypes);r<t.length;r++){var i=t[r],a=schemaKeywordTypes[i];if(void 0!==e[i])return a}return"any"}function isPrimitiveType(e,r){if(void 0===r&&(r=e.type),void 0!==e.oneOf||void 0!==e.anyOf)return!1;if(e.if&&e.then||e.if&&e.else)return!1;var t=!0,i=Array.isArray(r);return("object"===r||i&&(null==r?void 0:r.includes("object")))&&(t=void 0!==e.properties?0===Object.keys(e.properties).length:void 0===e.additionalProperties&&void 0===e.unevaluatedProperties),!Array.isArray(e.items)&&!Array.isArray(e.prefixItems)&&(void 0!==e.items&&"boolean"!=typeof e.items&&("array"===r||i&&(null==r?void 0:r.includes("array")))&&(t=isPrimitiveType(e.items,e.items.type)),t)}function isJsonLike(e){return-1!==e.search(/json/i)}function isFormUrlEncoded(e){return e===types_1.MediaTypes.URL_ENCODED}function delimitedEncodeField(e,r,t){return Array.isArray(e)?e.map((function(e){return e.toString()})).join(t):"object"==typeof e?Object.keys(e).map((function(r){return""+r+t+e[r]})).join(t):r+"="+e.toString()}function deepObjectEncodeField(e,r){return Array.isArray(e)?(console.warn("deepObject style cannot be used with array value:"+e.toString()),""):"object"==typeof e?Object.keys(e).map((function(t){return e[t]?r+"["+t+"]="+e[t]:void 0})).filter(Boolean).join("&"):(console.warn("deepObject style cannot be used with non-object value:"+e.toString()),"")}function serializeFormValue(e,r,t){var i,a="__redoc_param_name__",n=r?"*":"";return url_template_1.default.parse("{?"+a+n+"}").expand((i={},i[a]=t,i)).substring(1).replace(/__redoc_param_name__/g,e)}function urlFormEncodePayload(e,r){if(void 0===r&&(r={}),Array.isArray(e))throw new Error("Payload must have fields: "+e.toString());return Object.keys(e).map((function(t){var i=e[t],a=r[t]||{},n=a.style,o=void 0===n?"form":n,s=a.explode,u=void 0===s||s;switch(o){case"form":return serializeFormValue(t,u,i);case"spaceDelimited":return delimitedEncodeField(i,t,"%20");case"pipeDelimited":return delimitedEncodeField(i,t,"|");case"deepObject":return deepObjectEncodeField(i,t);default:return console.warn("Incorrect or unsupported encoding style: "+o),""}})).join("&")}function serializePathParameter(e,r,t,i){var a,n=t?"*":"",o="";"label"===r?o=".":"matrix"===r&&(o=";");var s="__redoc_param_name__";return url_template_1.default.parse("{"+o+s+n+"}").expand((a={},a[s]=i,a)).replace(/__redoc_param_name__/g,e)}function serializeQueryParameter(e,r,t,i){switch(r){case"form":return serializeFormValue(e,t,i);case"spaceDelimited":return Array.isArray(i)?t?serializeFormValue(e,t,i):e+"="+i.join("%20"):(console.warn("The style spaceDelimited is only applicable to arrays"),"");case"pipeDelimited":return Array.isArray(i)?t?serializeFormValue(e,t,i):e+"="+i.join("|"):(console.warn("The style pipeDelimited is only applicable to arrays"),"");case"deepObject":return!t||Array.isArray(i)||"object"!=typeof i?(console.warn("The style deepObject is only applicable for objects with explode=true"),""):deepObjectEncodeField(i,e);default:return console.warn("Unexpected style for query: "+r),""}}function serializeHeaderParameter(e,r,t){var i;if("simple"===e){var a=r?"*":"",n="__redoc_param_name__",o=url_template_1.default.parse("{"+n+a+"}");return decodeURIComponent(o.expand(((i={})[n]=t,i)))}return console.warn("Unexpected style for header: "+e),""}function serializeCookieParameter(e,r,t,i){return"form"===r?serializeFormValue(e,t,i):(console.warn("Unexpected style for cookie: "+r),"")}function serializeParameterValueWithMime(e,r){return isJsonLike(r)?JSON.stringify(e):(console.warn("Parameter serialization as "+r+" is not supported"),"")}function serializeParameterValue(e,r){var t=e.name,i=e.style,a=e.explode,n=void 0!==a&&a,o=e.serializationMime;if(o)switch(e.in){case"path":case"header":return serializeParameterValueWithMime(r,o);case"cookie":case"query":return t+"="+serializeParameterValueWithMime(r,o);default:return console.warn("Unexpected parameter location: "+e.in),""}if(!i)return console.warn("Missing style attribute or content for parameter "+t),"";switch(e.in){case"path":return serializePathParameter(t,i,n,r);case"query":return serializeQueryParameter(t,i,n,r);case"header":return serializeHeaderParameter(i,n,r);case"cookie":return serializeCookieParameter(t,i,n,r);default:return console.warn("Unexpected parameter location: "+e.in),""}}function langFromMime(e){return-1!==e.search(/xml/i)?"xml":"clike"}exports.detectType=detectType,exports.isPrimitiveType=isPrimitiveType,exports.isJsonLike=isJsonLike,exports.isFormUrlEncoded=isFormUrlEncoded,exports.urlFormEncodePayload=urlFormEncodePayload,exports.serializeQueryParameter=serializeQueryParameter,exports.serializeParameterValueWithMime=serializeParameterValueWithMime,exports.serializeParameterValue=serializeParameterValue,exports.langFromMime=langFromMime;var DEFINITION_NAME_REGEX=/^#\/components\/(schemas|pathItems)\/([^/]+)$/;function isNamedDefinition(e){return DEFINITION_NAME_REGEX.test(e||"")}function getDefinitionName(e){var r;return null===(r=null==e?void 0:e.match(DEFINITION_NAME_REGEX))||void 0===r?void 0:r.pop()}function humanizeMultipleOfConstraint(e){if(void 0!==e){var r=e.toString(10);return/^0\.0*1$/.test(r)?"decimal places <= "+r.split(".")[1].length:"multiple of "+r}}function humanizeRangeConstraint(e,r,t){var i;return void 0!==r&&void 0!==t?i=r===t?"= "+r+" "+e:"[ "+r+" .. "+t+" ] "+e:void 0!==t?i="<= "+t+" "+e:void 0!==r&&(i=1===r?"non-empty":">= "+r+" "+e),i}function humanizeNumberRange(e){var r,t,i="number"==typeof e.exclusiveMinimum?Math.min(e.exclusiveMinimum,null!==(r=e.minimum)&&void 0!==r?r:1/0):e.minimum,a="number"==typeof e.exclusiveMaximum?Math.max(e.exclusiveMaximum,null!==(t=e.maximum)&&void 0!==t?t:-1/0):e.maximum,n="number"==typeof e.exclusiveMinimum||e.exclusiveMinimum,o="number"==typeof e.exclusiveMaximum||e.exclusiveMaximum;return void 0!==i&&void 0!==a?(n?"( ":"[ ")+i+" .. "+a+(o?" )":" ]"):void 0!==a?(o?"< ":"<= ")+a:void 0!==i?(n?"> ":">= ")+i:void 0}function humanizeConstraints(e){var r=[],t=humanizeRangeConstraint("characters",e.minLength,e.maxLength);void 0!==t&&r.push(t);var i=humanizeRangeConstraint("items",e.minItems,e.maxItems);void 0!==i&&r.push(i);var a=humanizeRangeConstraint("properties",e.minProperties,e.maxProperties);void 0!==a&&r.push(a);var n=humanizeMultipleOfConstraint(e.multipleOf);void 0!==n&&r.push(n);var o=humanizeNumberRange(e);return void 0!==o&&r.push(o),e.uniqueItems&&r.push("unique"),r}function sortByRequired(e,r){void 0===r&&(r=[]);var t=[],i=[],a=[];return e.forEach((function(e){e.required?r.includes(e.name)?i.push(e):a.push(e):t.push(e)})),i.sort((function(e,t){return r.indexOf(e.name)-r.indexOf(t.name)})),(0,tslib_1.__spreadArray)((0,tslib_1.__spreadArray)((0,tslib_1.__spreadArray)([],i,!0),a,!0),t,!0)}function sortByField(e,r){return(0,tslib_1.__spreadArray)([],e,!0).sort((function(e,t){return e[r].localeCompare(t[r])}))}function mergeParams(e,r,t){void 0===r&&(r=[]),void 0===t&&(t=[]);var i={};return t.forEach((function(r){r=e.shallowDeref(r),i[r.name+"_"+r.in]=!0})),(r=r.filter((function(r){return r=e.shallowDeref(r),!i[r.name+"_"+r.in]}))).concat(t)}function mergeSimilarMediaTypes(e){var r={};return Object.keys(e).forEach((function(t){var i=e[t],a=t.split(";")[0].trim();r[a]?r[a]=(0,tslib_1.__assign)((0,tslib_1.__assign)({},r[a]),i):r[a]=i})),r}function expandDefaultServerVariables(e,r){return void 0===r&&(r={}),e.replace(/(?:{)([\w-.]+)(?:})/g,(function(e,t){return r[t]&&r[t].default||e}))}function normalizeServers(e,r){var t=void 0===e?(0,helpers_1.removeQueryString)(function(){if(!dom_1.IS_BROWSER)return"";var e=window.location.href;return e.endsWith(".html")?(0,path_1.dirname)(e):e}()):(0,path_1.dirname)(e);return 0===r.length&&(r=[{url:"/"}]),r.map((function(e){return(0,tslib_1.__assign)((0,tslib_1.__assign)({},e),{url:(r=e.url,(0,helpers_1.resolveUrl)(t,r)),description:e.description||""});var r}))}exports.isNamedDefinition=isNamedDefinition,exports.getDefinitionName=getDefinitionName,exports.humanizeNumberRange=humanizeNumberRange,exports.humanizeConstraints=humanizeConstraints,exports.sortByRequired=sortByRequired,exports.sortByField=sortByField,exports.mergeParams=mergeParams,exports.mergeSimilarMediaTypes=mergeSimilarMediaTypes,exports.expandDefaultServerVariables=expandDefaultServerVariables,exports.normalizeServers=normalizeServers,exports.SECURITY_DEFINITIONS_COMPONENT_NAME="security-definitions",exports.SECURITY_DEFINITIONS_JSX_NAME="SecurityDefinitions",exports.SCHEMA_DEFINITION_JSX_NAME="SchemaDefinition";var shortenHTTPVerb=function(e){return{delete:"del",options:"opts"}[e]||e};function isRedocExtension(e){return e in{"x-circular-ref":!0,"x-code-samples":!0,"x-codeSamples":!0,"x-displayName":!0,"x-examples":!0,"x-ignoredHeaderParameters":!0,"x-logo":!0,"x-nullable":!0,"x-servers":!0,"x-tagGroups":!0,"x-traitTag":!0,"x-additionalPropertiesName":!0,"x-explicitMappingOnly":!0,"x-enumDescriptions":!0,"x-hideTryItPanel":!0}}function extractExtensions(e,r){return Object.keys(e).filter((function(e){return!0===r?e.startsWith("x-")&&!isRedocExtension(e):e.startsWith("x-")&&r.indexOf(e)>-1})).reduce((function(r,t){return r[t]=e[t],r}),{})}function pluralizeType(e){return e.split(" or ").map((function(e){return e.replace(/^(string|object|number|integer|array|boolean)s?( ?.*)/,"$1s$2")})).join(" or ")}function getContentWithLegacyExamples(e){var r=e.content,t=e["x-examples"],i=e["x-example"];if(t){r=(0,tslib_1.__assign)({},r);for(var a=0,n=Object.keys(t);a<n.length;a++){var o=t[l=n[a]];r[l]=(0,tslib_1.__assign)((0,tslib_1.__assign)({},r[l]),{examples:o})}}else if(i){r=(0,tslib_1.__assign)({},r);for(var s=0,u=Object.keys(i);s<u.length;s++){var l,m=i[l=u[s]];r[l]=(0,tslib_1.__assign)((0,tslib_1.__assign)({},r[l]),{example:m})}}return r}exports.shortenHTTPVerb=shortenHTTPVerb,exports.isRedocExtension=isRedocExtension,exports.extractExtensions=extractExtensions,exports.pluralizeType=pluralizeType,exports.getContentWithLegacyExamples=getContentWithLegacyExamples;
|
|
2
2
|
//# sourceMappingURL=openapi.js.map
|
package/lib/services/ProStore.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.ProStore=exports.NestingGroup=void 0;var tslib_1=require("tslib"),mobx_1=require("mobx"),openapi_core_1=require("@redocly/openapi-core"),decko_1=require("decko"),redoc_lib_1=require("../redoc-lib"),pluggable_1=require("../components/pluggable"),utils_1=require("../utils"),SecurityDefs_1=require("../redoc-lib/src/components/SecurityRequirement/SecurityDefs"),history_1=require("./history"),ProMenu_1=require("./ProMenu"),SearchStore_1=require("./SearchStore"),extendTheme_1=require("./extendTheme"),VersionedSpecStore_1=require("./VersionedSpecStore"),check_1=(0,tslib_1.__importDefault)(require("./check")),utils_2=require("./utils"),store_types_1=require("./store-types"),types_1=require("./types"),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}),(0,mobx_1.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}}),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"active",void 0),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"expanded",void 0),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"activate",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"expand",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"collapse",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"deactivate",null),e}();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)}))}exports.NestingGroup=NestingGroup;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 redoc_lib_1.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:store_types_1.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}),(0,mobx_1.makeObservable)(this),this.initProOptions(i),redoc_lib_1.IS_BROWSER&&(this.l=(0,check_1.default)(i.licenseKey),this.l.then((function(e){e.valid&&e.allowed&&!e.expired||e.local||(n.menu.items=[],n.menu.flatItems=n.menu.flatItems.slice(0,1),n.menu.renderItems=[])})));var r="object"==typeof e&&"versions"in e,a=this.options.disableSidebar?new history_1.FakeHistoryService(this.options):"browser"===this.options.routingStrategy?new history_1.PushStateHistoryService(this.options,r):new history_1.ProHashHistoryService(this.options,r);this.definition=r?new VersionedSpecStore_1.VersionedSpecStore(e,this.options,a.currentId.split("/")[0]):new redoc_lib_1.SpecStore(e,t,this.options),i.downloadDefinitionUrl&&(this.definition.info.downloadFileName=""),this.scroll=new redoc_lib_1.ScrollService(this.options),this.options.disableSidebar||ProMenu_1.ProMenu.updateOnHistory(a.currentId,this.scroll),this.menu=new ProMenu_1.ProMenu(this.definition,this.scroll,this.options,a),this.menu.initOnHistory(),this.options.disableSearch||this.initSearch(this.options,o),this.disposer=(0,mobx_1.observe)(this.menu,"none"===this.options.pagination?"activeItemIdx":"activeRenderItemIdx",(function(e){setTimeout((function(){return n.updateMarkOnMenu(e.newValue)}))})),(0,utils_1.setGlobalStore)(this)}return Object.defineProperty(e.prototype,"initProOptions",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,i,o,n,r,a,s,l,u;e=deepClone(e),this.rawOptions=(0,extendTheme_1.extendTheme)(e),this.options=new redoc_lib_1.RedocNormalizedOptions(this.rawOptions,DEFAULT_OPTIONS),null!=this.rawOptions.showConsole&&console.warn('"showConsole" option is deprecated. Please, use "hideTryItPanel" instead.'),this.options.showConsole=null!=this.rawOptions.hideTryItPanel?!this.rawOptions.hideTryItPanel:null===(t=this.rawOptions.showConsole)||void 0===t||t,this.options.hideRightPanel=null!==(i=this.rawOptions.hideRightPanel)&&void 0!==i&&i,this.showRightPanel=!this.options.hideRightPanel,this.options.showRightPanelToggle=null===(o=this.rawOptions.showRightPanelToggle)||void 0===o||o,this.options.showChangeLayoutButton=null===(n=this.rawOptions.showChangeLayoutButton)||void 0===n||n,this.options.layout=this.rawOptions.layout||store_types_1.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||types_1.SideNavStyle.SummaryOnly,this.options.whiteLabel=!!this.rawOptions.whiteLabel,this.options.hideLogo=!!this.rawOptions.hideLogo,this.options.hideInfoSection=!!this.rawOptions.hideInfoSection,this.options.oAuth2RedirectURI=this.rawOptions.oAuth2RedirectURI||null,this.options.oAuth2RedirectURI=this.rawOptions.oAuth2RedirectURI||null,this.options.events=this.rawOptions.events||{},this.options.corsProxyUrl=this.rawOptions.corsProxyUrl?addTrailingSlash(this.rawOptions.corsProxyUrl):null,this.options.authCorsProxyUrl=this.rawOptions.authCorsProxyUrl?addTrailingSlash(this.rawOptions.authCorsProxyUrl):null,this.options.theme.scrollYOffset=this.options.scrollYOffset,this.options.linkForId=this.rawOptions.linkForId||redoc_lib_1.IS_BROWSER&&(null===(r=null===window||void 0===window?void 0:window.REFERENCE_DOCS_OPTIONS)||void 0===r?void 0:r.linkForId)||null,this.options.generateDeepLink=this.rawOptions.generateDeepLink||redoc_lib_1.IS_BROWSER&&(null===(a=null===window||void 0===window?void 0:window.REFERENCE_DOCS_OPTIONS)||void 0===a?void 0:a.generateDeepLink)||null,this.options.onDeepLinkClick=this.rawOptions.onDeepLinkClick||redoc_lib_1.IS_BROWSER&&(null===(s=null===window||void 0===window?void 0:window.REFERENCE_DOCS_OPTIONS)||void 0===s?void 0:s.onDeepLinkClick)||null,this.options.requestInterceptor=this.rawOptions.requestInterceptor||redoc_lib_1.IS_BROWSER&&(null===(l=null===window||void 0===window?void 0:window.REFERENCE_DOCS_OPTIONS)||void 0===l?void 0:l.requestInterceptor)||null,this.options.sidebarLinks=this.rawOptions.sidebarLinks||{};var p="object"==typeof this.rawOptions.layout?this.rawOptions.layout:null;if(this.options.pagination=this.rawOptions.pagination||"none",this.options.routingStrategy=void 0!==this.rawOptions.routingStrategy?this.rawOptions.routingStrategy:"none"===this.options.pagination?"hash":"browser",!(null===(u=this.rawOptions)||void 0===u?void 0:u.pagination)&&(null==p?void 0:p.scope))switch(console.warn('"layout.scope" and "routingStrategy" settings are deprecated. Please, use "pagination" instead.'),null==p?void 0:p.scope){case"all":default:this.options.pagination="none",this.options.routingStrategy="hash";break;case"section":this.options.pagination="section",this.options.routingStrategy="browser";break;case"item":this.options.pagination="item",this.options.routingStrategy="browser"}this.options.markdownItemsPagination="none",!1!==this.rawOptions.showNextButton&&(this.options.showNextButton=!0),this.options.disableSidebar=!!e.disableSidebar,this.options.disableSidebar&&(this.options.theme.sidebar.width="0px"),this.options.skipBundleAndConvert=!!e.skipBundleAndConvert,this.options.routingBasePath=e.routingBasePath&&(0,utils_2.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||SearchStore_1.DEFAULT_SEARCH_MAX_DEPTH}}),Object.defineProperty(e.prototype,"initSearch",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var i=this;global.__REDOCLY_SEARCH_URL?this.search=new SearchStore_1.RemoteSearch(global.__REDOCLY_SEARCH_URL):this.search=new SearchStore_1.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_1.VersionedSpecStore&&(0,mobx_1.observe)(this.definition,"activeVersionIdx",(function(t){var o,n,r=i.definition;null===(o=i.search)||void 0===o||o.dispose(),i.search=new SearchStore_1.DeepSearchStore(e);var a=r.versions[t.newValue]._searchIndexName;if(redoc_lib_1.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)})),redoc_lib_1.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=(0,utils_1.fromLocalStorage)("layoutVariant")||this.options.layout||this.layout,this.activeSampleLanguage=(0,utils_1.fromLocalStorage)("activeSampleLanguage")||this.options.defaultSampleLanguage,this.options.showRightPanelToggle){var e=(0,utils_1.fromSessionStorage)("showRightPanelToggleState");e&&(this.showRightPanel="true"===e)}}}),Object.defineProperty(e.prototype,"toggleRightPanel",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.showRightPanel=null!=e?e:!this.showRightPanel,(0,utils_1.toSessionStorage)("showRightPanelToggleState",JSON.stringify(this.showRightPanel))}}),Object.defineProperty(e.prototype,"toggleLayout",{enumerable:!1,configurable:!0,writable:!0,value:function(e){void 0===e&&(e=store_types_1.LayoutVariant.THREE_PANEL),this.layout=e,(0,utils_1.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,(0,utils_1.toLocalStorage)("activeSampleLanguage",e)}}),Object.defineProperty(e.prototype,"activateSampleLanguage",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.setActiveSampleLanguage(e)}}),Object.defineProperty(e.prototype,"startLoader",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.isLoading||(this.isLoading=!0)}}),Object.defineProperty(e.prototype,"stopLoader",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.isLoading&&(this.isLoading=!1)}}),Object.defineProperty(e.prototype,"dereferenceSpecForTryIt",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,i,o,n;return(0,tslib_1.__awaiter)(this,void 0,void 0,(function(){var r,a,s,l,u,p,d,c;return(0,tslib_1.__generator)(this,(function(h){switch(h.label){case 0:return r=this.definition.parser.definition,a=JSON.parse(JSON.stringify(r)),s=(0,tslib_1.__assign)((0,tslib_1.__assign)({},getSpecVersionObj(a)),{components:a.components,paths:(d={},d[e.path]=(c={},c[e.httpVerb]=null===(i=null===(t=a.paths)||void 0===t?void 0:t[e.path])||void 0===i?void 0:i[e.httpVerb],c.parameters=null===(n=null===(o=a.paths)||void 0===o?void 0:o[e.path])||void 0===n?void 0:n.parameters,c),d)}),l=new openapi_core_1.Config({}),u=(0,redoc_lib_1.createParsedDocument)(s),p={config:l,doc:u,dereference:!0},[4,(0,openapi_core_1.bundle)(p)];case 1:return h.sent(),[2,a]}}))}))}}),Object.defineProperty(e.prototype,"observeAllAndRemark",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this,t=function(i){for(var o=0,n=i;o<n.length;o++){var r=n[o];if("operation"===r.type)for(var a=0,s=r.responses;a<s.length;a++){var l=s[a];(0,mobx_1.observe)(l,"expanded",(function(t){return e.remark(t)}))}else"tag"===r.type&&t(r.items||[])}};t(this.menu.renderItems),"none"!==this.options.pagination&&(0,mobx_1.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);(0,utils_1.setGlobalStore)(o),o.menu.activeItemIdx=void 0!==t.menu.activeItemIdx?t.menu.activeItemIdx:-1,o.definition instanceof VersionedSpecStore_1.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(0,tslib_1.__awaiter)(this,void 0,void 0,(function(){var t,i;return(0,tslib_1.__generator)(this,(function(o){switch(o.label){case 0:return i={menu:{activeItemIdx:this.menu.activeItemIdx},definition:this.definition instanceof VersionedSpecStore_1.VersionedSpecStore?{url:void 0,data:this.definition.toJS()}:{url:this.definition.parser.definitionUrl,data:this.definition.parser.definition}},this.search?[4,this.search.toJS()]:[3,2];case 1:return t=o.sent(),[3,3];case 2:t=void 0,o.label=3;case 3:return[2,(i.searchIndex=t,i.options=this.rawOptions,i.tryItOperationId=null===(e=this.tryItOperation)||void 0===e?void 0:e.id,i)]}}))}))}}),Object.defineProperty(e.prototype,"dispose",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.scroll.dispose(),this.menu.dispose(),this.search&&this.search.dispose(),this.disposer()}}),Object.defineProperty(e.prototype,"updateMarkOnMenu",{enumerable:!1,configurable:!0,writable:!0,value:function(e){for(var t=Math.max(0,e),i=Math.min(this.menu.flatItems.length,t+5),o=[],n=t;n<i;n++){(r=this.menu.getElementAt(n))&&(r&&o.push(r))}if("item"===this.options.pagination){var r,a=(this.menu.flatItems[e]||{}).parent;if(null==a?void 0:a.absoluteIdx)(r=this.menu.getElementAt(a.absoluteIdx))&&o.push(r)}this.marker.addOnly(o),this.marker.mark()}}),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"search",void 0),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"tryItOperation",void 0),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"showRightPanel",void 0),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"layout",void 0),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"activeSampleLanguage",void 0),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"isLoading",void 0),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"onDidMount",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"toggleRightPanel",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"toggleLayout",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"disableConsole",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"enableConsole",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"tryItOut",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"setActiveSampleLanguage",null),(0,tslib_1.__decorate)([decko_1.bind,(0,decko_1.debounce)(500)],e.prototype,"activateSampleLanguage",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"startLoader",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"stopLoader",null),e}();exports.ProStore=ProStore;var DEFAULT_OPTIONS={ignoreNamedSchemas:["java.io.ObjectStreamField"],allowedMdComponents:(_a={RedocResponse:{component:pluggable_1.RedocResponse,propsSelector:function(e){return{store:e}}},PullRight:{component:pluggable_1.PullRight,propsSelector:function(){return{}}}},_a[redoc_lib_1.SCHEMA_DEFINITION_JSX_NAME]={component:redoc_lib_1.SchemaDefinition,propsSelector:function(e){return{parser:e.definition.parser,options:e.options,layout:e.layout,showRightPanel:e.showRightPanel}}},_a[redoc_lib_1.SECURITY_DEFINITIONS_COMPONENT_NAME]={component:SecurityDefs_1.SecurityDefs,propsSelector:function(e){return{securitySchemes:e.definition.securitySchemes}}},_a[redoc_lib_1.SECURITY_DEFINITIONS_JSX_NAME]={component:SecurityDefs_1.SecurityDefs,propsSelector:function(e){return{securitySchemes:e.definition.securitySchemes}}},_a)};function joinURLs(e,t){return e.endsWith("/")&&(e=e.slice(0,-1)),t.startsWith("/")&&(t=t.substring(1)),e+"/"+t}function addTrailingSlash(e){return e.endsWith("/")?e:e+"/"}function getSpecVersionObj(e){return e.openapi?{openapi:e.openapi}:e.swagger?{swagger:e.swagger}:void 0}function deepClone(e){if("object"!=typeof e||null===e)return e;var t=Array.isArray(e)?[]:{};for(var i in e){var o=e[i];t[i]=deepClone(o)}return t}
|
|
1
|
+
"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.ProStore=exports.NestingGroup=void 0;var tslib_1=require("tslib"),mobx_1=require("mobx"),openapi_core_1=require("@redocly/openapi-core"),decko_1=require("decko"),redoc_lib_1=require("../redoc-lib"),pluggable_1=require("../components/pluggable"),utils_1=require("../utils"),SecurityDefs_1=require("../redoc-lib/src/components/SecurityRequirement/SecurityDefs"),types_1=require("../types"),history_1=require("./history"),ProMenu_1=require("./ProMenu"),SearchStore_1=require("./SearchStore"),extendTheme_1=require("./extendTheme"),VersionedSpecStore_1=require("./VersionedSpecStore"),check_1=(0,tslib_1.__importDefault)(require("./check")),utils_2=require("./utils"),store_types_1=require("./store-types"),types_2=require("./types"),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}),(0,mobx_1.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}}),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"active",void 0),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"expanded",void 0),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"activate",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"expand",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"collapse",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"deactivate",null),e}();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)}))}exports.NestingGroup=NestingGroup;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 redoc_lib_1.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:store_types_1.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}),(0,mobx_1.makeObservable)(this),this.initProOptions(i),redoc_lib_1.IS_BROWSER&&(this.l=(0,check_1.default)(i.licenseKey),this.l.then((function(e){e.valid&&e.allowed&&!e.expired||e.local||(n.menu.items=[],n.menu.flatItems=n.menu.flatItems.slice(0,1),n.menu.renderItems=[])})));var r="object"==typeof e&&"versions"in e,a=this.options.disableSidebar?new history_1.FakeHistoryService(this.options):"browser"===this.options.routingStrategy?new history_1.PushStateHistoryService(this.options,r):new history_1.ProHashHistoryService(this.options,r);this.definition=r?new VersionedSpecStore_1.VersionedSpecStore(e,this.options,a.currentId.split("/")[0]):new redoc_lib_1.SpecStore(e,t,this.options),i.downloadDefinitionUrl&&(this.definition.info.downloadFileName=""),this.scroll=new redoc_lib_1.ScrollService(this.options),this.options.disableSidebar||ProMenu_1.ProMenu.updateOnHistory(a.currentId,this.scroll),this.menu=new ProMenu_1.ProMenu(this.definition,this.scroll,this.options,a),this.menu.initOnHistory(),this.options.disableSearch||this.initSearch(this.options,o),this.disposer=(0,mobx_1.observe)(this.menu,"none"===this.options.pagination?"activeItemIdx":"activeRenderItemIdx",(function(e){setTimeout((function(){return n.updateMarkOnMenu(e.newValue)}))})),(0,utils_1.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=(0,extendTheme_1.extendTheme)(e),this.options=new redoc_lib_1.RedocNormalizedOptions(this.rawOptions,DEFAULT_OPTIONS),null!=this.rawOptions.showConsole&&console.warn('"showConsole" option is deprecated. Please, use "hideTryItPanel" instead.'),this.options.showConsole=null!=this.rawOptions.hideTryItPanel?!this.rawOptions.hideTryItPanel:null===(t=this.rawOptions.showConsole)||void 0===t||t,this.options.hideRightPanel=null!==(i=this.rawOptions.hideRightPanel)&&void 0!==i&&i,this.showRightPanel=!this.options.hideRightPanel,this.options.showRightPanelToggle=null===(o=this.rawOptions.showRightPanelToggle)||void 0===o||o,this.options.showChangeLayoutButton=null===(n=this.rawOptions.showChangeLayoutButton)||void 0===n||n,this.options.layout=this.rawOptions.layout||store_types_1.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||types_2.SideNavStyle.SummaryOnly,this.options.whiteLabel=!!this.rawOptions.whiteLabel,this.options.hideLogo=!!this.rawOptions.hideLogo,this.options.hideInfoSection=!!this.rawOptions.hideInfoSection,this.options.oAuth2RedirectURI=this.rawOptions.oAuth2RedirectURI||null,this.options.oAuth2RedirectURI=this.rawOptions.oAuth2RedirectURI||null,this.options.events=this.rawOptions.events||{},this.options.corsProxyUrl=this.rawOptions.corsProxyUrl?addTrailingSlash(this.rawOptions.corsProxyUrl):null,this.options.authCorsProxyUrl=this.rawOptions.authCorsProxyUrl?addTrailingSlash(this.rawOptions.authCorsProxyUrl):null,this.options.theme.scrollYOffset=this.options.scrollYOffset,this.options.linkForId=this.rawOptions.linkForId||(0,utils_1.getWindowReferenceOptions)(types_1.WindowReferenceOptions.LINK_FOR_ID)||null,this.options.generateDeepLink=this.rawOptions.generateDeepLink||(0,utils_1.getWindowReferenceOptions)(types_1.WindowReferenceOptions.GENERATE_DEEP_LINK)||null,this.options.onDeepLinkClick=this.rawOptions.onDeepLinkClick||(0,utils_1.getWindowReferenceOptions)(types_1.WindowReferenceOptions.ON_DEEP_LINK_CLICK)||null,this.options.requestInterceptor=this.rawOptions.requestInterceptor||(0,utils_1.getWindowReferenceOptions)(types_1.WindowReferenceOptions.REQUEST_INTERCEPTOR)||null,this.options.sidebarLinks=this.rawOptions.sidebarLinks||{};var a="object"==typeof this.rawOptions.layout?this.rawOptions.layout:null;if(this.options.pagination=this.rawOptions.pagination||"none",this.options.routingStrategy=void 0!==this.rawOptions.routingStrategy?this.rawOptions.routingStrategy:"none"===this.options.pagination?"hash":"browser",!(null===(r=this.rawOptions)||void 0===r?void 0:r.pagination)&&(null==a?void 0:a.scope))switch(console.warn('"layout.scope" and "routingStrategy" settings are deprecated. Please, use "pagination" instead.'),null==a?void 0:a.scope){case"all":default:this.options.pagination="none",this.options.routingStrategy="hash";break;case"section":this.options.pagination="section",this.options.routingStrategy="browser";break;case"item":this.options.pagination="item",this.options.routingStrategy="browser"}this.options.markdownItemsPagination="none",!1!==this.rawOptions.showNextButton&&(this.options.showNextButton=!0),this.options.disableSidebar=!!e.disableSidebar,this.options.disableSidebar&&(this.options.theme.sidebar.width="0px"),this.options.skipBundleAndConvert=!!e.skipBundleAndConvert,this.options.routingBasePath=e.routingBasePath&&(0,utils_2.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||SearchStore_1.DEFAULT_SEARCH_MAX_DEPTH}}),Object.defineProperty(e.prototype,"initSearch",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var i=this;global.__REDOCLY_SEARCH_URL?this.search=new SearchStore_1.RemoteSearch(global.__REDOCLY_SEARCH_URL):this.search=new SearchStore_1.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_1.VersionedSpecStore&&(0,mobx_1.observe)(this.definition,"activeVersionIdx",(function(t){var o,n,r=i.definition;null===(o=i.search)||void 0===o||o.dispose(),i.search=new SearchStore_1.DeepSearchStore(e);var a=r.versions[t.newValue]._searchIndexName;if(redoc_lib_1.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)})),redoc_lib_1.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=(0,utils_1.fromLocalStorage)("layoutVariant")||this.options.layout||this.layout,this.activeSampleLanguage=(0,utils_1.fromLocalStorage)("activeSampleLanguage")||this.options.defaultSampleLanguage,this.options.showRightPanelToggle){var e=(0,utils_1.fromSessionStorage)("showRightPanelToggleState");e&&(this.showRightPanel="true"===e)}}}),Object.defineProperty(e.prototype,"toggleRightPanel",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.showRightPanel=null!=e?e:!this.showRightPanel,(0,utils_1.toSessionStorage)("showRightPanelToggleState",JSON.stringify(this.showRightPanel))}}),Object.defineProperty(e.prototype,"toggleLayout",{enumerable:!1,configurable:!0,writable:!0,value:function(e){void 0===e&&(e=store_types_1.LayoutVariant.THREE_PANEL),this.layout=e,(0,utils_1.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,(0,utils_1.toLocalStorage)("activeSampleLanguage",e)}}),Object.defineProperty(e.prototype,"activateSampleLanguage",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.setActiveSampleLanguage(e)}}),Object.defineProperty(e.prototype,"startLoader",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.isLoading||(this.isLoading=!0)}}),Object.defineProperty(e.prototype,"stopLoader",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.isLoading&&(this.isLoading=!1)}}),Object.defineProperty(e.prototype,"dereferenceSpecForTryIt",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,i,o,n;return(0,tslib_1.__awaiter)(this,void 0,void 0,(function(){var r,a,s,l,p,u,c,d;return(0,tslib_1.__generator)(this,(function(h){switch(h.label){case 0:return r=this.definition.parser.definition,a=JSON.parse(JSON.stringify(r)),s=(0,tslib_1.__assign)((0,tslib_1.__assign)({},getSpecVersionObj(a)),{components:a.components,paths:(c={},c[e.path]=(d={},d[e.httpVerb]=null===(i=null===(t=a.paths)||void 0===t?void 0:t[e.path])||void 0===i?void 0:i[e.httpVerb],d.parameters=null===(n=null===(o=a.paths)||void 0===o?void 0:o[e.path])||void 0===n?void 0:n.parameters,d),c)}),l=new openapi_core_1.Config({}),p=(0,redoc_lib_1.createParsedDocument)(s),u={config:l,doc:p,dereference:!0},[4,(0,openapi_core_1.bundle)(u)];case 1:return h.sent(),[2,a]}}))}))}}),Object.defineProperty(e.prototype,"observeAllAndRemark",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this,t=function(i){for(var o=0,n=i;o<n.length;o++){var r=n[o];if("operation"===r.type)for(var a=0,s=r.responses;a<s.length;a++){var l=s[a];(0,mobx_1.observe)(l,"expanded",(function(t){return e.remark(t)}))}else"tag"===r.type&&t(r.items||[])}};t(this.menu.renderItems),"none"!==this.options.pagination&&(0,mobx_1.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);(0,utils_1.setGlobalStore)(o),o.menu.activeItemIdx=void 0!==t.menu.activeItemIdx?t.menu.activeItemIdx:-1,o.definition instanceof VersionedSpecStore_1.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(0,tslib_1.__awaiter)(this,void 0,void 0,(function(){var t,i;return(0,tslib_1.__generator)(this,(function(o){switch(o.label){case 0:return i={menu:{activeItemIdx:this.menu.activeItemIdx},definition:this.definition instanceof VersionedSpecStore_1.VersionedSpecStore?{url:void 0,data:this.definition.toJS()}:{url:this.definition.parser.definitionUrl,data:this.definition.parser.definition}},this.search?[4,this.search.toJS()]:[3,2];case 1:return t=o.sent(),[3,3];case 2:t=void 0,o.label=3;case 3:return[2,(i.searchIndex=t,i.options=this.rawOptions,i.tryItOperationId=null===(e=this.tryItOperation)||void 0===e?void 0:e.id,i)]}}))}))}}),Object.defineProperty(e.prototype,"dispose",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.scroll.dispose(),this.menu.dispose(),this.search&&this.search.dispose(),this.disposer()}}),Object.defineProperty(e.prototype,"updateMarkOnMenu",{enumerable:!1,configurable:!0,writable:!0,value:function(e){for(var t=Math.max(0,e),i=Math.min(this.menu.flatItems.length,t+5),o=[],n=t;n<i;n++){(r=this.menu.getElementAt(n))&&(r&&o.push(r))}if("item"===this.options.pagination){var r,a=(this.menu.flatItems[e]||{}).parent;if(null==a?void 0:a.absoluteIdx)(r=this.menu.getElementAt(a.absoluteIdx))&&o.push(r)}this.marker.addOnly(o),this.marker.mark()}}),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"search",void 0),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"tryItOperation",void 0),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"showRightPanel",void 0),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"layout",void 0),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"activeSampleLanguage",void 0),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"isLoading",void 0),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"onDidMount",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"toggleRightPanel",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"toggleLayout",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"disableConsole",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"enableConsole",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"tryItOut",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"setActiveSampleLanguage",null),(0,tslib_1.__decorate)([decko_1.bind,(0,decko_1.debounce)(500)],e.prototype,"activateSampleLanguage",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"startLoader",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"stopLoader",null),e}();exports.ProStore=ProStore;var DEFAULT_OPTIONS={ignoreNamedSchemas:["java.io.ObjectStreamField"],allowedMdComponents:(_a={RedocResponse:{component:pluggable_1.RedocResponse,propsSelector:function(e){return{store:e}}},PullRight:{component:pluggable_1.PullRight,propsSelector:function(){return{}}}},_a[redoc_lib_1.SCHEMA_DEFINITION_JSX_NAME]={component:redoc_lib_1.SchemaDefinition,propsSelector:function(e){return{parser:e.definition.parser,options:e.options,layout:e.layout,showRightPanel:e.showRightPanel}}},_a[redoc_lib_1.SECURITY_DEFINITIONS_COMPONENT_NAME]={component:SecurityDefs_1.SecurityDefs,propsSelector:function(e){return{securitySchemes:e.definition.securitySchemes}}},_a[redoc_lib_1.SECURITY_DEFINITIONS_JSX_NAME]={component:SecurityDefs_1.SecurityDefs,propsSelector:function(e){return{securitySchemes:e.definition.securitySchemes}}},_a)};function joinURLs(e,t){return e.endsWith("/")&&(e=e.slice(0,-1)),t.startsWith("/")&&(t=t.substring(1)),e+"/"+t}function addTrailingSlash(e){return e.endsWith("/")?e:e+"/"}function getSpecVersionObj(e){return e.openapi?{openapi:e.openapi}:e.swagger?{swagger:e.swagger}:void 0}function deepClone(e){if("object"!=typeof e||null===e)return e;var t=Array.isArray(e)?[]:{};for(var i in e){var o=e[i];t[i]=deepClone(o)}return t}
|
|
2
2
|
//# sourceMappingURL=ProStore.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.capitalizeFirst=exports.isDefined=exports.getCodeSample=void 0;var tslib_1=require("tslib"),query_string_1=require("query-string"),Sampler=(0,tslib_1.__importStar)(require("openapi-sampler")),deepmerge_1=(0,tslib_1.__importDefault)(require("deepmerge")),mobx_1=require("mobx"),redoc_lib_1=require("../../redoc-lib"),utils_1=require("../../utils"),utils_2=require("../utils"),httpsnippet_1=require("./httpsnippet");function mapOperationToHAR(e,t){var a,r,i,n,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.capitalizeFirst=exports.isDefined=exports.getCodeSample=void 0;var tslib_1=require("tslib"),query_string_1=require("query-string"),Sampler=(0,tslib_1.__importStar)(require("openapi-sampler")),deepmerge_1=(0,tslib_1.__importDefault)(require("deepmerge")),mobx_1=require("mobx"),redoc_lib_1=require("../../redoc-lib"),utils_1=require("../../utils"),utils_2=require("../utils"),types_1=require("../../types"),httpsnippet_1=require("./httpsnippet");function mapOperationToHAR(e,t){var a,r,i,s,n,l,o,u,p,d,c=t.exampleName,m=void 0===c?"":c,_=t.skipOptionalParameters,v=void 0!==_&&_,h=t.withOAuth2Call,f=void 0!==h&&h,y=t.spec,g=t.generatedPayloadSamplesMaxDepth,O=void 0===g?8:g,b=t.pathParams,T=void 0===b?{}:b,S=t.properties,C=void 0===S?{}:S,E=getSecurityData(null===(a=e.security)||void 0===a?void 0:a[0],f),q=E.securityHeaders,D=E.securityCookies,x=E.securityQueries,w=E.securityOAuth2ExtraCalls,P=E.basicAuth,R=null===(i=null===(r=e.requestBody)||void 0===r?void 0:r.content)||void 0===i?void 0:i.active,A={skipNonRequired:v,skipReadOnly:!0,maxSampleDepth:O},k={path:(0,mobx_1.toJS)(null===(s=null==e?void 0:e.requestValues)||void 0===s?void 0:s.path),cookie:(0,mobx_1.toJS)(null===(n=null==e?void 0:e.requestValues)||void 0===n?void 0:n.cookie),header:(0,mobx_1.toJS)(null===(l=null==e?void 0:e.requestValues)||void 0===l?void 0:l.header),query:(0,mobx_1.toJS)(null===(o=null==e?void 0:e.requestValues)||void 0===o?void 0:o.query),body:(0,mobx_1.toJS)(null===(u=null==e?void 0:e.requestValues)||void 0===u?void 0:u.body)},H=!1,N=e.parameters.filter((function(e){return"header"===e.in})).filter((function(e){return!(v&&!e.required)})).map((function(e){var t;return{name:e.name,value:(null===(t=k.header)||void 0===t?void 0:t[e.name])||(0,utils_1.getParameterValue)("header",e.name)||(0,redoc_lib_1.serializeParameterValue)(e,Sampler.sample(e.schema.rawSchema,A,y))}})).map((function(e){return(null==R?void 0:R.name)&&"content-type"===e.name.toLowerCase()&&(H=!0,e.value=R.name),e})).concat(q);!H&&(null==R?void 0:R.name)&&N.unshift({name:"Content-Type",value:null==R?void 0:R.name});var M=e.parameters.filter((function(e){return"cookie"===e.in})).filter((function(e){return!(v&&!e.required)})).map((function(e){return(0,query_string_1.parse)((0,redoc_lib_1.serializeParameterValue)(e,Sampler.sample(e.schema.rawSchema,A,y)))})).reduce((function(e,t){for(var a,r=0,i=Object.entries(t);r<i.length;r++){var s=i[r],n=s[0],l=s[1];e.push({name:n,value:String((null===(a=k.cookie)||void 0===a?void 0:a[n])||l)})}return e}),[]).concat(D),z=e.parameters.filter((function(e){return"query"===e.in})).filter((function(e){return!(v&&!e.required)})).map((function(e){return(0,query_string_1.parse)((0,redoc_lib_1.serializeParameterValue)(e,Sampler.sample(e.schema.rawSchema,A,y)))})).reduce((function(e,t){for(var a,r=0,i=Object.entries(t);r<i.length;r++){var s=i[r],n=s[0],l=s[1];e.push({name:n,value:String((null===(a=k.query)||void 0===a?void 0:a[n])||l)})}return e}),[]).concat(x),U=(null===(p=e.activeServer)||void 0===p?void 0:p.url.replace(/\/$/,""))+"/"+e.path.replace(/^\//,""),V=e.parameters.filter((function(e){return"path"===e.in})).reduce((function(e,t){var a,r=t.in,i=t.name;return e[i]=(null===(a=k.path)||void 0===a?void 0:a[i])||T[i]||(0,utils_1.getParameterValue)(r,i),e}),{}),j=null===(d=null==R?void 0:R.examples)||void 0===d?void 0:d[m],J=(null==R?void 0:R.examples)||{},L=Object.values(J)[0],I=k.body||(null==j?void 0:j.value)||(null==L?void 0:L.value)||(null==R?void 0:R.schema)&&Sampler.sample(null==R?void 0:R.schema.rawSchema,A,y),Y=null==R?void 0:R.name.toLowerCase(),F="",K=[];switch((0,utils_2.normalizeMimeType)(Y)){case types_1.MediaTypes.JSON:F=JSON.stringify(getDataRequest(I,C));break;case types_1.MediaTypes.URL_ENCODED:case types_1.MediaTypes.MULTIPART:F=(0,query_string_1.stringify)(getDataRequest(I,C)),K=objectToHarParams(getDataRequest(I,C));break;default:F=String(I||"")}var B=F?{mimeType:(null==R?void 0:R.name)||types_1.MediaTypes.OCTET_STREAM,text:F,params:K}:void 0;return{method:e.httpVerb,url:U,httpVersion:"HTTP/1.1",cookies:M,headers:N,queryString:z,postData:B,headersSize:-1,bodySize:-1,securityOAuth2ExtraCalls:w,basicAuth:P,pathParameters:V,serverVariables:e.activeServer.variables}}var defaultOptions={withImports:!0,withComments:!1},langToSnippetConfig={curl:{code:"shell",defaultTarget:"curl",defaultOptions:(0,tslib_1.__assign)((0,tslib_1.__assign)({},defaultOptions),{short:!0})},JavaScript:{code:"javascript",defaultTarget:"fetch",defaultOptions:(0,tslib_1.__assign)((0,tslib_1.__assign)({},defaultOptions),{withImports:!1})},"Node.js":{code:"node",defaultTarget:"fetch",defaultOptions:(0,tslib_1.__assign)({},defaultOptions)},Python:{code:"python",defaultTarget:"requests",defaultOptions:(0,tslib_1.__assign)({},defaultOptions)},"Java8+Apache":{code:"java8",defaultTarget:"apachehttp",defaultOptions:(0,tslib_1.__assign)({},defaultOptions)},Java:{code:"java",defaultTarget:"httpclient",defaultOptions:(0,tslib_1.__assign)({},defaultOptions)},"C#":{code:"csharp",defaultTarget:"httpclient",defaultOptions:(0,tslib_1.__assign)({},defaultOptions)},Go:{code:"go",defaultTarget:"http.DefaultClient",defaultOptions:(0,tslib_1.__assign)({},defaultOptions)},PHP:{code:"php",defaultTarget:"curl",defaultOptions:(0,tslib_1.__assign)({},defaultOptions)},Ruby:{code:"ruby",defaultTarget:"net::http",defaultOptions:(0,tslib_1.__assign)({},defaultOptions)},R:{code:"r",defaultTarget:"httr",defaultOptions:(0,tslib_1.__assign)({},defaultOptions)}};function getCodeSample(e){var t=e.lang,a=e.operation,r=e.exampleName,i=e.pathParams,s=e.properties,n=e.options,l=void 0===n?{}:n;try{var o=mapOperationToHAR(a,{exampleName:r,pathParams:i,properties:s,skipOptionalParameters:l.skipOptionalParameters,withOAuth2Call:l.withOAuth2Call,spec:l.spec,generatedPayloadSamplesMaxDepth:l.generatedPayloadSamplesMaxDepth}),u=new httpsnippet_1.HTTPSnippet(o);return langToSnippetConfig[t]?u.convert(langToSnippetConfig[t].code,langToSnippetConfig[t].defaultTarget,(0,tslib_1.__assign)((0,tslib_1.__assign)({},langToSnippetConfig[t].defaultOptions),l)):"Language is not supported."}catch(e){return console.error(e),"Failed to generate code sample."}}function getSecurityData(e,t){for(var a,r,i,s,n={securityHeaders:[],securityCookies:[],securityQueries:[],securityOAuth2ExtraCalls:[],basicAuth:void 0},l=0,o=(null==e?void 0:e.schemes)||[];l<o.length;l++){var u=o[l],p=(0,utils_1.getSecurityDetails)(u.id);switch(u.type){case"openIdConnect":null===(a=n.securityHeaders)||void 0===a||a.push({name:"Authorization",value:"Bearer <YOUR_TOKEN_HERE>"});break;case"oauth2":var d=p.token?(p.token.token_type||"Bearer")+" "+p.token.access_token:"Bearer <YOUR_TOKEN_HERE>";u.flows.clientCredentials&&t?n.securityOAuth2ExtraCalls.push(getOAuth2ClientCredsCallHar(u.flows.clientCredentials,u.scopes,p)):u.flows.password&&t&&n.securityOAuth2ExtraCalls.push(getOAuth2PasswordCallHar(u.flows.password,u.scopes,p)),null===(r=n.securityHeaders)||void 0===r||r.push({name:"Authorization",value:d});break;case"apiKey":var c=p.raw||"YOUR_API_KEY_HERE";"header"===u.in&&(null===(i=n.securityHeaders)||void 0===i||i.push({name:u.name,value:c})),"cookie"===u.in&&n.securityCookies.push({name:u.name,value:c}),"query"===u.in&&n.securityQueries.push({name:u.name,value:c});break;case"http":"basic"===u.scheme?n.basicAuth={username:p.username||"<username>",password:p.password||"<password>"}:null===(s=n.securityHeaders)||void 0===s||s.push({name:"Authorization",value:capitalizeFirst(u.scheme||"bearer")+" <YOUR_"+(u.bearerFormat||"TOKEN")+"_HERE>"})}}return n}function getOAuth2PasswordCallHar(e,t,a){return{method:"POST",url:e.tokenUrl,httpVersion:"HTTP/1.1",headers:[{name:"Content-Type",value:types_1.MediaTypes.URL_ENCODED},{name:"Accept",value:types_1.MediaTypes.JSON}],queryString:[],postData:{mimeType:types_1.MediaTypes.URL_ENCODED,text:"",params:[{name:"grant_type",value:"password"},{name:"client_id",value:a.client_id||"YOUR_CLIENT_ID"},{name:"client_secret",value:a.client_secret||"YOUR_CLIENT_SECRET"},{name:"username",value:a.username||"<username>"},{name:"password",value:a.password||"<password>"},t.length?{name:"scope",value:t.join(" ")}:void 0].filter(isDefined)},cookies:[],headersSize:-1,bodySize:-1,securityOAuth2ExtraCalls:[]}}function getOAuth2ClientCredsCallHar(e,t,a){return{method:"POST",url:e.tokenUrl,httpVersion:"HTTP/1.1",headers:[{name:"Content-Type",value:types_1.MediaTypes.URL_ENCODED},{name:"Accept",value:types_1.MediaTypes.JSON}],queryString:[],postData:{mimeType:types_1.MediaTypes.URL_ENCODED,text:"",params:[{name:"grant_type",value:"client_credentials"},{name:"client_id",value:a.client_id||"YOUR_CLIENT_ID"},{name:"client_secret",value:a.client_secret||"YOUR_CLIENT_SECRET"},t.length?{name:"scope",value:t.join(" ")}:void 0].filter(isDefined)},cookies:[],headersSize:-1,bodySize:-1,securityOAuth2ExtraCalls:[]}}function getDataRequest(e,t){if(e){if("object"==typeof e)return(0,deepmerge_1.default)(e,t,{arrayMerge:utils_2.arrayMergeStrategy});try{return(0,deepmerge_1.default)(JSON.parse(e),t,{arrayMerge:utils_2.arrayMergeStrategy})}catch(e){return!1}}return!1}function objectToHarParams(e){for(var t=[],a=0,r=Object.entries(e);a<r.length;a++){var i=r[a],s=i[0],n=i[1];t.push({name:s,value:String(n)})}return t}function isDefined(e){return void 0!==e}function capitalizeFirst(e){return e.charAt(0).toUpperCase()+e.slice(1)}exports.getCodeSample=getCodeSample,exports.isDefined=isDefined,exports.capitalizeFirst=capitalizeFirst;
|
|
2
2
|
//# sourceMappingURL=generator.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.HTTPSnippet=void 0;var tslib_1=require("tslib"),qs=(0,tslib_1.__importStar)(require("querystring")),url=(0,tslib_1.__importStar)(require("url")),utils_1=require("../../utils"),targets_1=(0,tslib_1.__importDefault)(require("./targets")),reducer_1=(0,tslib_1.__importDefault)(require("./helpers/reducer")),HTTPSnippet=function(){function e(e){Object.defineProperty(this,"request",{enumerable:!0,configurable:!0,writable:!0,value:void 0});var t=(0,tslib_1.__assign)({},e);this.request=this.prepare((0,tslib_1.__assign)((0,tslib_1.__assign)({},t),{httpVersion:t.httpVersion||"HTTP/1.1",queryString:t.queryString||[],headers:t.headers||[],cookies:t.cookies||[],postData:t.postData?(0,tslib_1.__assign)((0,tslib_1.__assign)({},t.postData),{jsonObj:void 0,paramsObj:void 0}):void 0,bodySize:0,headersSize:0,queryObj:{},headersObj:{},cookiesObj:{},allHeaders:{},uriObj:{},fullUrl:"",pathParameters:t.pathParameters||{},serverVariables:t.serverVariables||{}}))}return Object.defineProperty(e.prototype,"prepare",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t;if(e.queryString&&e.queryString.length&&(e.queryObj=e.queryString.reduce(reducer_1.default,{})),e.headers&&e.headers.length){var r=/^HTTP\/2/;e.headersObj=e.headers.reduce((function(t,a){var
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.HTTPSnippet=void 0;var tslib_1=require("tslib"),qs=(0,tslib_1.__importStar)(require("querystring")),url=(0,tslib_1.__importStar)(require("url")),utils_1=require("../../utils"),types_1=require("../../../types"),targets_1=(0,tslib_1.__importDefault)(require("./targets")),reducer_1=(0,tslib_1.__importDefault)(require("./helpers/reducer")),HTTPSnippet=function(){function e(e){Object.defineProperty(this,"request",{enumerable:!0,configurable:!0,writable:!0,value:void 0});var t=(0,tslib_1.__assign)({},e);this.request=this.prepare((0,tslib_1.__assign)((0,tslib_1.__assign)({},t),{httpVersion:t.httpVersion||"HTTP/1.1",queryString:t.queryString||[],headers:t.headers||[],cookies:t.cookies||[],postData:t.postData?(0,tslib_1.__assign)((0,tslib_1.__assign)({},t.postData),{jsonObj:void 0,paramsObj:void 0}):void 0,bodySize:0,headersSize:0,queryObj:{},headersObj:{},cookiesObj:{},allHeaders:{},uriObj:{},fullUrl:"",pathParameters:t.pathParameters||{},serverVariables:t.serverVariables||{}}))}return Object.defineProperty(e.prototype,"prepare",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t;if(e.queryString&&e.queryString.length&&(e.queryObj=e.queryString.reduce(reducer_1.default,{})),e.headers&&e.headers.length){var r=/^HTTP\/2/;e.headersObj=e.headers.reduce((function(t,a){var s=a.name;return e.httpVersion.match(r)&&(s=s.toLowerCase()),t[s]=a.value,t}),{})}e.cookies&&e.cookies.length&&(e.cookiesObj=e.cookies.reduceRight((function(e,t){return e[t.name]=t.value,e}),{}));var a=e.cookies.map((function(e){return encodeURIComponent(e.name)+"="+encodeURIComponent(e.value)}));if(a.length&&(e.allHeaders.cookie=a.join("; ")),e.postData)switch((0,utils_1.normalizeMimeType)(e.postData.mimeType)){case"multipart/mixed":case"multipart/related":case types_1.MediaTypes.MULTIPART:case"multipart/alternative":break;case types_1.MediaTypes.URL_ENCODED:(null===(t=e.postData)||void 0===t?void 0:t.params)?(e.postData.paramsObj=e.postData.params.reduce(reducer_1.default,{}),e.postData.text=qs.stringify(e.postData.paramsObj)):e.postData.text="";break;case"text/json":case"text/x-json":case types_1.MediaTypes.JSON:case"application/x-json":if(e.postData.mimeType=types_1.MediaTypes.JSON,e.postData.text)try{e.postData.jsonObj=JSON.parse(e.postData.text)}catch(t){e.postData.mimeType="text/plain"}}return e.allHeaders=Object.assign(e.allHeaders,e.headersObj),e.uriObj=url.parse(e.url,!0,!0),e.queryObj=Object.assign(e.queryObj,e.uriObj.query),e.uriObj.query=null,e.uriObj.search=null,e.uriObj.path=e.uriObj.pathname=(0,utils_1.unescapeServerVariables)(e.uriObj.pathname),e.url=(0,utils_1.unescapeServerVariables)(url.format(e.uriObj)),e.uriObj.query=e.queryObj,e.uriObj.search=qs.stringify(e.queryObj),e.uriObj.search&&(e.uriObj.path=e.uriObj.pathname+"?"+e.uriObj.search),e.fullUrl=(0,utils_1.unescapeServerVariables)(url.format(e.uriObj)),e}}),Object.defineProperty(e.prototype,"convert",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){!r&&t&&(r=t);var a=this._matchTarget(e,t);if(a){var s=a(this.request,r,{target:e,client:t});return 1===s.length?s[0]:s}throw new Error("Can not match target")}}),Object.defineProperty(e.prototype,"_matchTarget",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return!!Object.prototype.hasOwnProperty.call(targets_1.default,e)&&("string"==typeof t&&"function"==typeof targets_1.default[e][t]?targets_1.default[e][t]:targets_1.default[e][targets_1.default[e].info.default])}}),e}();exports.HTTPSnippet=HTTPSnippet;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.info=void 0;var tslib_1=require("tslib"),stringify_object_1=(0,tslib_1.__importDefault)(require("stringify-object")),code_builder_1=require("../../helpers/code-builder"),__1=require("../.."),code_helpers_1=require("../../helpers/code-helpers"),utils_1=require("../../../../utils"),generator_1=require("../../../generator"),constants_1=require("../../helpers/constants"),handler=function(t,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.info=void 0;var tslib_1=require("tslib"),stringify_object_1=(0,tslib_1.__importDefault)(require("stringify-object")),code_builder_1=require("../../helpers/code-builder"),__1=require("../.."),code_helpers_1=require("../../helpers/code-helpers"),utils_1=require("../../../../utils"),generator_1=require("../../../generator"),constants_1=require("../../helpers/constants"),types_1=require("../../../../../types"),handler=function(e,t,s){var a,n,i,r,o=s.target,p=s.client,u=Object.assign({indent:" ",withWrapper:!0},t),l=new code_builder_1.CodeBuilder({indentation:u.indent,variablesPrefix:u.variablesPrefix,capitalize:!0,lang:constants_1.Lang.CSHARP}),c=formatHttpMethod(e.method);if(u.withComments&&addComments(l),u.withWrapper&&(l.push("using System;"),l.push("using System.Net.Http;"),l.push("using System.Threading.Tasks;"),(g(types_1.MediaTypes.JSON)||g(types_1.MediaTypes.XML)||e.basicAuth)&&l.push("using System.Text;"),(g(types_1.MediaTypes.URL_ENCODED)||(null===(a=e.securityOAuth2ExtraCalls)||void 0===a?void 0:a.length))&&l.push("using System.Collections.Generic;"),(g(types_1.MediaTypes.JSON)||(null===(n=e.securityOAuth2ExtraCalls)||void 0===n?void 0:n.length))&&l.push("using Newtonsoft.Json.Linq;"),e.headersObj&&e.headersObj["Content-Type"]===types_1.MediaTypes.OCTET_STREAM&&(l.push("using System.IO;"),l.push("using System.Net.Http.Headers;")),l.blank(),l.push("public class Program"),l.push("{"),l.push(1,"public static async Task Main(string[] args)"),l.push(1,"{"),l.push(2,"using (var client = new HttpClient())"),l.push(2,"{")),null===(i=e.securityOAuth2ExtraCalls)||void 0===i?void 0:i.length){var h=new __1.HTTPSnippet(null===(r=e.securityOAuth2ExtraCalls)||void 0===r?void 0:r[0]).convert(o,p,(0,tslib_1.__assign)((0,tslib_1.__assign)({},u),{withImports:!1,withWrapper:!1,withComments:!1,variablesPrefix:"oauth2"}));l.push(h),l.push(3,"var oauth2Response = await oauth2Request.Content.ReadAsStringAsync();"),l.push(3,"JObject inputJObject = JObject.Parse(oauth2Response);"),l.push(3,'var accessToken = inputJObject["access_token"].ToString();'),l.blank()}var d=Object.keys(e.allHeaders).filter((function(e){switch(e.toLowerCase()){case"content-type":case"content-length":case"accept-encoding":return!1;default:return!0}}));if(d.length&&d.forEach((function(t){var s;l.push(3,'client.DefaultRequestHeaders.Add("%s", %s);',t,(null===(s=e.securityOAuth2ExtraCalls)||void 0===s?void 0:s.length)?'"Bearer " + accessToken':'"'+e.allHeaders[t]+'"')})),e.basicAuth){var m=e.basicAuth,y=m.username,_=m.password;l.push(3,'var base64String = Convert.ToBase64String(Encoding.ASCII.GetBytes("'+y+":"+_+'"));'),l.push(3,'client.DefaultRequestHeaders.Add("Authorization", "Basic "+ base64String);')}if(e.postData)switch((0,utils_1.normalizeMimeType)(e.postData.mimeType)){case types_1.MediaTypes.URL_ENCODED:e.postData.params&&(l.blank(),l.push(3,"List<KeyValuePair<string, string>> postData = new List<KeyValuePair<string, string>>();"),e.postData.params.forEach((function(e){l.push(3,'postData.Add(new KeyValuePair<string, string>("%s", "%s"));',e.name,e.value)})),l.blank());break;case types_1.MediaTypes.MULTIPART:e.postData.params&&(l.blank(),l.push(3,"MultipartFormDataContent postData = new MultipartFormDataContent();"),e.postData.params.forEach((function(e){l.push(3,'postData.Add(new StringContent("%s"), "%s");',e.value,e.name)})));break;case types_1.MediaTypes.JSON:e.postData.jsonObj&&(l.push(3,'JObject json = JObject.Parse(@"'+(0,code_helpers_1.addIndentation)((0,stringify_object_1.default)(e.postData.jsonObj,{indent:u.indent,inlineCharacterLimit:25}).replace(/"/g,'""'),{level:3,firstLine:!1})+'");'),l.push(3,'var postData = new StringContent(json.ToString(), Encoding.UTF8, "application/json");'));break;case types_1.MediaTypes.XML:e.postData.text&&(e.postData.text.trim().split("\n").forEach((function(e,t){var s=(0===t?'string xml = @"':"")+e.replace(/"/g,'""');l.push(0===t?3:4,s)})),l.push(3,'";'),l.push(3,'var postData = new StringContent(xml, Encoding.UTF8, "application/xml");'))}else T()&&(l.push(3,"var ms = new MemoryStream();"),l.push(3,"var postData = new StreamContent(ms);"),l.push(3,'postData.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");'));return(0,code_helpers_1.printUrlVariablesDeclarations)(e,l,3),l.push(3,"var %s = await client.%sAsync(%s%s);",l.var("request"),c,(0,code_helpers_1.buildUrlExpression)(e,l),u.withImports?isDataMethod(e.method)?(0,utils_1.normalizeMimeType)(e.postData&&e.postData.mimeType)===types_1.MediaTypes.URL_ENCODED?", new FormUrlEncodedContent(postData)":"delete"===e.method?"":e.postData&&e.postData.params||T()?", postData":", null":"":", new FormUrlEncodedContent(postData)"),u.withWrapper&&(l.push(3,"var response = await request.Content.ReadAsStringAsync();"),l.blank(),l.push(3,"Console.WriteLine(response);"),l.push(2,"}"),l.push(1,"}"),l.push("}")),l.join();function g(t){return e.postData&&(0,utils_1.normalizeMimeType)(e.postData.mimeType)===t}function T(){return e.headersObj&&e.headersObj["Content-Type"]===types_1.MediaTypes.OCTET_STREAM}};function addComments(e){e.push("/*"),e.push(" * Requires >= .NET 5"),e.push(" *"),e.push(' * Requires package "Newtonsoft.Json" >= 9.01'),e.push(" * See here for installation details:"),e.push(" * https://www.newtonsoft.com/json"),e.push(" */"),e.blank()}function formatHttpMethod(e){return(0,generator_1.capitalizeFirst)(e.toLowerCase())}function isDataMethod(e){return e&&["POST","PUT","DELETE","PATCH"].includes(e.toUpperCase())}exports.info={key:"httpclient",title:"HttpClient",link:"https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient",description:".NET Standard HTTP Client"},exports.default=handler;
|
|
2
2
|
//# sourceMappingURL=httpclient.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.info=void 0;var tslib_1=require("tslib"),code_builder_1=require("../../helpers/code-builder"),__1=require("../.."),constants_1=require("../../helpers/constants"),code_helpers_1=require("../../helpers/code-helpers"),utils_1=require("../../../../utils"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.info=void 0;var tslib_1=require("tslib"),code_builder_1=require("../../helpers/code-builder"),__1=require("../.."),constants_1=require("../../helpers/constants"),code_helpers_1=require("../../helpers/code-helpers"),utils_1=require("../../../../utils"),types_1=require("../../../../../types"),indent=1;function hasMimeType(e,t){return void 0===e&&(e={}),(0,utils_1.normalizeMimeType)(e.mimeType)===t}var handler=function(e,t,s){var a,r,n,i,p,d,o=s.target,l=s.client,u=(0,tslib_1.__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],y=u.checkErrors?"err":"_",v=e.method.toUpperCase(),c=new code_builder_1.CodeBuilder({indentation:u.indent,variablesPrefix:u.variablesPrefix,capitalize:u.capitalize,lang:constants_1.Lang.GO}),m=function(){u.checkErrors&&c.push(indent,"if err != nil {").push(indent+1,"panic(err)").push(indent,"}")};if(u.showBoilerplate&&(c.push("package main").blank().push("import (").push(indent,'"fmt"'),u.timeout>0&&c.push(indent,'"time"'),h&&c.push(indent,'"encoding/json"'),hasMimeType(e.postData,types_1.MediaTypes.MULTIPART)&&(c.push(indent,'"mime/multipart"'),c.push(indent,'"io"'),c.push(indent,'"bytes"')),(hasMimeType(e.postData,types_1.MediaTypes.URL_ENCODED)||hasMimeType(null===(n=null===(r=e.securityOAuth2ExtraCalls)||void 0===r?void 0:r[0])||void 0===n?void 0:n.postData,types_1.MediaTypes.URL_ENCODED))&&(c.push(indent,'"net/url"'),c.push(indent,'"strconv"')),(hasMimeType(e.postData,types_1.MediaTypes.JSON)||hasMimeType(null===(p=null===(i=e.securityOAuth2ExtraCalls)||void 0===i?void 0:i[0])||void 0===p?void 0:p.postData,types_1.MediaTypes.JSON))&&c.push(indent,'"bytes"'),(e.postData&&!hasMimeType(e.postData,types_1.MediaTypes.JSON)||h)&&c.push(indent,'"strings"'),c.push(indent,'"net/http"'),u.printBody&&c.push(indent,'"io/ioutil"'),c.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 _="oAuth2",b=u.checkErrors?y+" := ":"",f=u.capitalize?"Res":"res",q=new __1.HTTPSnippet(h).convert(o,l,(0,tslib_1.__assign)((0,tslib_1.__assign)({},u),{printBody:!1,variablesPrefix:_,showBoilerplate:!1}));c.push(q).blank().push(indent,"var oAuth2"+f+"Body struct {").push(indent+1,"Access_token string").push(indent,"}").push(indent,b+"json.NewDecoder("+_+f+".Body).Decode(&"+_+f+"Body)").blank(),m(),e.allHeaders.Authorization='"Bearer " + oAuth2'+f+"Body.Access_token"}if((0,code_helpers_1.printUrlVariablesDeclarations)(e,c,indent),u.timeout>0&&(l=c.var("client"),c.push(indent,"%s := http.Client{",l).push(indent+1,"Timeout: time.Duration(%s * time.Second),",u.timeout).push(indent,"}").blank()),c.push(indent,c.var("reqUrl")+" := "+(0,code_helpers_1.buildUrlExpression)(e,c)),e.postData){var w=void 0;switch((0,utils_1.normalizeMimeType)(e.postData.mimeType)){case types_1.MediaTypes.URL_ENCODED:c.push(indent,"%s := url.Values{}",c.var("data")),e.postData.params.forEach((function(e){c.push(indent,'%s.Set("%s", "%s")',c.var("data"),e.name,e.value)})),c.push(indent,'%s, %s := http.NewRequest("%s", %s, strings.NewReader(%s.Encode()))',c.var("req"),y,v,c.var("reqUrl"),c.var("data")),e.allHeaders["Content-Length"]="strconv.Itoa(len("+c.var("data")+".Encode()))";break;case types_1.MediaTypes.JSON:w=JSON.stringify(e.postData.jsonObj,null,2).split("\n").map((function(e){return u.indent+e})).join("\n").trim(),c.push(indent,"var "+c.var("data")+" = []byte(`"+w+"`)"),c.push(indent,'%s, %s := http.NewRequest("%s", %s, bytes.NewBuffer(%s))',c.var("req"),y,v,c.var("reqUrl"),c.var("data"));break;case types_1.MediaTypes.MULTIPART:c.push(indent,"%s := &bytes.Buffer{}",c.var("data")).push(indent,"writer := multipart.NewWriter(%s)",c.var("data")),e.postData.params.forEach((function(e){if(!e.fileName&&!e.contentType)return c.push(indent,'%s, _ := writer.CreateFormField("%s")',c.var(e.name+"Fw"),e.name).push(indent,'_, %s = io.Copy(%s, strings.NewReader("%s"))',y,c.var(e.name+"Fw"),e.value),void m();e.fileName&&(c.push(indent,'%s, %s = writer.CreateFormFile("%s", "%s")',c.var(e.name+"Fw"),y,e.name,e.fileName),m())})),c.push(indent,"writer.Close()").blank().push(indent,"%s := bytes.NewReader(%s.Bytes())",c.var("payload"),c.var("data")).push(indent,'%s, %s := http.NewRequest("%s", %s, %s)',c.var("req"),y,v,c.var("reqUrl"),c.var("payload")),e.allHeaders["Content-Type"]="writer.FormDataContentType()";break;default:e.postData.text&&c.push(indent,"%s := strings.NewReader(%s)",c.var("payload"),JSON.stringify(null===(d=e.postData)||void 0===d?void 0:d.text)).push(indent,'%s, %s := http.NewRequest("%s", %s, %s)',c.var("req"),y,v,c.var("reqUrl"),c.var("payload"))}}else c.push(indent,'%s, %s := http.NewRequest("%s", %s, nil)',c.var("req"),y,v,c.var("reqUrl"));if(Object.getOwnPropertyNames(e.queryObj).length){for(var T in c.blank().push(indent,c.var("query")+" := "+c.var("req")+".URL.Query()"),e.queryObj)c.push(indent,c.var("query")+'.Add("'+T+'", "'+e.queryObj[T]+'")');c.push(indent,c.var("req")+".URL.RawQuery = "+c.var("query")+".Encode()").blank()}if(m(),e.basicAuth){var N=e.basicAuth,g=N.username,k=N.password;c.push(indent,'%s.SetBasicAuth("'+g+'", "'+k+'")',c.var("req"))}return Object.keys(e.allHeaders).length&&Object.keys(e.allHeaders).forEach((function(t){c.push(indent,'%s.Header.Add("%s", %s)',c.var("req"),t,e.allHeaders[t])})),c.push(indent,"%s, %s := %s.Do(%s)",c.var("res"),y,l,c.var("req")),m(),u.printBody&&(c.push(indent,"defer %s.Body.Close()",c.var("res")).push(indent,"%s, %s := ioutil.ReadAll(%s.Body)",c.var("body"),y,c.var("res")),m()),c.blank().push(indent,"fmt.Println(%s)",c.var("res")),u.printBody&&c.push(indent,"fmt.Println(string(%s))",c.var("body")),u.showBoilerplate&&c.push("}"),c.join()};exports.info={key:"native",title:"NewRequest",link:"http://golang.org/pkg/net/http/#NewRequest",description:"Golang HTTP client request"},exports.default=handler;
|
|
2
2
|
//# sourceMappingURL=native.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.info=void 0;var tslib_1=require("tslib"),code_builder_1=require("../../helpers/code-builder"),__1=require("../.."),utils_1=require("../../../../utils"),code_helpers_1=require("../../helpers/code-helpers"),constants_1=require("../../helpers/constants"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.info=void 0;var tslib_1=require("tslib"),code_builder_1=require("../../helpers/code-builder"),__1=require("../.."),utils_1=require("../../../../utils"),code_helpers_1=require("../../helpers/code-helpers"),constants_1=require("../../helpers/constants"),types_1=require("../../../../../types"),hasQueryParams=function(e){return!(!e.uriObj.query||!Object.keys(e.uriObj.query).length)},getBody=function(e){return e.postData&&e.postData.mimeType===types_1.MediaTypes.URL_ENCODED?"HttpRequest.BodyPublishers.ofString(form)":e.postData?"HttpRequest.BodyPublishers.ofString(payload)":["POST","PUT","PATCH"].includes(e.method.toUpperCase())?'HttpRequest.BodyPublishers.ofString("some body text")':""},handler=function(e,t,a){var s,r,i,n=a.target,p=a.client,o=Object.assign({indent:" ",withWrapper:!0},t),l=new code_builder_1.CodeBuilder({indentation:o.indent,variablesPrefix:o.variablesPrefix,capitalize:!0,lang:constants_1.Lang.JAVA}),u=!1;if(o.withComments&&addComments(l,e),o.withImports&&addImports(l,e),o.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=e.securityOAuth2ExtraCalls)||void 0===s?void 0:s.length){var h=new __1.HTTPSnippet(null===(r=e.securityOAuth2ExtraCalls)||void 0===r?void 0:r[0]).convert(n,p,(0,tslib_1.__assign)((0,tslib_1.__assign)({},o),{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(e.postData)switch((0,utils_1.normalizeMimeType)(e.postData.mimeType)){case types_1.MediaTypes.URL_ENCODED:e.postData.params&&(l.push(2,"HashMap<String, String> params = new HashMap<>();"),e.postData.params.forEach((function(e){l.push(2,'params.put("%s", "%s");',e.name,e.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 types_1.MediaTypes.JSON:e.postData.jsonObj&&(l.push(2,'var payload = String.join("\\n"\n '+(0,code_helpers_1.addIndentation)(JSON.stringify(e.postData.jsonObj,null,1).replace(/"/g,'\\"').replace(/^/gm,', "').replace(/$/gm,'"'),{level:3,indent:o.indent,firstLine:!1})),l.push(2,");"),l.blank());break;case types_1.MediaTypes.XML:e.postData.text&&(l.push(2,'var payload = String.join("\\n"'),e.postData.text.trim().split("\n").forEach((function(e){var t=e.replace(/"/g,'\\"');l.push(3,', "'+t+'"')})),l.push(2,");"),l.blank());break;case types_1.MediaTypes.MULTIPART:u=!0,l.unshift("# multipart/form-data is not supported yet\n")}if(hasQueryParams(e)){l.push(2,"HashMap<String, String> params = new HashMap<>();");for(var d=0,c=Object.entries(e.uriObj.query);d<c.length;d++){var m=c[d],v=m[0],y=m[1];l.push(2,'params.put("%s", "%s");',v,y)}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";',e.uriObj.protocol+"//"+e.uriObj.host),(0,code_helpers_1.printUrlVariablesDeclarations)(e,l,2);var b=(0,tslib_1.__assign)((0,tslib_1.__assign)({},e),{pathname:e.uriObj.pathname});l.push(2,"var "+l.var("pathname")+" = %s;",(0,code_helpers_1.buildUrlExpression)(b,l)),l.push(2,"var "+l.var("request")+" = HttpRequest.newBuilder()"),"PATCH"===e.method.toUpperCase()?l.push(3,'.method("PATCH", %s)',getBody(e)):l.push(3,".%s(%s)",e.method.toUpperCase(),getBody(e)),l.push(3,".uri(URI.create("+l.var("host")+" + "+l.var("pathname")+" %s))",hasQueryParams(e)?"+ '?' + query":""),(null===(i=e.securityOAuth2ExtraCalls)||void 0===i?void 0:i.length)&&(e.allHeaders.Authorization='"Bearer " + accessToken');var g=Object.keys(e.allHeaders);if(g.length&&g.forEach((function(t){var a;l.push(3,'.header("%s", %s)',t,"Authorization"===t&&(null===(a=e.securityOAuth2ExtraCalls)||void 0===a?void 0:a.length)?e.allHeaders[t]:'"'+e.allHeaders[t]+'"')})),e.basicAuth){var _=e.basicAuth,f=_.username,j=_.password;l.push(3,'.header("Authorization", "Basic " + Base64.getEncoder().encodeToString(("'+f+":"+j+'").getBytes()))')}return l.push(3,".build();"),o.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()};function addComments(e,t){var a;e.push("/**"),e.push(" * Requires JDK >= 11"),(null===(a=t.securityOAuth2ExtraCalls)||void 0===a?void 0:a.length)&&(e.push(" *"),e.push(' * Requires package "org.json" >= 20201115'),e.push(" * See here for installation details:"),e.push(" * https://search.maven.org/artifact/org.json/json")),e.push(" */"),e.blank()}function addImports(e,t){var a,s,r,i;e.push("import java.net.*;"),e.push("import java.net.http.*;"),e.push("import java.util.*;"),((0,utils_1.normalizeMimeType)(null===(a=t.postData)||void 0===a?void 0:a.mimeType)===types_1.MediaTypes.URL_ENCODED&&(null===(s=t.postData)||void 0===s?void 0:s.params)||(null===(r=t.securityOAuth2ExtraCalls)||void 0===r?void 0:r.length)||hasQueryParams(t))&&(e.push("import java.nio.charset.StandardCharsets;"),e.push("import java.util.stream.Collectors;")),(null===(i=t.securityOAuth2ExtraCalls)||void 0===i?void 0:i.length)&&e.push("import org.json.JSONObject;"),e.blank()}exports.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 )"},exports.default=handler;
|
|
2
2
|
//# sourceMappingURL=httpclient.js.map
|