@redocly/reference-docs 2.31.1 → 2.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli/commands/redocly-docs-cli.min.js +105 -92
- package/bin/cli/commands/redocly-docs-cli.min.js.LICENSE.txt +1 -1
- package/dist/console.redocly-reference-docs.min.js +129 -132
- package/dist/oauth2-redirect.js +1 -1
- package/dist/redocly-reference-docs.min.js +624 -608
- package/lib/components/Endpoint/Endpoint.js +1 -1
- package/lib/components/Endpoint/ServerList.d.ts +1 -1
- package/lib/components/Endpoint/ServerList.js +1 -1
- package/lib/components/Endpoint/types.d.ts +1 -2
- package/lib/components/Panel/ContentPanel.js +1 -1
- package/lib/components/Panel/Description.d.ts +1 -0
- package/lib/components/Panel/Description.js +2 -0
- package/lib/components/Panel/PanelComponent.js +1 -1
- package/lib/components/Panel/index.d.ts +1 -0
- package/lib/components/Panel/index.js +1 -1
- package/lib/components/Samples/SamplesTabs.d.ts +3 -1
- package/lib/components/Samples/SamplesTabs.js +1 -1
- package/lib/components/Tabs/CollapsingTabs/CollapsingTabsBase.d.ts +1 -1
- package/lib/components/Tabs/CollapsingTabs/CollapsingTabsBase.js +1 -1
- package/lib/components/common/FileUpload/FileUpload.d.ts +3 -2
- package/lib/components/common/FileUpload/FileUpload.js +1 -1
- package/lib/components/console/AuthPanel.d.ts +1 -1
- package/lib/components/console/AuthPanel.js +1 -1
- package/lib/components/console/CodemirrorInput.d.ts +15 -11
- package/lib/components/console/CodemirrorInput.js +1 -1
- package/lib/components/console/Console.d.ts +3 -3
- package/lib/components/console/Console.js +1 -1
- package/lib/components/console/ConsoleLazy.js +1 -1
- package/lib/components/console/OAuth2Flow.d.ts +1 -1
- package/lib/components/console/OAuth2TokenInput.d.ts +1 -1
- package/lib/components/console/OpenIDConnect.d.ts +4 -1
- package/lib/components/console/OpenIDConnect.js +1 -1
- package/lib/components/console/RequestBody/RequestBody.d.ts +3 -0
- package/lib/components/console/RequestBody/RequestBody.js +2 -0
- package/lib/components/console/RequestBody/index.d.ts +2 -0
- package/lib/components/console/RequestBody/index.js +2 -0
- package/lib/components/console/RequestBody/types.d.ts +10 -0
- package/lib/components/console/RequestBody/types.js +2 -0
- package/lib/components/console/RequestBodyForm.d.ts +3 -2
- package/lib/components/console/ServersDropdown/ServersDropdown.d.ts +3 -0
- package/lib/components/console/ServersDropdown/ServersDropdown.js +2 -0
- package/lib/components/console/ServersDropdown/index.d.ts +1 -0
- package/lib/components/console/ServersDropdown/index.js +2 -0
- package/lib/components/console/ServersDropdown/types.d.ts +5 -0
- package/lib/components/console/ServersDropdown/types.js +2 -0
- package/lib/components/console/styled.d.ts +1 -0
- package/lib/components/console/styled.js +1 -1
- package/lib/components/console/utils.d.ts +3 -1
- package/lib/components/console/utils.js +1 -1
- package/lib/hooks/index.d.ts +1 -0
- package/lib/hooks/index.js +1 -1
- package/lib/hooks/useDimensions.d.ts +1 -0
- package/lib/hooks/useDimensions.js +2 -0
- package/lib/index.d.ts +1 -1
- package/lib/oauth2-redirect-page/handler/helpers.d.ts +1 -0
- package/lib/oauth2-redirect-page/handler/helpers.js +1 -1
- package/lib/redoc-lib/src/common-elements/samples.js +1 -1
- package/lib/redoc-lib/src/components/CallbackSamples/CallbackSamples.d.ts +0 -1
- package/lib/redoc-lib/src/components/CallbackSamples/CallbackSamples.js +1 -1
- package/lib/redoc-lib/src/components/Callbacks/CallbackDetails.js +1 -1
- package/lib/redoc-lib/src/components/JsonViewer/style.js +1 -1
- package/lib/redoc-lib/src/components/Operation/Operation.js +1 -1
- package/lib/redoc-lib/src/components/RequestSamples/RequestSamples.js +1 -1
- package/lib/redoc-lib/src/components/Responses/Response.d.ts +2 -5
- package/lib/redoc-lib/src/components/Responses/Response.js +1 -1
- package/lib/redoc-lib/src/components/Responses/ResponseDetails.d.ts +3 -8
- package/lib/redoc-lib/src/components/Responses/ResponseDetails.js +1 -1
- package/lib/redoc-lib/src/components/Responses/ResponseHeaders.d.ts +3 -9
- package/lib/redoc-lib/src/components/Responses/ResponseHeaders.js +1 -1
- package/lib/redoc-lib/src/components/Responses/ResponseSummary.d.ts +1 -5
- package/lib/redoc-lib/src/components/Responses/ResponsesList.d.ts +3 -8
- package/lib/redoc-lib/src/components/Responses/ResponsesList.js +1 -1
- package/lib/redoc-lib/src/components/Responses/index.d.ts +1 -0
- package/lib/redoc-lib/src/components/Responses/index.js +2 -0
- package/lib/redoc-lib/src/components/Responses/{styled.elements.d.ts → styled.d.ts} +1 -0
- package/lib/redoc-lib/src/components/Responses/styled.js +2 -0
- package/lib/redoc-lib/src/components/Responses/types.d.ts +12 -0
- package/lib/redoc-lib/src/components/Responses/types.js +2 -0
- package/lib/redoc-lib/src/components/SecurityRequirement/SecurityRequirementPanelDescription.js +1 -1
- package/lib/redoc-lib/src/components/SourceCode/SourceCode.d.ts +3 -5
- package/lib/redoc-lib/src/components/SourceCode/SourceCode.js +1 -1
- package/lib/redoc-lib/src/theme.d.ts +9 -0
- package/lib/redoc-lib/src/theme.js +1 -1
- package/lib/services/code-samples/generator.d.ts +1 -0
- package/lib/services/code-samples/generator.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/python/requests.js +1 -1
- package/lib/services/extendTheme.d.ts +1 -1
- package/lib/standalone.js +1 -1
- package/lib/types.d.ts +11 -0
- package/lib/utils.d.ts +3 -13
- package/lib/utils.js +1 -1
- package/lib-esm/components/Endpoint/Endpoint.js +1 -1
- package/lib-esm/components/Endpoint/ServerList.d.ts +1 -1
- package/lib-esm/components/Endpoint/ServerList.js +1 -1
- package/lib-esm/components/Endpoint/types.d.ts +1 -2
- package/lib-esm/components/Panel/ContentPanel.js +1 -1
- package/lib-esm/components/Panel/Description.d.ts +1 -0
- package/lib-esm/components/Panel/Description.js +2 -0
- package/lib-esm/components/Panel/PanelComponent.js +1 -1
- package/lib-esm/components/Panel/index.d.ts +1 -0
- package/lib-esm/components/Panel/index.js +1 -1
- package/lib-esm/components/Samples/SamplesTabs.d.ts +3 -1
- package/lib-esm/components/Samples/SamplesTabs.js +1 -1
- package/lib-esm/components/Tabs/CollapsingTabs/CollapsingTabsBase.d.ts +1 -1
- package/lib-esm/components/Tabs/CollapsingTabs/CollapsingTabsBase.js +1 -1
- package/lib-esm/components/common/FileUpload/FileUpload.d.ts +3 -2
- package/lib-esm/components/common/FileUpload/FileUpload.js +1 -1
- package/lib-esm/components/console/AuthPanel.d.ts +1 -1
- package/lib-esm/components/console/AuthPanel.js +1 -1
- package/lib-esm/components/console/CodemirrorInput.d.ts +15 -11
- package/lib-esm/components/console/CodemirrorInput.js +1 -1
- package/lib-esm/components/console/Console.d.ts +3 -3
- package/lib-esm/components/console/Console.js +1 -1
- package/lib-esm/components/console/ConsoleLazy.js +1 -1
- package/lib-esm/components/console/OAuth2Flow.d.ts +1 -1
- package/lib-esm/components/console/OAuth2TokenInput.d.ts +1 -1
- package/lib-esm/components/console/OpenIDConnect.d.ts +4 -1
- package/lib-esm/components/console/OpenIDConnect.js +1 -1
- package/lib-esm/components/console/RequestBody/RequestBody.d.ts +3 -0
- package/lib-esm/components/console/RequestBody/RequestBody.js +2 -0
- package/lib-esm/components/console/RequestBody/index.d.ts +2 -0
- package/lib-esm/components/console/RequestBody/index.js +2 -0
- package/lib-esm/components/console/RequestBody/types.d.ts +10 -0
- package/lib-esm/components/console/RequestBody/types.js +2 -0
- package/lib-esm/components/console/RequestBodyForm.d.ts +3 -2
- package/lib-esm/components/console/ServersDropdown/ServersDropdown.d.ts +3 -0
- package/lib-esm/components/console/ServersDropdown/ServersDropdown.js +2 -0
- package/lib-esm/components/console/ServersDropdown/index.d.ts +1 -0
- package/lib-esm/components/console/ServersDropdown/index.js +2 -0
- package/lib-esm/components/console/ServersDropdown/types.d.ts +5 -0
- package/lib-esm/components/console/ServersDropdown/types.js +2 -0
- package/lib-esm/components/console/styled.d.ts +1 -0
- package/lib-esm/components/console/styled.js +1 -1
- package/lib-esm/components/console/utils.d.ts +3 -1
- package/lib-esm/components/console/utils.js +1 -1
- package/lib-esm/hooks/index.d.ts +1 -0
- package/lib-esm/hooks/index.js +1 -1
- package/lib-esm/hooks/useDimensions.d.ts +1 -0
- package/lib-esm/hooks/useDimensions.js +2 -0
- package/lib-esm/index.d.ts +1 -1
- package/lib-esm/oauth2-redirect-page/handler/helpers.d.ts +1 -0
- package/lib-esm/oauth2-redirect-page/handler/helpers.js +1 -1
- package/lib-esm/redoc-lib/src/common-elements/samples.js +1 -1
- package/lib-esm/redoc-lib/src/components/CallbackSamples/CallbackSamples.d.ts +0 -1
- package/lib-esm/redoc-lib/src/components/CallbackSamples/CallbackSamples.js +1 -1
- package/lib-esm/redoc-lib/src/components/Callbacks/CallbackDetails.js +1 -1
- package/lib-esm/redoc-lib/src/components/JsonViewer/style.js +1 -1
- package/lib-esm/redoc-lib/src/components/Operation/Operation.js +1 -1
- package/lib-esm/redoc-lib/src/components/RequestSamples/RequestSamples.js +1 -1
- package/lib-esm/redoc-lib/src/components/Responses/Response.d.ts +2 -5
- package/lib-esm/redoc-lib/src/components/Responses/Response.js +1 -1
- package/lib-esm/redoc-lib/src/components/Responses/ResponseDetails.d.ts +3 -8
- package/lib-esm/redoc-lib/src/components/Responses/ResponseDetails.js +1 -1
- package/lib-esm/redoc-lib/src/components/Responses/ResponseHeaders.d.ts +3 -9
- package/lib-esm/redoc-lib/src/components/Responses/ResponseHeaders.js +1 -1
- package/lib-esm/redoc-lib/src/components/Responses/ResponseSummary.d.ts +1 -5
- package/lib-esm/redoc-lib/src/components/Responses/ResponsesList.d.ts +3 -8
- package/lib-esm/redoc-lib/src/components/Responses/ResponsesList.js +1 -1
- package/lib-esm/redoc-lib/src/components/Responses/index.d.ts +1 -0
- package/lib-esm/redoc-lib/src/components/Responses/index.js +2 -0
- package/lib-esm/redoc-lib/src/components/Responses/{styled.elements.d.ts → styled.d.ts} +1 -0
- package/lib-esm/redoc-lib/src/components/Responses/styled.js +2 -0
- package/lib-esm/redoc-lib/src/components/Responses/types.d.ts +12 -0
- package/lib-esm/redoc-lib/src/components/Responses/types.js +2 -0
- package/lib-esm/redoc-lib/src/components/SecurityRequirement/SecurityRequirementPanelDescription.js +1 -1
- package/lib-esm/redoc-lib/src/components/SourceCode/SourceCode.d.ts +3 -5
- package/lib-esm/redoc-lib/src/components/SourceCode/SourceCode.js +1 -1
- package/lib-esm/redoc-lib/src/theme.d.ts +9 -0
- package/lib-esm/redoc-lib/src/theme.js +1 -1
- package/lib-esm/services/code-samples/generator.d.ts +1 -0
- package/lib-esm/services/code-samples/generator.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/python/requests.js +1 -1
- package/lib-esm/services/extendTheme.d.ts +1 -1
- package/lib-esm/standalone.js +1 -1
- package/lib-esm/types.d.ts +11 -0
- package/lib-esm/utils.d.ts +3 -13
- package/lib-esm/utils.js +1 -1
- package/package.json +3 -2
- package/lib/components/console/RequestBody.d.ts +0 -12
- package/lib/components/console/RequestBody.js +0 -2
- package/lib/components/console/ServerDropdown.d.ts +0 -24
- package/lib/components/console/ServerDropdown.js +0 -2
- package/lib/redoc-lib/src/components/Responses/styled.elements.js +0 -2
- package/lib-esm/components/console/RequestBody.d.ts +0 -12
- package/lib-esm/components/console/RequestBody.js +0 -2
- package/lib-esm/components/console/ServerDropdown.d.ts +0 -24
- package/lib-esm/components/console/ServerDropdown.js +0 -2
- package/lib-esm/redoc-lib/src/components/Responses/styled.elements.js +0 -2
package/lib-esm/redoc-lib/src/components/SecurityRequirement/SecurityRequirementPanelDescription.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React,{useState}from"react";import{AUTH_TYPES}from"./SecurityRequirement";export var SecurityRequirementPanelDescription=function(e){var t=e.securities,r=e.showSecuritySchemeType,n=React.createRef(),c=useState(""),a=c[0],u=c[1];return React.useLayoutEffect((function(){var e;u((null===(e=n.current)||void 0===e?void 0:e.innerText)||"")}),[n]),React.createElement("span",{ref:n,title:a},t.map((function(e,n){var c="",a="",u=e.schemes.length;return t.length>1&&u>1&&(c=0===n?"(":"",a=")"),n!==t.length-1&&(a+=" or "),React.createElement(React.Fragment,{key:n},c,u?e.schemes.map((function(e,t){return React.createElement("b",{key:t},r?(AUTH_TYPES[e.type]||e.type)+": ":null,e.id)})).reduce((function(e,t){return[e," and ",t]})):null,a)})))};
|
|
2
2
|
//# sourceMappingURL=SecurityRequirementPanelDescription.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import type { ExternalSource } from '../../services/types';
|
|
3
3
|
import type { FileInfo } from '../../common-elements/Download';
|
|
4
4
|
export interface SourceCodeProps {
|
|
@@ -6,8 +6,6 @@ export interface SourceCodeProps {
|
|
|
6
6
|
source?: string;
|
|
7
7
|
externalSource?: ExternalSource;
|
|
8
8
|
}
|
|
9
|
-
export declare
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
export declare function SourceCodeWithText(props: SourceCodeProps): JSX.Element;
|
|
9
|
+
export declare const SourceCode: ({ source, lang, }: Required<Omit<SourceCodeProps, 'externalSource'>>) => JSX.Element;
|
|
10
|
+
export declare function SourceCodeWithText({ source: _source, lang, externalSource: _externalSource, }: SourceCodeProps): JSX.Element;
|
|
13
11
|
export declare function SourceCodeWithFile(props: FileInfo): JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React,{useEffect,useState}from"react";import{highlight}from"../../utils";import{FileIcon,SampleControls,SampleControlsWrap,StyledPre}from"../../common-elements";import{CopyButtonWrapper}from"../../common-elements/CopyButtonWrapper";import{Download}from"../../common-elements/Download";export var SourceCode=function(e){var t=e.source,o=e.lang;return React.createElement(StyledPre,{"data-cy":"code-samples",dangerouslySetInnerHTML:{__html:highlight(t,o)}})};export function SourceCodeWithText(e){var t=e.source,o=e.lang,l=e.externalSource,r=useState(null!=t?t:""),n=r[0],a=r[1];return useEffect((function(){var e,o,r=t||(null===(o=null===(e=null==l?void 0:l.sample)||void 0===e?void 0:e.get)||void 0===o?void 0:o.call(e,l));r&&a(r)}),[t,l]),React.createElement(CopyButtonWrapper,{data:n},(function(e){var t=e.renderCopyButton;return React.createElement(SampleControlsWrap,null,React.createElement(SampleControls,null,t()),React.createElement(SourceCode,{lang:o,source:n}))}))}export function SourceCodeWithFile(e){var t;return React.createElement(SampleControlsWrap,null,React.createElement(SampleControls,null,React.createElement(Download,{fileInfo:e.fileInfo})),React.createElement(StyledPre,null,React.createElement(FileIcon,{color:"light"})," ",null===(t=e.fileInfo)||void 0===t?void 0:t.fileName))}
|
|
2
2
|
//# sourceMappingURL=SourceCode.js.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Typography } from '../../services/extendTheme';
|
|
1
2
|
declare const defaultTheme: ThemeInterface;
|
|
2
3
|
export default defaultTheme;
|
|
3
4
|
export declare function resolveTheme(theme: ThemeInterface): ResolvedThemeInterface;
|
|
@@ -174,6 +175,13 @@ export interface ResolvedThemeInterface {
|
|
|
174
175
|
panels: {
|
|
175
176
|
borderRadius: string;
|
|
176
177
|
backgroundColor: string;
|
|
178
|
+
title: Typography & {
|
|
179
|
+
fontFamily: MediaValue;
|
|
180
|
+
};
|
|
181
|
+
subTitle: Typography & {
|
|
182
|
+
fontFamily: MediaValue;
|
|
183
|
+
};
|
|
184
|
+
iconColor: string;
|
|
177
185
|
};
|
|
178
186
|
layoutControls: {
|
|
179
187
|
top: string;
|
|
@@ -213,6 +221,7 @@ export interface ResolvedThemeInterface {
|
|
|
213
221
|
};
|
|
214
222
|
codeBlock: {
|
|
215
223
|
backgroundColor: string;
|
|
224
|
+
maxHeight: string;
|
|
216
225
|
};
|
|
217
226
|
layout: {
|
|
218
227
|
showDarkRightPanel?: boolean;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var _a,_b;import{darken,lighten,readableColor,transparentize}from"polished";import{ZERO_BREAKPOINT}from"./utils/media-css";var defaultTheme={spacing:{unit:5,sectionHorizontal:function(r){return 8*r.spacing.unit},sectionVertical:function(r){return 4*r.spacing.unit}},breakpoints:{small:"50rem",medium:"85rem",large:"105rem"},colors:{tonalOffset:.2,primary:{main:"#0065FB",light:function(r){var o=r.colors;return lighten(o.tonalOffset,o.primary.main)},dark:function(r){var o=r.colors;return darken(o.tonalOffset,o.primary.main)},contrastText:function(r){var o=r.colors;return readableColor(o.primary.main)}},secondary:{main:"#E4E7EB",light:"#F5F7FA",dark:"#E4E7EB",contrastText:"#3E4C59"},accent:{main:"#59C3FF",light:"#b3dcf3",dark:"#033B73",contrastText:"#ffffff"},success:{main:"#41DE50",light:function(r){var o=r.colors;return lighten(2*o.tonalOffset,o.success.main)},dark:function(r){var o=r.colors;return darken(o.tonalOffset,o.success.main)},contrastText:function(r){var o=r.colors;return readableColor(o.success.main)}},warning:{main:"#ffa500",light:function(r){var o=r.colors;return lighten(o.tonalOffset,o.warning.main)},dark:function(r){var o=r.colors;return darken(o.tonalOffset,o.warning.main)},contrastText:"#ffffff"},error:{main:"#FF6161",light:function(r){var o=r.colors;return lighten(o.tonalOffset,o.error.main)},dark:function(r){var o=r.colors;return darken(o.tonalOffset,o.error.main)},contrastText:"#ffffff"},text:{primary:"#1F2933",secondary:"#7b8794",light:"#F5F7FA"},border:{dark:"#616E7C",light:"#E4E7EB"},responses:{success:{borderColor:"#B1E996",backgroundColor:"#F6FFF4",tabTextColor:function(r){return r.colors.responses.success.borderColor}},error:{borderColor:"#FFC9C9",backgroundColor:"#FFF4F4",tabTextColor:function(r){return r.colors.responses.error.borderColor}},redirect:{borderColor:function(r){return r.colors.warning.main},backgroundColor:function(r){var o=r.colors;return transparentize(.9,o.responses.redirect.borderColor)},tabTextColor:function(r){return r.colors.responses.redirect.borderColor}},info:{borderColor:"#87ceeb",backgroundColor:function(r){var o=r.colors;return transparentize(.9,o.responses.info.borderColor)},tabTextColor:function(r){return r.colors.responses.info.borderColor}}},http:{get:"#3A9601",post:"#0065FB",put:"#93527B",options:"#947014",patch:"#bf581d",delete:"#C83637",basic:"#707070",link:"#07818F",head:"#A23DAD"}},schema:{linesColor:function(r){return r.colors.border.light},defaultDetailsWidth:"70%",typeNameColor:function(r){return r.colors.text.secondary},typeTitleColor:function(r){return r.schema.typeNameColor},requireLabelColor:"#FF0000",labelsTextSize:"0.9em",nestingSpacing:"1em",nestedBackground:function(r){return r.colors.secondary.light},nestedAlternativeBackground:"#ffffff",caretColor:function(r){return r.colors.text.primary},caretSize:"9px"},typography:{fontSize:"14px",lineHeight:"1.5em",fontWeightRegular:"400",fontWeightBold:"600",fontWeightLight:"300",fontFamily:"Source Sans Pro, sans-serif",smoothing:"antialiased",optimizeSpeed:!0,headings:{fontFamily:function(r){return r.typography.fontFamily},fontWeight:"700",lineHeight:"1.6em"},code:{fontSize:"13px",fontFamily:"Source Code Pro, monospace",lineHeight:function(r){return r.typography.lineHeight},fontWeight:function(r){return r.typography.fontWeightRegular},color:"#e53935",backgroundColor:"rgba(38, 50, 56, 0.05)",wrap:!1},links:{color:function(r){return r.colors.primary.main},visited:function(r){return r.typography.links.color},hover:function(r){var o=r.typography;return lighten(.2,o.links.color)},textDecoration:"auto",hoverTextDecoration:"auto"},fieldName:{fontSize:function(r){return r.typography.code.fontSize},fontFamily:function(r){return r.typography.code.fontFamily},fontWeight:function(r){return r.typography.code.fontWeight}}},sidebar:{separatorLabelColor:function(r){return r.sidebar.textColor},separatorLineColor:"#DADADA",caretColor:function(r){return r.sidebar.textColor},caretSize:function(r){return r.sidebar.spacing.unit},spacing:{unit:8,paddingHorizontal:function(r){return r.sidebar.spacing.unit},paddingVertical:function(r){return r.sidebar.spacing.unit},offsetTop:function(r){return 2*r.sidebar.spacing.unit},offsetLeft:function(r){return 2*r.sidebar.spacing.unit},offsetNesting:function(r){return 2*r.sidebar.spacing.unit}},borderRadius:"4px",fontFamily:function(r){return r.typography.fontFamily},fontSize:function(r){return r.typography.fontSize},showAtBreakpoint:"small",width:"285px",backgroundColor:"#fff",rightLineColor:function(r){return r.colors.border.light},textColor:function(r){return r.colors.text.primary},activeTextColor:function(r){return r.sidebar.textColor},activeBgColor:function(r){return r.colors.border.light}},components:{buttons:{borderRadius:function(r){return r.shape.borderRadius},hoverStyle:"",fontWeight:function(r){return r.typography.fontWeightBold},boxShadow:"none",hoverBoxShadow:"0px 0px 12px 0px rgba(0, 0, 0, 0.1)",fontFamily:"inherit",sizes:{small:{fontSize:"12px",padding:"8px 10px",minWidth:"90px"},medium:{fontSize:"14px",padding:"8px 20px",minWidth:"120px"},large:{fontSize:"14px",padding:"12px 24px",minWidth:"150px"},xlarge:{fontSize:"16px",padding:"20px 24px",minWidth:"200px"}}},httpBadges:{borderRadius:"16px",fontFamily:function(r){return r.typography.code.fontFamily},fontWeight:function(r){return r.typography.fontWeightBold},color:function(r){return r.colors.text.light},sizes:{medium:{fontSize:"12px",lineHeight:"20px"},small:{fontSize:"8px",lineHeight:"15px"}}},tryItButton:{fullWidth:!1},tryItSendButton:{fullWidth:!1},panels:{borderRadius:"8px",backgroundColor:"#fff"},layoutControls:{top:"20px",width:"36px",height:"36px"}},logo:{maxHeight:function(r){return r.sidebar.width},maxWidth:function(r){return r.sidebar.width},gutter:"2px"},fab:{backgroundColor:"#f2f2f2",color:"#0065FB"},rightPanel:{showAtBreakpoint:"medium",backgroundColor:"#1F2933",panelBackgroundColor:"#52606D",panelControlsBackgroundColor:"#323F4B",width:"37.5%",textColor:"#ffffff"},codeBlock:{backgroundColor:function(r){return r.rightPanel.panelControlsBackgroundColor}},shape:{borderRadius:"4px"},layout:{showDarkRightPanel:!1,stacked:{maxWidth:(_a={},_a[ZERO_BREAKPOINT]="",_a.small="90%",_a.medium="75%",_a.large="1200px",_a)},"three-panel":{middlePanelMaxWidth:"none",maxWidth:(_b={},_b[ZERO_BREAKPOINT]="100%",_b.small="100%",_b.medium="100%",_b.large="1800px",_b)}}};export default defaultTheme;export function resolveTheme(r){var o={},t=0,n=function(e,i){Object.keys(e).forEach((function(a){var l=(i?i+".":"")+a,
|
|
1
|
+
var _a,_b;import{darken,lighten,readableColor,transparentize}from"polished";import{ZERO_BREAKPOINT}from"./utils/media-css";var defaultTheme={spacing:{unit:5,sectionHorizontal:function(r){return 8*r.spacing.unit},sectionVertical:function(r){return 4*r.spacing.unit}},breakpoints:{small:"50rem",medium:"85rem",large:"105rem"},colors:{tonalOffset:.2,primary:{main:"#0065FB",light:function(r){var o=r.colors;return lighten(o.tonalOffset,o.primary.main)},dark:function(r){var o=r.colors;return darken(o.tonalOffset,o.primary.main)},contrastText:function(r){var o=r.colors;return readableColor(o.primary.main)}},secondary:{main:"#E4E7EB",light:"#F5F7FA",dark:"#E4E7EB",contrastText:"#3E4C59"},accent:{main:"#59C3FF",light:"#b3dcf3",dark:"#033B73",contrastText:"#ffffff"},success:{main:"#41DE50",light:function(r){var o=r.colors;return lighten(2*o.tonalOffset,o.success.main)},dark:function(r){var o=r.colors;return darken(o.tonalOffset,o.success.main)},contrastText:function(r){var o=r.colors;return readableColor(o.success.main)}},warning:{main:"#ffa500",light:function(r){var o=r.colors;return lighten(o.tonalOffset,o.warning.main)},dark:function(r){var o=r.colors;return darken(o.tonalOffset,o.warning.main)},contrastText:"#ffffff"},error:{main:"#FF6161",light:function(r){var o=r.colors;return lighten(o.tonalOffset,o.error.main)},dark:function(r){var o=r.colors;return darken(o.tonalOffset,o.error.main)},contrastText:"#ffffff"},text:{primary:"#1F2933",secondary:"#7b8794",light:"#F5F7FA"},border:{dark:"#616E7C",light:"#E4E7EB"},responses:{success:{borderColor:"#B1E996",backgroundColor:"#F6FFF4",tabTextColor:function(r){return r.colors.responses.success.borderColor}},error:{borderColor:"#FFC9C9",backgroundColor:"#FFF4F4",tabTextColor:function(r){return r.colors.responses.error.borderColor}},redirect:{borderColor:function(r){return r.colors.warning.main},backgroundColor:function(r){var o=r.colors;return transparentize(.9,o.responses.redirect.borderColor)},tabTextColor:function(r){return r.colors.responses.redirect.borderColor}},info:{borderColor:"#87ceeb",backgroundColor:function(r){var o=r.colors;return transparentize(.9,o.responses.info.borderColor)},tabTextColor:function(r){return r.colors.responses.info.borderColor}}},http:{get:"#3A9601",post:"#0065FB",put:"#93527B",options:"#947014",patch:"#bf581d",delete:"#C83637",basic:"#707070",link:"#07818F",head:"#A23DAD"}},schema:{linesColor:function(r){return r.colors.border.light},defaultDetailsWidth:"70%",typeNameColor:function(r){return r.colors.text.secondary},typeTitleColor:function(r){return r.schema.typeNameColor},requireLabelColor:"#FF0000",labelsTextSize:"0.9em",nestingSpacing:"1em",nestedBackground:function(r){return r.colors.secondary.light},nestedAlternativeBackground:"#ffffff",caretColor:function(r){return r.colors.text.primary},caretSize:"9px"},typography:{fontSize:"14px",lineHeight:"1.5em",fontWeightRegular:"400",fontWeightBold:"600",fontWeightLight:"300",fontFamily:"Source Sans Pro, sans-serif",smoothing:"antialiased",optimizeSpeed:!0,headings:{fontFamily:function(r){return r.typography.fontFamily},fontWeight:"700",lineHeight:"1.6em"},code:{fontSize:"13px",fontFamily:"Source Code Pro, monospace",lineHeight:function(r){return r.typography.lineHeight},fontWeight:function(r){return r.typography.fontWeightRegular},color:"#e53935",backgroundColor:"rgba(38, 50, 56, 0.05)",wrap:!1},links:{color:function(r){return r.colors.primary.main},visited:function(r){return r.typography.links.color},hover:function(r){var o=r.typography;return lighten(.2,o.links.color)},textDecoration:"auto",hoverTextDecoration:"auto"},fieldName:{fontSize:function(r){return r.typography.code.fontSize},fontFamily:function(r){return r.typography.code.fontFamily},fontWeight:function(r){return r.typography.code.fontWeight}}},sidebar:{separatorLabelColor:function(r){return r.sidebar.textColor},separatorLineColor:"#DADADA",caretColor:function(r){return r.sidebar.textColor},caretSize:function(r){return r.sidebar.spacing.unit},spacing:{unit:8,paddingHorizontal:function(r){return r.sidebar.spacing.unit},paddingVertical:function(r){return r.sidebar.spacing.unit},offsetTop:function(r){return 2*r.sidebar.spacing.unit},offsetLeft:function(r){return 2*r.sidebar.spacing.unit},offsetNesting:function(r){return 2*r.sidebar.spacing.unit}},borderRadius:"4px",fontFamily:function(r){return r.typography.fontFamily},fontSize:function(r){return r.typography.fontSize},showAtBreakpoint:"small",width:"285px",backgroundColor:"#fff",rightLineColor:function(r){return r.colors.border.light},textColor:function(r){return r.colors.text.primary},activeTextColor:function(r){return r.sidebar.textColor},activeBgColor:function(r){return r.colors.border.light}},components:{buttons:{borderRadius:function(r){return r.shape.borderRadius},hoverStyle:"",fontWeight:function(r){return r.typography.fontWeightBold},boxShadow:"none",hoverBoxShadow:"0px 0px 12px 0px rgba(0, 0, 0, 0.1)",fontFamily:"inherit",sizes:{small:{fontSize:"12px",padding:"8px 10px",minWidth:"90px"},medium:{fontSize:"14px",padding:"8px 20px",minWidth:"120px"},large:{fontSize:"14px",padding:"12px 24px",minWidth:"150px"},xlarge:{fontSize:"16px",padding:"20px 24px",minWidth:"200px"}}},httpBadges:{borderRadius:"16px",fontFamily:function(r){return r.typography.code.fontFamily},fontWeight:function(r){return r.typography.fontWeightBold},color:function(r){return r.colors.text.light},sizes:{medium:{fontSize:"12px",lineHeight:"20px"},small:{fontSize:"8px",lineHeight:"15px"}}},tryItButton:{fullWidth:!1},tryItSendButton:{fullWidth:!1},panels:{borderRadius:"8px",backgroundColor:"#fff",title:{fontSize:"18px",fontWeight:function(r){return r.typography.headings.fontWeight},fontFamily:function(r){return r.typography.fontFamily},lineHeight:"18px",color:"#1F2933",transform:""},subTitle:{fontSize:"0.9em",fontWeight:"normal",fontFamily:function(r){return r.typography.fontFamily},lineHeight:"18px",color:"#1F2933",transform:""},iconColor:"#1F2933"},layoutControls:{top:"20px",width:"36px",height:"36px"}},logo:{maxHeight:function(r){return r.sidebar.width},maxWidth:function(r){return r.sidebar.width},gutter:"2px"},fab:{backgroundColor:"#f2f2f2",color:"#0065FB"},rightPanel:{showAtBreakpoint:"medium",backgroundColor:"#1F2933",panelBackgroundColor:"#52606D",panelControlsBackgroundColor:"#323F4B",width:"37.5%",textColor:"#ffffff"},codeBlock:{backgroundColor:function(r){return r.rightPanel.panelControlsBackgroundColor},maxHeight:"auto"},shape:{borderRadius:"4px"},layout:{showDarkRightPanel:!1,stacked:{maxWidth:(_a={},_a[ZERO_BREAKPOINT]="",_a.small="90%",_a.medium="75%",_a.large="1200px",_a)},"three-panel":{middlePanelMaxWidth:"none",maxWidth:(_b={},_b[ZERO_BREAKPOINT]="100%",_b.small="100%",_b.medium="100%",_b.large="1800px",_b)}}};export default defaultTheme;export function resolveTheme(r){var o={},t=0,n=function(e,i){Object.keys(e).forEach((function(a){var l=(i?i+".":"")+a,f=e[a];"function"==typeof f?Object.defineProperty(e,a,{get:function(){if(!o[l]){if(++t>1e3)throw new Error("Theme probably contains circular dependency at "+l+": "+f.toString());o[l]=f(r)}return o[l]},enumerable:!0}):"object"==typeof f&&n(f,l)}))};return n(r,""),JSON.parse(JSON.stringify(r))}
|
|
2
2
|
//# sourceMappingURL=theme.js.map
|
|
@@ -11,6 +11,7 @@ export declare type CustomHAR = HAR.Request & {
|
|
|
11
11
|
[key in string]: string;
|
|
12
12
|
};
|
|
13
13
|
serverVariables?: ServerVariables;
|
|
14
|
+
allResponseCodes?: string[];
|
|
14
15
|
};
|
|
15
16
|
export declare function getCodeSample({ lang, operation, exampleName, pathParams, properties, options, }: {
|
|
16
17
|
lang: Languages;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign}from"tslib";import{parse as parseQueryString,stringify as stringifyQueryString}from"query-string";import*as Sampler from"openapi-sampler";import merge from"deepmerge";import{toJS}from"mobx";import{deleteEmptyArrayItem,isArrayOfObjects,serializeParameterValue}from"../../redoc-lib";import{getSecurityDetails,getParameterValue}from"../../utils";import{normalizeMimeType,arrayMergeStrategy}from"../utils";import{MediaTypes}from"../../types";import{HTTPSnippet}from"./httpsnippet";function mapOperationToHAR(e,
|
|
1
|
+
import{__assign}from"tslib";import{parse as parseQueryString,stringify as stringifyQueryString}from"query-string";import*as Sampler from"openapi-sampler";import merge from"deepmerge";import{toJS}from"mobx";import{deleteEmptyArrayItem,isArrayOfObjects,serializeParameterValue}from"../../redoc-lib";import{getSecurityDetails,getParameterValue}from"../../utils";import{normalizeMimeType,arrayMergeStrategy}from"../utils";import{MediaTypes}from"../../types";import{l}from"../../redoc-lib/src/services/Labels";import{HTTPSnippet}from"./httpsnippet";import StringUtility from"./httpsnippet/helpers/string-utility";function mapOperationToHAR(e,t){var a,r,i,n,s,o,l,u,p,d,c=t.exampleName,m=void 0===c?"":c,v=t.skipOptionalParameters,h=void 0!==v&&v,f=t.withOAuth2Call,y=void 0!==f&&f,g=t.spec,O=t.generatedPayloadSamplesMaxDepth,S=void 0===O?8:O,_=t.pathParams,T=void 0===_?{}:_,C=t.properties,E=void 0===C?{}:C,b=getSecurityData(null===(a=e.security)||void 0===a?void 0:a[0],y),A=b.securityHeaders,P=b.securityCookies,R=b.securityQueries,w=b.securityOAuth2ExtraCalls,D=b.basicAuth,k=null===(i=null===(r=e.requestBody)||void 0===r?void 0:r.content)||void 0===i?void 0:i.active,q={skipNonRequired:h,skipReadOnly:!0,maxSampleDepth:S},H={path:toJS(null===(n=null==e?void 0:e.requestValues)||void 0===n?void 0:n.path),cookie:toJS(null===(s=null==e?void 0:e.requestValues)||void 0===s?void 0:s.cookie),header:toJS(null===(o=null==e?void 0:e.requestValues)||void 0===o?void 0:o.header),query:toJS(null===(l=null==e?void 0:e.requestValues)||void 0===l?void 0:l.query),body:toJS(null===(u=null==e?void 0:e.requestValues)||void 0===u?void 0:u.body)},x=!1,M=e.parameters.filter((function(e){return"header"===e.in})).filter((function(e){return!(h&&!e.required)})).map((function(e){var t;return{name:e.name,value:(null===(t=H.header)||void 0===t?void 0:t[e.name])||getParameterValue("header",e.name)||serializeParameterValue(e,Sampler.sample(e.schema.rawSchema,q,g))}})).map((function(e){return(null==k?void 0:k.name)&&"content-type"===e.name.toLowerCase()&&(x=!0,e.value=k.name),e})).concat(A);!x&&(null==k?void 0:k.name)&&M.unshift({name:"Content-Type",value:null==k?void 0:k.name});var N=e.parameters.filter((function(e){return"cookie"===e.in})).filter((function(e){return!(h&&!e.required)})).map((function(e){return parseQueryString(serializeParameterValue(e,Sampler.sample(e.schema.rawSchema,q,g)))})).reduce((function(e,t){for(var a,r=0,i=Object.entries(t);r<i.length;r++){var n=i[r],s=n[0],o=n[1];e.push({name:s,value:String((null===(a=H.cookie)||void 0===a?void 0:a[s])||o)})}return e}),[]).concat(P),U=e.parameters.filter((function(e){return"query"===e.in})).filter((function(e){return!(h&&!e.required)})).map((function(e){return parseQueryString(serializeParameterValue(e,Sampler.sample(e.schema.rawSchema,q,g)))})).reduce((function(e,t){for(var a,r,i,n=0,s=Object.entries(t);n<s.length;n++){var o=s[n],l=o[0],u=o[1];e.push({name:l,value:isArrayOfObjects(null===(a=H.query)||void 0===a?void 0:a[l])&&JSON.stringify(deleteEmptyArrayItem(null===(r=H.query)||void 0===r?void 0:r[l]))||String((null===(i=H.query)||void 0===i?void 0:i[l])||u)})}return e}),[]).concat(R),z=(null===(p=e.activeServer)||void 0===p?void 0:p.url.replace(/\/$/,""))+"/"+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=H.path)||void 0===a?void 0:a[i])||T[i]||getParameterValue(r,i),e}),{}),j=null===(d=null==k?void 0:k.examples)||void 0===d?void 0:d[m],I=(null==k?void 0:k.examples)||{},J=Object.values(I)[0],L=H.body||(null==j?void 0:j.value)||(null==J?void 0:J.value)||(null==k?void 0:k.schema)&&Sampler.sample(null==k?void 0:k.schema.rawSchema,q,g),Y=null==k?void 0:k.name.toLowerCase(),Q="",B=[];switch(normalizeMimeType(Y)){case MediaTypes.JSON:Q=JSON.stringify(getDataRequest(L,E));break;case MediaTypes.URL_ENCODED:case MediaTypes.MULTIPART:Q=stringifyQueryString(getDataRequest(L,E)),B=objectToHarParams(getDataRequest(L,E));break;default:Q=String(L||"")}var K=Q?{mimeType:(null==k?void 0:k.name)||MediaTypes.OCTET_STREAM,text:Q,params:B}:void 0,F=e.responses.map((function(e){return e.code}));return{method:e.httpVerb,url:z,httpVersion:"HTTP/1.1",cookies:N,headers:M,queryString:U,postData:K,headersSize:-1,bodySize:-1,securityOAuth2ExtraCalls:w,basicAuth:D,pathParameters:V,serverVariables:e.activeServer.variables,allResponseCodes:F}}var defaultOptions={withImports:!0,withComments:!1},langToSnippetConfig={curl:{code:"shell",defaultTarget:"curl",defaultOptions:__assign(__assign({},defaultOptions),{short:!0})},JavaScript:{code:"javascript",defaultTarget:"fetch",defaultOptions:__assign(__assign({},defaultOptions),{withImports:!1})},"Node.js":{code:"node",defaultTarget:"fetch",defaultOptions:__assign({},defaultOptions)},Python:{code:"python",defaultTarget:"requests",defaultOptions:__assign({},defaultOptions)},"Java8+Apache":{code:"java8",defaultTarget:"apachehttp",defaultOptions:__assign({},defaultOptions)},Java:{code:"java",defaultTarget:"httpclient",defaultOptions:__assign({},defaultOptions)},"C#":{code:"csharp",defaultTarget:"httpclient",defaultOptions:__assign({},defaultOptions)},Go:{code:"go",defaultTarget:"http.DefaultClient",defaultOptions:__assign({},defaultOptions)},PHP:{code:"php",defaultTarget:"curl",defaultOptions:__assign({},defaultOptions)},Ruby:{code:"ruby",defaultTarget:"net::http",defaultOptions:__assign({},defaultOptions)},R:{code:"r",defaultTarget:"httr",defaultOptions:__assign({},defaultOptions)}};export function getCodeSample(e){var t=e.lang,a=e.operation,r=e.exampleName,i=e.pathParams,n=e.properties,s=e.options,o=void 0===s?{}:s;try{var l=mapOperationToHAR(a,{exampleName:r,pathParams:i,properties:n,skipOptionalParameters:o.skipOptionalParameters,withOAuth2Call:o.withOAuth2Call,spec:o.spec,generatedPayloadSamplesMaxDepth:o.generatedPayloadSamplesMaxDepth}),u=new HTTPSnippet(l);return langToSnippetConfig[t]?u.convert(langToSnippetConfig[t].code,langToSnippetConfig[t].defaultTarget,__assign(__assign({},langToSnippetConfig[t].defaultOptions),o)):"Language is not supported."}catch(e){return console.error(e),"Failed to generate code sample."}}function getSecurityData(e,t){for(var a,r,i,n,s={securityHeaders:[],securityCookies:[],securityQueries:[],securityOAuth2ExtraCalls:[],basicAuth:void 0},o=0,u=(null==e?void 0:e.schemes)||[];o<u.length;o++){var p=u[o],d=getSecurityDetails(p.id);switch(p.type){case"openIdConnect":null===(a=s.securityHeaders)||void 0===a||a.push({name:"Authorization",value:"Bearer <YOUR_TOKEN_HERE>"});break;case"oauth2":var c=d.token?(d.token.token_type||"Bearer")+" "+d.token.access_token:"Bearer <YOUR_TOKEN_HERE>";p.flows.clientCredentials&&t?s.securityOAuth2ExtraCalls.push(getOAuth2ClientCredsCallHar(p.flows.clientCredentials,p.scopes,d)):p.flows.password&&t&&s.securityOAuth2ExtraCalls.push(getOAuth2PasswordCallHar(p.flows.password,p.scopes,d)),null===(r=s.securityHeaders)||void 0===r||r.push({name:"Authorization",value:c});break;case"apiKey":var m=d.raw||"YOUR_API_KEY_HERE";"header"===p.in&&(null===(i=s.securityHeaders)||void 0===i||i.push({name:p.name,value:m})),"cookie"===p.in&&s.securityCookies.push({name:p.name,value:m}),"query"===p.in&&s.securityQueries.push({name:p.name,value:m});break;case"http":"basic"===p.scheme?s.basicAuth={username:d.username||"<"+StringUtility.toSnakeCase(l("tryItAuthBasicUsername"))+">",password:d.password||"<"+StringUtility.toSnakeCase(l("tryItAuthBasicPassword"))+">"}:null===(n=s.securityHeaders)||void 0===n||n.push({name:"Authorization",value:capitalizeFirst(p.scheme||"bearer")+" <YOUR_"+(p.bearerFormat||"TOKEN")+"_HERE>"})}}return s}function getOAuth2PasswordCallHar(e,t,a){return{method:"POST",url:e.tokenUrl,httpVersion:"HTTP/1.1",headers:[{name:"Content-Type",value:MediaTypes.URL_ENCODED},{name:"Accept",value:MediaTypes.JSON}],queryString:[],postData:{mimeType:MediaTypes.URL_ENCODED,text:"",params:[{name:"grant_type",value:"password"},{name:"client_id",value:a.client_id||"YOUR_CLIENT_ID"},{name:"client_secret",value:a.client_secret||"YOUR_CLIENT_SECRET"},{name:"username",value:a.username||"<username>"},{name:"password",value:a.password||"<password>"},t.length?{name:"scope",value:t.join(" ")}:void 0].filter(isDefined)},cookies:[],headersSize:-1,bodySize:-1,securityOAuth2ExtraCalls:[]}}function getOAuth2ClientCredsCallHar(e,t,a){return{method:"POST",url:e.tokenUrl,httpVersion:"HTTP/1.1",headers:[{name:"Content-Type",value:MediaTypes.URL_ENCODED},{name:"Accept",value:MediaTypes.JSON}],queryString:[],postData:{mimeType:MediaTypes.URL_ENCODED,text:"",params:[{name:"grant_type",value:"client_credentials"},{name:"client_id",value:a.client_id||"YOUR_CLIENT_ID"},{name:"client_secret",value:a.client_secret||"YOUR_CLIENT_SECRET"},t.length?{name:"scope",value:t.join(" ")}:void 0].filter(isDefined)},cookies:[],headersSize:-1,bodySize:-1,securityOAuth2ExtraCalls:[]}}function getDataRequest(e,t){if(e){if("object"==typeof e)return merge(e,t,{arrayMerge:arrayMergeStrategy});try{return merge(JSON.parse(e),t,{arrayMerge:arrayMergeStrategy})}catch(e){return!1}}return!1}function objectToHarParams(e){for(var t=[],a=0,r=Object.entries(e);a<r.length;a++){var i=r[a],n=i[0],s=i[1];t.push({name:n,value:String(s)})}return t}export function isDefined(e){return void 0!==e}export function capitalizeFirst(e){return e.charAt(0).toUpperCase()+e.slice(1)}
|
|
2
2
|
//# sourceMappingURL=generator.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign}from"tslib";import stringifyObject from"stringify-object";import{CodeBuilder}from"../../helpers/code-builder";import{addIndentation,getPreserveTransformer,buildUrlExpression,printUrlVariablesDeclarations}from"../../helpers/code-helpers";import{normalizeMimeType}from"../../../../utils";import{HTTPSnippet}from"../..";import{Lang}from"../../helpers/constants";import{MediaTypes}from"../../../../../types";var handler=function(e,t,a){var r,i,n,
|
|
1
|
+
import{__assign}from"tslib";import stringifyObject from"stringify-object";import{CodeBuilder}from"../../helpers/code-builder";import{addIndentation,getPreserveTransformer,buildUrlExpression,printUrlVariablesDeclarations}from"../../helpers/code-helpers";import{normalizeMimeType}from"../../../../utils";import{HTTPSnippet}from"../..";import{Lang}from"../../helpers/constants";import{MediaTypes}from"../../../../../types";var handler=function(e,t,a){var r,i,s,n,o,d,l=a.target,p=a.client,h=__assign({indent:" ",credentials:null},t),c=new CodeBuilder({indentation:h.indent,variablesPrefix:h.variablesPrefix,capitalize:!0,lang:Lang.JAVASCRIPT}),m={method:e.method.toUpperCase()};Object.keys(e.headersObj).length&&(m.headers=e.headersObj);var u=!1;if(h.withComments&&addComments(c),null===(r=e.securityOAuth2ExtraCalls)||void 0===r?void 0:r.length){var f=new HTTPSnippet(null===(i=e.securityOAuth2ExtraCalls)||void 0===i?void 0:i[0]).convert(l,p,__assign(__assign({},h),{withImports:!1,withComments:!1,variablesPrefix:"oAuth2"}));c.push(f),c.blank(),m.headers=m.headers||{},m.headers.Authorization="'Bearer ' + oAuth2Data.access_token",u=!0}null!==h.credentials&&(m.credentials=h.credentials);var v=Object.getOwnPropertyNames(e.queryObj).length;if(v&&c.push("const "+c.var("query")+" = new URLSearchParams("+stringifyObject(e.queryObj,{indent:h.indent,inlineCharacterLimit:25})+").toString();").blank(),e.postData)switch(normalizeMimeType(e.postData.mimeType)){case MediaTypes.URL_ENCODED:m.body=e.postData.paramsObj?"new URLSearchParams("+c.var("formData")+").toString()":e.postData.text,e.postData.paramsObj&&c.push("const "+c.var("formData")+" = "+addIndentation(stringifyObject(e.postData.paramsObj,{indent:h.indent,inlineCharacterLimit:25}),{level:0,firstLine:!1})+";").blank();break;case MediaTypes.JSON:e.postData.jsonObj&&(m.body="JSON.stringify("+addIndentation(stringifyObject(e.postData.jsonObj,{indent:h.indent,inlineCharacterLimit:25}),{level:1,firstLine:!1})+")");break;case MediaTypes.MULTIPART:c.push("const "+c.var("form")+" = new FormData();"),(null===(s=null==m?void 0:m.headers)||void 0===s?void 0:s["Content-Type"])&&(null===(n=m.headers)||void 0===n||delete n["Content-Type"]),e.postData.params.forEach((function(e){c.push(c.var("form")+".append(%s, %s);",JSON.stringify(e.name),JSON.stringify(e.value||e.fileName||""))})),m.body=c.var("form"),c.blank();break;default:e.postData.text&&(m.body="`"+addIndentation(e.postData.text,{level:2,indent:h.indent,firstLine:!1}).trim()+"`")}var b=m.headers&&m.headers.Accept&&normalizeMimeType(m.headers.Accept)===MediaTypes.JSON||normalizeMimeType(null===(o=e.postData)||void 0===o?void 0:o.mimeType)===MediaTypes.JSON;if(e.basicAuth){var y=e.basicAuth,g=y.username,O=y.password;m.headers=m.headers||{},m.headers.Authorization="'Basic ' + btoa('"+g+":"+O+"')",u=!0}printUrlVariablesDeclarations(e,c);var T=buildUrlExpression(e,c);return c.push("const "+c.var("resp")+" = await fetch(").push(1,"`"+T+(v?"?${"+c.var("query")+"}":"")+"`,").push(addIndentation(stringifyObject(m,{indent:h.indent,inlineCharacterLimit:25,transform:getPreserveTransformer({body:!0,authorizationHeader:u})}),{level:1,indent:h.indent})).push(");").blank(),(null===(d=e.allResponseCodes)||void 0===d?void 0:d.includes("204"))?(c.push("if (resp.status === 204) {").push(1,"console.log('success');").push("} else {"),c.push(1,"const "+c.var("data")+" = await "+c.var("resp")+"."+(b?"json()":"text()")+";").push(1,"console.log("+c.var("data")+");").push("}")):c.push("const "+c.var("data")+" = await "+c.var("resp")+"."+(b?"json()":"text()")+";").push("console.log("+c.var("data")+");"),c.join()};function addComments(e){e.push("/**"),e.push(" * Requires ES8-compatible browser: https://caniuse.com/async-functions"),e.push(" */"),e.blank()}export var info={key:"fetch",title:"fetch",link:"https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch",description:"Perform asynchronous HTTP requests with the Fetch API"};export default handler;
|
|
2
2
|
//# sourceMappingURL=fetch.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign}from"tslib";import stringifyObject from"stringify-object";import{CodeBuilder}from"../../helpers/code-builder";import{addIndentation,getPreserveTransformer,buildUrlExpression,printUrlVariablesDeclarations}from"../../helpers/code-helpers";import{Lang}from"../../helpers/constants";import{normalizeMimeType}from"../../../../utils";import{HTTPSnippet}from"../..";import{MediaTypes}from"../../../../../types";var handler=function(e,t,a){var r,i,
|
|
1
|
+
import{__assign}from"tslib";import stringifyObject from"stringify-object";import{CodeBuilder}from"../../helpers/code-builder";import{addIndentation,getPreserveTransformer,buildUrlExpression,printUrlVariablesDeclarations}from"../../helpers/code-helpers";import{Lang}from"../../helpers/constants";import{normalizeMimeType}from"../../../../utils";import{HTTPSnippet}from"../..";import{MediaTypes}from"../../../../../types";var handler=function(e,t,a){var r,n,i,s,o,d,p=a.target,l=a.client,h=Object.assign({indent:" ",showBoilerplate:!0,level:1},t),m=h.level,c=!1,u=new CodeBuilder({indentation:h.indent,variablesPrefix:h.variablesPrefix,capitalize:!0,lang:Lang.NODEJS});h.withComments&&addComments(u),h.withImports&&(u.push("import fetch from 'node-fetch';"),u.blank()),h.showBoilerplate&&u.push("async function run() {");var f={method:e.method.toUpperCase()};Object.keys(e.headersObj).length&&(f.headers=e.headersObj);var v=!1;if(null===(r=e.securityOAuth2ExtraCalls)||void 0===r?void 0:r.length){var b=new HTTPSnippet(null===(n=e.securityOAuth2ExtraCalls)||void 0===n?void 0:n[0]).convert(p,l,__assign(__assign({},h),{withImports:!1,withComments:!1,variablesPrefix:"oAuth2",showBoilerplate:!1,level:1}));u.push(b),u.blank(),f.headers=f.headers||{},f.headers.Authorization="'Bearer ' + oAuth2Data.access_token",v=!0}var y=Object.getOwnPropertyNames(e.queryObj).length;if(y&&u.push(m,"const "+u.var("query")+" = new URLSearchParams("+addIndentation(stringifyObject(e.queryObj,{indent:h.indent,inlineCharacterLimit:25}),{level:m,indent:h.indent,firstLine:!1})+").toString();").blank(),e.postData)switch(normalizeMimeType(e.postData.mimeType)){case MediaTypes.URL_ENCODED:f.body=e.postData.paramsObj?"new URLSearchParams("+u.var("formData")+").toString()":e.postData.text,e.postData.paramsObj&&u.push(m,"const "+u.var("formData")+" = "+addIndentation(stringifyObject(e.postData.paramsObj,{indent:h.indent,inlineCharacterLimit:25}),{level:m,firstLine:!1})+";").blank();break;case MediaTypes.JSON:e.postData.jsonObj&&(f.body="JSON.stringify("+addIndentation(stringifyObject(e.postData.jsonObj,{indent:h.indent,inlineCharacterLimit:25}),{level:m,firstLine:!1})+")");break;case MediaTypes.MULTIPART:(null===(i=null==f?void 0:f.headers)||void 0===i?void 0:i["Content-Type"])&&(null===(s=f.headers)||void 0===s||delete s["Content-Type"]),h.withImports&&u.unshift("import FormData from 'form-data';"),u.push(m,"const "+u.var("form")+" = new FormData();"),e.postData.params.forEach((function(e){e.fileName||e.fileName||e.contentType?e.fileName&&(c=!0,u.blank(),u.push(m,u.var("form")+".append('\" + param.name + \"', fs.createReadStream('\" + param.fileName + \"'));")):u.push(m,"form.append('"+e.name+"','"+e.value+"');")})),f.body=u.var("form"),u.blank();break;default:e.postData.text&&(f.body="`"+addIndentation(e.postData.text,{level:m+1,indent:h.indent,firstLine:!1}).trim()+"`")}if(e.cookies.length){var g="";e.cookies.forEach((function(e){g=g+encodeURIComponent(e.name)+"="+encodeURIComponent(e.value)+"; "})),g=g.trim(),f.headers||(f.headers={}),f.headers.cookie=g}if(e.basicAuth){var O=e.basicAuth,j=O.username,T=O.password;f.headers=f.headers||{},f.headers.Authorization="'Basic ' + Buffer.from('"+j+":"+T+"').toString('base64')",v=!0}c&&h.withImports&&u.unshift("import fs from 'fs';");var w=f.headers&&f.headers.Accept&&normalizeMimeType(f.headers.Accept)===MediaTypes.JSON||normalizeMimeType(null===(o=e.postData)||void 0===o?void 0:o.mimeType)===MediaTypes.JSON;printUrlVariablesDeclarations(e,u,m);var D=buildUrlExpression(e,u);return u.push(m,"const "+u.var("resp")+" = await fetch(").push(m+1,"`"+D+(y?"?${"+u.var("query")+"}":"")+"`,").push(m+1,addIndentation(stringifyObject(f,{indent:h.indent,inlineCharacterLimit:25,transform:getPreserveTransformer({body:!0,authorizationHeader:v})}),{level:m+1,indent:h.indent,firstLine:!1})).push(m,");").blank(),(null===(d=e.allResponseCodes)||void 0===d?void 0:d.includes("204"))?(u.push(m,"if (resp.status === 204) {").push(m+1,"console.log('success');").push(m,"} else {"),u.push(m+1,"const "+u.var("data")+" = await "+u.var("resp")+"."+(w?"json()":"text()")+";").push(m+1,"console.log("+u.var("data")+");").push(m,"}")):u.push(m,"const "+u.var("data")+" = await "+u.var("resp")+"."+(w?"json()":"text()")+";").push(m,"console.log("+u.var("data")+");"),h.showBoilerplate&&u.push("}").blank().push("run();"),u.join().replace(/"fs\.createReadStream\(\\"(.+)\\"\)"/,'fs.createReadStream("$1")')};function addComments(e){e.push("/**"),e.push(" * Requires Node.js >= 14"),e.push(" *"),e.push(' * Requires module "node-fetch" >= 2.6.1'),e.push(" * See here for installation details:"),e.push(" * https://www.npmjs.com/package/node-fetch"),e.push(" */"),e.blank()}export var info={key:"fetch",title:"Fetch",link:"https://github.com/bitinn/node-fetch",description:"Simplified HTTP node-fetch client"};export default handler;
|
|
2
2
|
//# sourceMappingURL=fetch.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign}from"tslib";import{format}from"util";import{CodeBuilder}from"../../helpers/code-builder";import{normalizeMimeType}from"../../../../utils";import{addIndentation,buildUrlExpression,printUrlVariablesDeclarations}from"../../helpers/code-helpers";import{HTTPSnippet}from"../..";import{Lang}from"../../helpers/constants";import{MediaTypes}from"../../../../../types";var handler=function(e,t,a){var r,
|
|
1
|
+
import{__assign}from"tslib";import{format}from"util";import{CodeBuilder}from"../../helpers/code-builder";import{normalizeMimeType}from"../../../../utils";import{addIndentation,buildUrlExpression,printUrlVariablesDeclarations}from"../../helpers/code-helpers";import{HTTPSnippet}from"../..";import{Lang}from"../../helpers/constants";import{MediaTypes}from"../../../../../types";var handler=function(e,t,a){var s,r,o,n,i=a.target,p=a.client,l=Object.assign({indent:" "},t),u=l.level,d=void 0===u?0:u,h=new CodeBuilder({indentation:l.indent,variablesPrefix:l.variablesPrefix,lang:Lang.PYTHON});l.withComments&&addComments(h),l.withImports&&h.push("import requests").blank();var m,v,b=!1,c=e.allHeaders;if(null===(s=e.securityOAuth2ExtraCalls)||void 0===s?void 0:s.length){var f=new HTTPSnippet(null===(r=e.securityOAuth2ExtraCalls)||void 0===r?void 0:r[0]).convert(i,p,__assign(__assign({},l),{withImports:!1,withComments:!1,variablesPrefix:"oauth2_"}));h.push(f),h.blank(),(c=c||{}).Authorization='"Bearer " + oauth2_data["access_token"]',b=!0}(printUrlVariablesDeclarations(e,h),h.push(h.var("url").toLowerCase()+" = %s",buildUrlExpression(e,h)).blank(),Object.keys(e.queryObj||{}).length)&&(m="query = "+jsObjectToPythonDict(e.queryObj,l.indent),h.push(m).blank());var C,_=normalizeMimeType(null===(o=e.postData)||void 0===o?void 0:o.mimeType);if(e.postData)switch(_){case MediaTypes.URL_ENCODED:v=e.postData.paramsObj?""+addIndentation(jsObjectToPythonDict(e.postData.paramsObj,l.indent),{level:0,firstLine:!1}):e.postData.text;break;case MediaTypes.JSON:e.postData.jsonObj&&(v=addIndentation(jsObjectToPythonDict(e.postData.jsonObj,l.indent),{level:0,firstLine:!1}));break;case MediaTypes.MULTIPART:h.unshift("# multipart/form-data is not supported yet\n");break;default:e.postData.text&&(v="'''\n"+addIndentation(e.postData.text.trim(),{level:1,indent:l.indent,firstLine:!0})+"\n'''")}v&&h.push(h.var("payload").toLowerCase()+" = %s",v).blank();var y=Object.keys(c).length,L=function(e,t){return"Authorization"===e&&b?t:'"'+t+'"'};if(1===y)for(C in c)h.push(h.var("headers").toLowerCase()+' = {"'+C+'": '+L(C,c[C])+"}").blank();else if(y>1){var w=1;for(C in h.push(h.var("headers").toLowerCase()+" = {"),c)w++!==y?h.push(1,'"'+C+'": '+L(C,c[C])+","):h.push(1,'"'+C+'": '+L(C,c[C]));h.push(0,"}").blank()}var O=e.method.toLowerCase(),j=format(h.var("response").toLowerCase()+" = requests."+O+"("+h.var("url").toLowerCase());v&&(j+=", "+(_===MediaTypes.JSON?"json":"data")+"="+h.var("payload").toLowerCase());return y>0&&(j+=", headers="+h.var("headers").toLowerCase()),m&&(j+=", params="+h.var("query").toLowerCase()),e.basicAuth&&(j+=", auth=('"+e.basicAuth.username+"','"+e.basicAuth.password+"')"),j+=")",h.push(j).blank(),(null===(n=e.allResponseCodes)||void 0===n?void 0:n.includes("204"))?h.push("if (response.status == 204) {").push(d+1,'print("success")').push("} else {").push(d+1,h.var("data").toLowerCase()+" = "+h.var("response").toLowerCase()+".json()").push(d+1,"print("+h.var("data").toLowerCase()+")").push("}"):h.push(h.var("data").toLowerCase()+" = "+h.var("response").toLowerCase()+".json()").push("print("+h.var("data").toLowerCase()+")"),h.join()};export default handler;function addComments(e){e.push('"""'),e.push("Requires python >= 3"),e.blank(),e.push('Requires module "requests" >= 2.25.1'),e.push("See here for installation details:"),e.push(" https://requests.readthedocs.io/"),e.push('"""'),e.blank()}function jsObjectToPythonDict(e,t){return JSON.stringify(e,(function(e,t){return e&&"boolean"==typeof t?t?"__REDOCLY_<True>__":"__REDOCLY_<False>__":null===t?"__REDOCLY_<None>__":t}),t).replace(/"__REDOCLY_<(\w+)>__"/g,"$1")}
|
|
2
2
|
//# sourceMappingURL=requests.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ResolvedThemeInterface, MediaValue } from '../redoc-lib';
|
|
2
2
|
import type { RedocProRawOptions } from './ProStore';
|
|
3
3
|
export declare function extendTheme(options: RedocProRawOptions): RedocProRawOptions;
|
|
4
|
-
interface Typography {
|
|
4
|
+
export interface Typography {
|
|
5
5
|
fontSize?: MediaValue;
|
|
6
6
|
fontWeight?: string | number;
|
|
7
7
|
fontFamily?: MediaValue | ((theme: ProTheme) => string);
|
package/lib-esm/standalone.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign}from"tslib";import"core-js/es/array/find-index";import"core-js/es/array/find";import"core-js/es/array/includes";import"core-js/es/map";import"core-js/es/number/is-integer";import"core-js/es/object/assign";import"core-js/es/object/entries";import"core-js/es/object/is";import"core-js/es/object/values";import"core-js/es/promise";import"core-js/es/string/ends-with";import"core-js/es/string/starts-with";import"core-js/es/symbol";import"unfetch/polyfill/index";import"url-polyfill";import{dirname}from"path";import*as React from"react";import{hydrate as hydrateComponent,render}from"react-dom";import{querySelector,IS_BROWSER}from"./redoc-lib";import{ProStore}from"./services/ProStore";import{LayoutVariant}from"./services/store-types";import{RedoclyReferenceDocs,RedoclyReferenceDocsStandalone,RedoclyReferenceDocsMultiStandalone}from"./components/RedoclyReferenceDocs";import{getGlobalStore}from"./utils";export{setSecurityDetails,setParameterValue,setSecurityDetailsVariants}from"./utils";export function toggleLayout(e){var r=getGlobalStore();r&&r.toggleLayout((null!=e?e:r.layout===LayoutVariant.STACKED)?LayoutVariant.THREE_PANEL:LayoutVariant.STACKED)}export function toggleRightPanel(e){var r=getGlobalStore();r&&r.toggleRightPanel(e)}var url=getJsUrl(),__dirname=url?dirname(url)+"/":"";function attributesMap(e){for(var r={},t=e.attributes,o=0;o<t.length;o++){var i=t[o];r[i.name]=i.value}return r}function parseOptionsFromElement(e){var r=attributesMap(e),t={};for(var o in r){t[o.replace(/-(.)/g,(function(e,r){return r.toUpperCase()}))]=r[o]}return t}export function hydrate(e,r){void 0===r&&(r=document.querySelector("redoc"));var t=ProStore.fromJS(e);hydrateComponent(React.createElement(RedoclyReferenceDocs,{store:t}),r)}export function init(e,r,t,o){if(void 0===r&&(r={}),void 0===t&&(t=querySelector("redoc")),null===t)throw new Error('"element" argument is not provided and <redoc> tag is not found on the page');var i,n;"object"==typeof e&&"versions"in e?render(React.createElement(RedoclyReferenceDocsMultiStandalone,{definitions:e,options:__assign(__assign({},r),parseOptionsFromElement(t))},["Loading..."]),t,o):("string"==typeof e?i=e:"object"==typeof e&&(n=e),render(React.createElement(RedoclyReferenceDocsStandalone,{definition:n,definitionUrl:i,options:__assign(__assign({},r),parseOptionsFromElement(t))},["Loading..."]),t,o))}export function setPublicPath(e){__webpack_public_path__=e}export var version=__REDOCLY_API_REFERENCE_VERSION__;export var revision=__REDOCLY_API_REFERENCE_REVISION__;function autoInit(){var e=querySelector("redoc");if(e){var r=e.getAttribute("spec-url");r&&init(r,{},e)}}
|
|
1
|
+
import{__assign}from"tslib";import"core-js/es/array/find-index";import"core-js/es/array/find";import"core-js/es/array/includes";import"core-js/es/map";import"core-js/es/number/is-integer";import"core-js/es/object/assign";import"core-js/es/object/entries";import"core-js/es/object/is";import"core-js/es/object/values";import"core-js/es/promise";import"core-js/es/string/ends-with";import"core-js/es/string/starts-with";import"core-js/es/symbol";import"unfetch/polyfill/index";import"url-polyfill";import{dirname}from"path";import*as React from"react";import{hydrate as hydrateComponent,render}from"react-dom";import{querySelector,IS_BROWSER}from"./redoc-lib";import{ProStore}from"./services/ProStore";import{LayoutVariant}from"./services/store-types";import{RedoclyReferenceDocs,RedoclyReferenceDocsStandalone,RedoclyReferenceDocsMultiStandalone}from"./components/RedoclyReferenceDocs";import{getGlobalStore,getJsUrl}from"./utils";export{setSecurityDetails,setParameterValue,setSecurityDetailsVariants}from"./utils";export function toggleLayout(e){var r=getGlobalStore();r&&r.toggleLayout((null!=e?e:r.layout===LayoutVariant.STACKED)?LayoutVariant.THREE_PANEL:LayoutVariant.STACKED)}export function toggleRightPanel(e){var r=getGlobalStore();r&&r.toggleRightPanel(e)}var url=getJsUrl(),__dirname=url?dirname(url)+"/":"";function attributesMap(e){for(var r={},t=e.attributes,o=0;o<t.length;o++){var i=t[o];r[i.name]=i.value}return r}function parseOptionsFromElement(e){var r=attributesMap(e),t={};for(var o in r){t[o.replace(/-(.)/g,(function(e,r){return r.toUpperCase()}))]=r[o]}return t}export function hydrate(e,r){void 0===r&&(r=document.querySelector("redoc"));var t=ProStore.fromJS(e);hydrateComponent(React.createElement(RedoclyReferenceDocs,{store:t}),r)}export function init(e,r,t,o){if(void 0===r&&(r={}),void 0===t&&(t=querySelector("redoc")),null===t)throw new Error('"element" argument is not provided and <redoc> tag is not found on the page');var i,n;"object"==typeof e&&"versions"in e?render(React.createElement(RedoclyReferenceDocsMultiStandalone,{definitions:e,options:__assign(__assign({},r),parseOptionsFromElement(t))},["Loading..."]),t,o):("string"==typeof e?i=e:"object"==typeof e&&(n=e),render(React.createElement(RedoclyReferenceDocsStandalone,{definition:n,definitionUrl:i,options:__assign(__assign({},r),parseOptionsFromElement(t))},["Loading..."]),t,o))}export function setPublicPath(e){__webpack_public_path__=e}export var version=__REDOCLY_API_REFERENCE_VERSION__;export var revision=__REDOCLY_API_REFERENCE_REVISION__;function autoInit(){var e=querySelector("redoc");if(e){var r=e.getAttribute("spec-url");r&&init(r,{},e)}}IS_BROWSER&&setPublicPath(__dirname),autoInit();
|
|
2
2
|
//# sourceMappingURL=standalone.js.map
|
package/lib-esm/types.d.ts
CHANGED
|
@@ -12,3 +12,14 @@ export declare enum MediaTypes {
|
|
|
12
12
|
JSON = "application/json",
|
|
13
13
|
XML = "application/xml"
|
|
14
14
|
}
|
|
15
|
+
export declare type SecurityDetails = {
|
|
16
|
+
password?: string;
|
|
17
|
+
username?: string;
|
|
18
|
+
token?: {
|
|
19
|
+
token_type?: string;
|
|
20
|
+
access_token: string;
|
|
21
|
+
};
|
|
22
|
+
client_id?: string;
|
|
23
|
+
client_secret?: string;
|
|
24
|
+
scopes?: string;
|
|
25
|
+
};
|
package/lib-esm/utils.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ProStore } from './services/ProStore';
|
|
2
|
+
import type { SecurityDetails } from './types';
|
|
2
3
|
export declare const getGlobalStore: () => ProStore;
|
|
3
4
|
export declare const setGlobalStore: (store: ProStore) => ProStore;
|
|
4
5
|
export declare function debounce<T extends unknown>(fn: (...args: T[]) => void, threshold: number, leading?: boolean): (...args: T[]) => void;
|
|
@@ -8,18 +9,6 @@ export declare function setParameterValue(_in: string, name: string, value: Gene
|
|
|
8
9
|
export declare function getParameterValue(_in: string, name: string): string | null;
|
|
9
10
|
export declare function toLocalStorage(key: string, value: string): void;
|
|
10
11
|
export declare function fromLocalStorage<T extends string>(key: string): T;
|
|
11
|
-
export declare function useDimensions(node?: HTMLElement | null): [DOMRect | null];
|
|
12
|
-
export declare type SecurityDetails = {
|
|
13
|
-
password?: string;
|
|
14
|
-
username?: string;
|
|
15
|
-
token?: {
|
|
16
|
-
token_type?: string;
|
|
17
|
-
access_token: string;
|
|
18
|
-
};
|
|
19
|
-
client_id?: string;
|
|
20
|
-
client_secret?: string;
|
|
21
|
-
scopes?: string;
|
|
22
|
-
};
|
|
23
12
|
export declare function escapeFormId(id: string): string;
|
|
24
13
|
export declare function unescapeFormId(id: string): string;
|
|
25
14
|
export declare function setSecurityDetails(name: string, details: SecurityDetails | string): void;
|
|
@@ -34,7 +23,8 @@ export declare function getSecurityDetailsOptions(name: string, fieldName: strin
|
|
|
34
23
|
label: string;
|
|
35
24
|
value: string;
|
|
36
25
|
}> | null;
|
|
37
|
-
export declare function get<T>(object: GenericObject, path: string | Array<string>, defval?: T): GenericObject;
|
|
26
|
+
export declare function get<T>(object: GenericObject | undefined, path: string | Array<string>, defval?: T): GenericObject;
|
|
38
27
|
export declare function joinStringFactory(separator: string): (...args: (string | undefined)[]) => string;
|
|
39
28
|
export declare const dottedString: (...args: (string | undefined)[]) => string;
|
|
40
29
|
export declare function getWindowReferenceOptions<T>(option: string): T | null;
|
|
30
|
+
export declare function getJsUrl(): string;
|
package/lib-esm/utils.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{IS_BROWSER}from"./redoc-lib/src/utils/";var _store;export var getGlobalStore=function(){return _store};export var setGlobalStore=function(e){return _store=e};export function debounce(e,t,r){var o,n=0;return function(){for(var i=[],a=0;a<arguments.length;a++)i[a]=arguments[a];function s(){n>1&&e.apply(void 0,i),n=0,o=null}n++,o?clearTimeout(o):r&&e.apply(void 0,i),o=setTimeout(s,t)}}export function toSessionStorage(e,t){IS_BROWSER&&window.sessionStorage.setItem("redoc."+e,t)}export function fromSessionStorage(e){return IS_BROWSER&&window.sessionStorage.getItem("redoc."+e)||""}export function setParameterValue(e,t,r){toSessionStorage(e+"."+t,JSON.stringify(r))}export function getParameterValue(e,t){try{return JSON.parse(fromSessionStorage(e+"."+t))}catch(e){return null}}export function toLocalStorage(e,t){window.localStorage.setItem("redoc."+e,t)}export function fromLocalStorage(e){return IS_BROWSER&&window.localStorage.getItem("redoc."+e)||""}export function escapeFormId(e){return e.replace(/[.[\]]/g,(function(e){return{".":"%2e","[":"%5b","]":"%5d"}[e]||""}))}export function unescapeFormId(e){return e.replace(/%2e|%5b|%5d/g,(function(e){return{"%2e":".","%5b":"[","%5d":"]"}[e]||""}))}export function setSecurityDetails(e,t){e=escapeFormId(e),"string"==typeof t?toSessionStorage("auth."+e,t):t&&(toSessionStorage("auth."+e+".password",t.password||""),toSessionStorage("auth."+e+".username",t.username||""),toSessionStorage("auth."+e+".token",t.token&&JSON.stringify(t.token)||""),toSessionStorage("auth."+e+".client_id",t.client_id||""),toSessionStorage("auth."+e+".client_secret",t.client_secret||""),toSessionStorage("auth."+e+".scopes",t.scopes&&JSON.stringify(t.scopes)||""))}export function setSecurityDetailsVariants(e,t){toSessionStorage("auth."+(e=escapeFormId(e))+".variants",JSON.stringify(t))}export function getSecurityDetails(e){var t=fromSessionStorage("auth."+(e=escapeFormId(e))),r=fromSessionStorage("auth."+e+".token");return{raw:t,password:fromSessionStorage("auth."+e+".password"),username:fromSessionStorage("auth."+e+".username"),token:r&&JSON.parse(r)||null,client_id:fromSessionStorage("auth."+e+".client_id"),client_secret:fromSessionStorage("auth."+e+".client_secret"),scopes:fromSessionStorage("auth."+e+".scopes")}}export function getSecurityDetailsOptions(e,t){var r=fromSessionStorage("auth."+(e=escapeFormId(e))+".variants");if(!r)return null;var o=JSON.parse(r);return o&&Array.isArray(o)?o.map((function(e){return e.details?""===t&&e.details&&"string"==typeof e.details?{label:e.label,value:e.details}:"object"==typeof e.details?{label:e.label,value:e.details[t]}:null:null})).filter(notNull):null}function notNull(e){return null!==e}export function get(e,t,r){return void 0===e&&(e={}),"string"==typeof t&&(t=t.split(".")),t.reduce((function(e,t){return e&&e[t]?e[t]:r}),e)}export function joinStringFactory(e){return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return t.filter(Boolean).join(e)}}export var dottedString=joinStringFactory(".");export function getWindowReferenceOptions(e){var t;return IS_BROWSER?null===(t=null===window||void 0===window?void 0:window.REFERENCE_DOCS_OPTIONS)||void 0===t?void 0:t[e]:null}export function getJsUrl(){var e;if(!IS_BROWSER)return"";var t=+new Date+Math.random();try{return document.currentScript&&(document.currentScript.async||document.currentScript.defer)||document.write('<script id="dummy'+t+'"><\/script>'),(null===(e=document.getElementById("dummy"+t))||void 0===e?void 0:e.previousSibling).src}catch(e){return""}}
|
|
2
2
|
//# sourceMappingURL=utils.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/reference-docs",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.33.0",
|
|
4
4
|
"description": "Redocly Reference Docs",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib-esm/index.js",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"test:unit": "jest",
|
|
79
79
|
"test:unit:watch": "jest --watch",
|
|
80
80
|
"test:update-snapshot": "jest --updateSnapshot",
|
|
81
|
-
"test:e2e": "npm run bundle && percy exec -- cypress run",
|
|
81
|
+
"test:e2e": "npm run bundle && npm run bundle-cli && scripts/build-cli.sh && percy exec -- cypress run",
|
|
82
82
|
"cypress": "cypress open",
|
|
83
83
|
"list-licenses": "node ./scripts/list-licenses.js",
|
|
84
84
|
"license-check": "license-checker --production --onlyAllow 'MIT;ISC;Apache-2.0;Apache;CC0-1.0;BSD;BSD-2-Clause;BSD-3-Clause;UNKNOWN' --summary",
|
|
@@ -105,6 +105,7 @@
|
|
|
105
105
|
"@types/dompurify": "^2.0.2",
|
|
106
106
|
"@types/enzyme-to-json": "^1.5.3",
|
|
107
107
|
"@types/jest": "^25.1.4",
|
|
108
|
+
"@types/jest-when": "^3.5.2",
|
|
108
109
|
"@types/json-pointer": "^1.0.30",
|
|
109
110
|
"@types/mark.js": "^8.11.5",
|
|
110
111
|
"@types/marked": "^4.0.1",
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import type { RequestBodyModel } from '../../redoc-lib';
|
|
3
|
-
import type { Console } from './Console';
|
|
4
|
-
export interface RequestBodyProps {
|
|
5
|
-
body: RequestBodyModel;
|
|
6
|
-
resolvedBody: any;
|
|
7
|
-
validate: () => string | undefined;
|
|
8
|
-
console: Console;
|
|
9
|
-
id: string;
|
|
10
|
-
properties: any;
|
|
11
|
-
}
|
|
12
|
-
export declare const RequestBody: React.MemoExoticComponent<(props: RequestBodyProps) => JSX.Element>;
|
|
@@ -1,2 +0,0 @@
|
|
|
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
|
-
//# sourceMappingURL=RequestBody.js.map
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import type { OperationModel, Server } from '../../redoc-lib';
|
|
3
|
-
import type { DropdownOption } from '../common/Dropdown';
|
|
4
|
-
export interface ServerDropdownProps {
|
|
5
|
-
operation: OperationModel;
|
|
6
|
-
onChange: (server: Server) => void;
|
|
7
|
-
}
|
|
8
|
-
export interface ServerDropdownState {
|
|
9
|
-
activeIdx: number;
|
|
10
|
-
variables?: {
|
|
11
|
-
[name: string]: string;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
export declare class ServerChooser extends React.Component<ServerDropdownProps, ServerDropdownState> {
|
|
15
|
-
state: {
|
|
16
|
-
activeIdx: number;
|
|
17
|
-
variables: {};
|
|
18
|
-
};
|
|
19
|
-
static getDerivedStateFromProps(props: ServerDropdownProps): ServerDropdownState;
|
|
20
|
-
handleServerChange: (option: DropdownOption) => void;
|
|
21
|
-
handleVariableChange: (name: string, rawValue: string) => void;
|
|
22
|
-
componentDidMount(): void;
|
|
23
|
-
render(): JSX.Element;
|
|
24
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ServerChooser=void 0;var tslib_1=require("tslib"),React=(0,tslib_1.__importStar)(require("react")),mobx_react_1=require("mobx-react"),redoc_lib_1=require("../../redoc-lib"),utils_1=require("../../utils"),form_1=require("../common/form"),Dropdown_1=require("../common/Dropdown"),utils_2=require("./utils"),ServerVariable_1=(0,tslib_1.__importDefault)(require("./ServerVariable")),ServerChooser=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return Object.defineProperty(r,"state",{enumerable:!0,configurable:!0,writable:!0,value:{activeIdx:0,variables:{}}}),Object.defineProperty(r,"handleServerChange",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var t=r.props.operation.servers.find((function(r){return r.url===e.serverUrl})),a=(0,utils_2.getDefaultOrStoredVariables)(t);r.props.onChange({url:e.serverUrl||"",variables:a}),(0,utils_1.toSessionStorage)("serverUrl",e.serverUrl||""),r.setState({variables:a})}}),Object.defineProperty(r,"handleVariableChange",{enumerable:!0,configurable:!0,writable:!0,value:function(e,t){var a,i=r.props.operation.servers[r.state.activeIdx],l=t||""===t?t:(0,utils_2.getDefaultOrStoredVariables)(i)[e],n=(0,tslib_1.__assign)((0,tslib_1.__assign)({},r.state.variables),((a={})[e]=l,a));r.setState({variables:n}),(0,utils_2.updateVariablesStorage)(e,l),r.props.onChange((0,tslib_1.__assign)((0,tslib_1.__assign)({},i),{variables:n}))}}),r}return(0,tslib_1.__extends)(r,e),Object.defineProperty(r,"getDerivedStateFromProps",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var r=e.operation,t=(0,utils_1.fromSessionStorage)("serverUrl"),a=r.servers.findIndex((function(e){return e.url===t}));return{activeIdx:a<0?0:a}}}),Object.defineProperty(r.prototype,"componentDidMount",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=(0,utils_2.getServerWithVariables)(this.props.operation.servers,this.state.activeIdx);this.props.onChange(e),this.setState({variables:e.variables})}}),Object.defineProperty(r.prototype,"render",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this,r=this.state.activeIdx,t=this.props.operation.servers.map((function(r,t){return{idx:t,serverUrl:r.url,value:"\n "+(0,utils_2.expandDefaultServerVariables)((0,utils_2.expandVariables)(r.url,e.state.variables),r.variables)+"\n - "+(r.description||"Default")+"\n "}})),a=Object.keys(this.state.variables);return React.createElement(ServerDropdownWrap,null,React.createElement(form_1.FormLabel,{htmlFor:"server"},"Target server: "),React.createElement(form_1.FormControl,null,React.createElement(Dropdown_1.Dropdown,{variant:"dark",value:t[r].value,options:t,fullWidth:!0,onChange:this.handleServerChange})),a.length?a.map((function(r){var t,a=null===(t=e.props.operation.servers[e.state.activeIdx].variables)||void 0===t?void 0:t[r];if(a)return React.createElement(ServerVariable_1.default,{key:r,name:r,value:e.state.variables[r],defaultValue:a.default,onChange:function(t){return e.handleVariableChange(r,t)},variableEnum:a.enum,description:a.description})})):null)}}),r=(0,tslib_1.__decorate)([mobx_react_1.observer],r)}(React.Component);exports.ServerChooser=ServerChooser;var templateObject_1,ServerDropdownWrap=redoc_lib_1.styled.div(templateObject_1||(templateObject_1=(0,tslib_1.__makeTemplateObject)(["\n margin-top: 20px;\n"],["\n margin-top: 20px;\n"])));
|
|
2
|
-
//# sourceMappingURL=ServerDropdown.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Wrapper=exports.HeadersCaption=void 0;var templateObject_1,templateObject_2,tslib_1=require("tslib"),common_elements_1=require("../../common-elements"),styled_components_1=(0,tslib_1.__importDefault)(require("../../styled-components"));exports.HeadersCaption=(0,styled_components_1.default)(common_elements_1.FieldsGroupHeader.withComponent("caption"))(templateObject_1||(templateObject_1=(0,tslib_1.__makeTemplateObject)(["\n text-align: left;\n margin-top: 1em;\n caption-side: top;\n"],["\n text-align: left;\n margin-top: 1em;\n caption-side: top;\n"]))),exports.Wrapper=styled_components_1.default.div(templateObject_2||(templateObject_2=(0,tslib_1.__makeTemplateObject)(["\n margin-bottom: 1em;\n"],["\n margin-bottom: 1em;\n"])));
|
|
2
|
-
//# sourceMappingURL=styled.elements.js.map
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import type { RequestBodyModel } from '../../redoc-lib';
|
|
3
|
-
import type { Console } from './Console';
|
|
4
|
-
export interface RequestBodyProps {
|
|
5
|
-
body: RequestBodyModel;
|
|
6
|
-
resolvedBody: any;
|
|
7
|
-
validate: () => string | undefined;
|
|
8
|
-
console: Console;
|
|
9
|
-
id: string;
|
|
10
|
-
properties: any;
|
|
11
|
-
}
|
|
12
|
-
export declare const RequestBody: React.MemoExoticComponent<(props: RequestBodyProps) => JSX.Element>;
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var _this=this;import{__assign,__awaiter,__generator}from"tslib";import*as React from"react";import{useEffect}from"react";import{observer}from"mobx-react";import merge from"deepmerge";import{DropdownOrLabel,MediaTypesSwitch}from"../../redoc-lib";import{ExampleSwitch,useExampleKey}from"../Samples";import{arrayMergeStrategy}from"../../services/utils";import{isRootFileUpload}from"../common/FileUpload/helper";import{MediaTypes}from"../../types";import{Dropdown}from"../common/Dropdown";import{RequestBodyForm}from"./RequestBodyForm";import{RequestMimeLabel}from"./RequestMimeLabel";import CodemirrorInput from"./CodemirrorInput";var RequestBodyComponent=observer((function(e){var r,t=e.body.content,o=e.console.formApi,a=function(r){var o;if(!t||!t.hasSample)return"";var a=null===(o=t.active)||void 0===o?void 0:o.examples;if(!(null==a?void 0:a[r]))return"";var i=null==a?void 0:a[r].value,n=e.properties?merge(i,e.properties,{arrayMerge:arrayMergeStrategy}):i;return JSON.stringify(n,null,2)},i=null===(r=null==t?void 0:t.operation)||void 0===r?void 0:r.activeExampleName,n=function(e){var r;null===(r=null==t?void 0:t.operation)||void 0===r||r.activateExampleName(e),o.setValue("body",a(e))},m=function(r){if(!r)return"";if(r.mime===MediaTypes.URL_ENCODED)return r.value;var t=r.value,o=e.properties?merge(t,e.properties,{arrayMerge:arrayMergeStrategy}):t;return JSON.stringify(o,null,2)},l=function(e,r){return __awaiter(void 0,void 0,void 0,(function(){return __generator(this,(function(t){return(0,o.setValue)("body."+e,r),[2]}))}))};useEffect((function(){!1!==i?i&&o.setValue("body",a(i)):o.setValue("body",JSON.stringify(e.properties||{},null,2))}),[i]);var p=e.validate,d=e.body;return React.createElement(React.Fragment,null,React.createElement(MediaTypesSwitch,{content:d.content,renderDropdown:function(e){return React.createElement(DropdownOrLabel,__assign({},e,{variant:"dark",fullWidth:!0,Label:RequestMimeLabel,Dropdown:Dropdown}))}},(function(r){var t,a=r.examples||{},i=Object.keys(a),d=r.schema,u=isRootFileUpload(d||{},r.name)||r.name===MediaTypes.MULTIPART||r.name===MediaTypes.URL_ENCODED,s=useExampleKey(r.operation,a).exampleKey,c=a[s];return React.createElement(React.Fragment,null,i.length&&1!==i.length&&React.createElement(ExampleSwitch,{examples:a,onChange:n,exampleKey:s})||null,u?React.createElement(RequestBodyForm,{mediaType:r,formApi:o,onChange:l.bind(_this)}):React.createElement(CodemirrorInput,{id:"body"+e.id,field:"body",initialValue:m(c),schema:((null===(t=null==e?void 0:e.resolvedBody)||void 0===t?void 0:t.content[r.name])||{}).schema,mode:r.name,validate:p}))})))}));export var RequestBody=React.memo(RequestBodyComponent);
|
|
2
|
-
//# sourceMappingURL=RequestBody.js.map
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import type { OperationModel, Server } from '../../redoc-lib';
|
|
3
|
-
import type { DropdownOption } from '../common/Dropdown';
|
|
4
|
-
export interface ServerDropdownProps {
|
|
5
|
-
operation: OperationModel;
|
|
6
|
-
onChange: (server: Server) => void;
|
|
7
|
-
}
|
|
8
|
-
export interface ServerDropdownState {
|
|
9
|
-
activeIdx: number;
|
|
10
|
-
variables?: {
|
|
11
|
-
[name: string]: string;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
export declare class ServerChooser extends React.Component<ServerDropdownProps, ServerDropdownState> {
|
|
15
|
-
state: {
|
|
16
|
-
activeIdx: number;
|
|
17
|
-
variables: {};
|
|
18
|
-
};
|
|
19
|
-
static getDerivedStateFromProps(props: ServerDropdownProps): ServerDropdownState;
|
|
20
|
-
handleServerChange: (option: DropdownOption) => void;
|
|
21
|
-
handleVariableChange: (name: string, rawValue: string) => void;
|
|
22
|
-
componentDidMount(): void;
|
|
23
|
-
render(): JSX.Element;
|
|
24
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{__assign,__decorate,__extends,__makeTemplateObject}from"tslib";import*as React from"react";import{observer}from"mobx-react";import{styled}from"../../redoc-lib";import{fromSessionStorage,toSessionStorage}from"../../utils";import{FormControl,FormLabel}from"../common/form";import{Dropdown}from"../common/Dropdown";import{expandDefaultServerVariables,expandVariables,getServerWithVariables,getDefaultOrStoredVariables,updateVariablesStorage}from"./utils";import ServerVariable from"./ServerVariable";var ServerChooser=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return Object.defineProperty(r,"state",{enumerable:!0,configurable:!0,writable:!0,value:{activeIdx:0,variables:{}}}),Object.defineProperty(r,"handleServerChange",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var a=r.props.operation.servers.find((function(r){return r.url===e.serverUrl})),t=getDefaultOrStoredVariables(a);r.props.onChange({url:e.serverUrl||"",variables:t}),toSessionStorage("serverUrl",e.serverUrl||""),r.setState({variables:t})}}),Object.defineProperty(r,"handleVariableChange",{enumerable:!0,configurable:!0,writable:!0,value:function(e,a){var t,o=r.props.operation.servers[r.state.activeIdx],n=a||""===a?a:getDefaultOrStoredVariables(o)[e],i=__assign(__assign({},r.state.variables),((t={})[e]=n,t));r.setState({variables:i}),updateVariablesStorage(e,n),r.props.onChange(__assign(__assign({},o),{variables:i}))}}),r}return __extends(r,e),Object.defineProperty(r,"getDerivedStateFromProps",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var r=e.operation,a=fromSessionStorage("serverUrl"),t=r.servers.findIndex((function(e){return e.url===a}));return{activeIdx:t<0?0:t}}}),Object.defineProperty(r.prototype,"componentDidMount",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=getServerWithVariables(this.props.operation.servers,this.state.activeIdx);this.props.onChange(e),this.setState({variables:e.variables})}}),Object.defineProperty(r.prototype,"render",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this,r=this.state.activeIdx,a=this.props.operation.servers.map((function(r,a){return{idx:a,serverUrl:r.url,value:"\n "+expandDefaultServerVariables(expandVariables(r.url,e.state.variables),r.variables)+"\n - "+(r.description||"Default")+"\n "}})),t=Object.keys(this.state.variables);return React.createElement(ServerDropdownWrap,null,React.createElement(FormLabel,{htmlFor:"server"},"Target server: "),React.createElement(FormControl,null,React.createElement(Dropdown,{variant:"dark",value:a[r].value,options:a,fullWidth:!0,onChange:this.handleServerChange})),t.length?t.map((function(r){var a,t=null===(a=e.props.operation.servers[e.state.activeIdx].variables)||void 0===a?void 0:a[r];if(t)return React.createElement(ServerVariable,{key:r,name:r,value:e.state.variables[r],defaultValue:t.default,onChange:function(a){return e.handleVariableChange(r,a)},variableEnum:t.enum,description:t.description})})):null)}}),r=__decorate([observer],r)}(React.Component);export{ServerChooser};var templateObject_1,ServerDropdownWrap=styled.div(templateObject_1||(templateObject_1=__makeTemplateObject(["\n margin-top: 20px;\n"],["\n margin-top: 20px;\n"])));
|
|
2
|
-
//# sourceMappingURL=ServerDropdown.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{__makeTemplateObject}from"tslib";import{FieldsGroupHeader}from"../../common-elements";import styled from"../../styled-components";export var HeadersCaption=styled(FieldsGroupHeader.withComponent("caption"))(templateObject_1||(templateObject_1=__makeTemplateObject(["\n text-align: left;\n margin-top: 1em;\n caption-side: top;\n"],["\n text-align: left;\n margin-top: 1em;\n caption-side: top;\n"])));export var Wrapper=styled.div(templateObject_2||(templateObject_2=__makeTemplateObject(["\n margin-bottom: 1em;\n"],["\n margin-bottom: 1em;\n"])));var templateObject_1,templateObject_2;
|
|
2
|
-
//# sourceMappingURL=styled.elements.js.map
|