@redocly/openapi-docs 3.4.12-rc.1 → 3.4.13
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/dist/redocly-openapi-docs.min.js +979 -1238
- package/lib/components/RedoclyOpenAPIDocs/Providers.js +1 -1
- package/lib/components/common/linkify.d.ts +8 -0
- package/lib/components/common/linkify.js +2 -2
- package/lib/services/code-samples/generator.d.ts +1 -0
- package/lib/services/code-samples/generator.js +1 -1
- package/lib/services/config-options/normalizeOptions.js +1 -1
- package/lib-esm/components/RedoclyOpenAPIDocs/Providers.js +1 -1
- package/lib-esm/components/common/linkify.d.ts +8 -0
- package/lib-esm/components/common/linkify.js +2 -2
- 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/config-options/normalizeOptions.js +1 -1
- package/package.json +7 -8
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var __awaiter=this&&this.__awaiter||function(e,t,i,r){return new(i||(i=Promise))((function(o,n){function a(e){try{l(r.next(e))}catch(e){n(e)}}function s(e){try{l(r.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,s)}l((r=r.apply(e,t||[])).next())}))},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.StoreProvider=exports.AppProvider=void 0;const jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),markdoc_1=require("@markdoc/markdoc"),theme_1=require("@redocly/theme"),jotai_1=require("jotai"),services_1=require("../../services"),utils_1=require("./utils"),utils_2=require("../../utils"),SchemaDefinition_1=require("../SchemaDefinition"),app_1=require("../../jotai/app"),nexus_1=__importDefault(require("../../jotai/nexus")),object_1=require("../../utils/object"),operation_1=require("../../models/operation"),operation_2=require("../../jotai/operation"),environments_1=require("../../utils/environments"),store_1=require("../../jotai/store"),AppProvider=({options:e,definitionUrl:t,definition:i,activeSampleLanguage:r,children:o})=>{const[,n]=(0,react_1.useState)(),[a,s]=(0,react_1.useState)(!0),[l,u]=(0,react_1.useState)(null);(0,react_1.useEffect)((()=>{!function(){__awaiter(this,void 0,void 0,(function*(){s(!0);try{u(yield(0,utils_1.loadSingle)(i,t,e))}catch(e){n((()=>{throw e}))}}))}()}),[i,t,e]);const c=(0,react_1.useMemo)((()=>{var i,o,n;if(l)return(null===(i=null==e?void 0:e.unstable_hooks)||void 0===i?void 0:i.onInit)&&(null===(n=null===(o=e.unstable_hooks)||void 0===o?void 0:o.onInit)||void 0===n||n.call(o,{store:{definition:l,options:e,definitionUrl:t,activeSampleLanguage:r}})),{definition:l,options:e,definitionUrl:t,activeSampleLanguage:r}}),(0,utils_1.useDeepCompareMemoize)([l,e,t]));return(0,react_1.useEffect)((()=>{c&&s(!1)}),[c]),c?a?(0,utils_2.argValueToBoolean)(null==e?void 0:e.hideLoading,!1)?null:(0,jsx_runtime_1.jsx)(theme_1.Loading,{color:"--loading-spinner-color"}):(0,react_1.isValidElement)(o)?(0,react_1.cloneElement)(o,{store:c}):null:null};exports.AppProvider=AppProvider;const DEFAULT_OPTIONS={ignoreNamedSchemas:["java.io.ObjectStreamField"],maxDisplayedEnumValues:10,markdocOptions:{tags:{schemaDefinition:{render:"SchemaDefinition",attributes:{schemaRef:{type:String},exampleRef:{type:String},showReadOnly:{type:Boolean},showWriteOnly:{type:Boolean},htmlWrap:{type:String,default:!1}}}},nodes:{heading:{children:["inline"],attributes:{id:{type:String},level:{type:Number,required:!0,default:1}},transform(e,t){const i=e.transformAttributes(t),r=e.transformChildren(t),o="string"==typeof i.id?i.id:(0,utils_1.getMarkdownHeaderId)(r);return new markdoc_1.Tag("Heading",Object.assign(Object.assign({},i),{id:o,level:e.attributes.level}),r)}}},components:{SchemaDefinition:SchemaDefinition_1.SchemaDefinition,Heading:
|
|
1
|
+
"use strict";var __awaiter=this&&this.__awaiter||function(e,t,i,r){return new(i||(i=Promise))((function(o,n){function a(e){try{l(r.next(e))}catch(e){n(e)}}function s(e){try{l(r.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,s)}l((r=r.apply(e,t||[])).next())}))},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.StoreProvider=exports.AppProvider=void 0;const jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),markdoc_1=require("@markdoc/markdoc"),theme_1=require("@redocly/theme"),jotai_1=require("jotai"),services_1=require("../../services"),utils_1=require("./utils"),utils_2=require("../../utils"),SchemaDefinition_1=require("../SchemaDefinition"),app_1=require("../../jotai/app"),nexus_1=__importDefault(require("../../jotai/nexus")),object_1=require("../../utils/object"),operation_1=require("../../models/operation"),operation_2=require("../../jotai/operation"),environments_1=require("../../utils/environments"),store_1=require("../../jotai/store"),linkify_1=require("../common/linkify"),AppProvider=({options:e,definitionUrl:t,definition:i,activeSampleLanguage:r,children:o})=>{const[,n]=(0,react_1.useState)(),[a,s]=(0,react_1.useState)(!0),[l,u]=(0,react_1.useState)(null);(0,react_1.useEffect)((()=>{!function(){__awaiter(this,void 0,void 0,(function*(){s(!0);try{u(yield(0,utils_1.loadSingle)(i,t,e))}catch(e){n((()=>{throw e}))}}))}()}),[i,t,e]);const c=(0,react_1.useMemo)((()=>{var i,o,n;if(l)return(null===(i=null==e?void 0:e.unstable_hooks)||void 0===i?void 0:i.onInit)&&(null===(n=null===(o=e.unstable_hooks)||void 0===o?void 0:o.onInit)||void 0===n||n.call(o,{store:{definition:l,options:e,definitionUrl:t,activeSampleLanguage:r}})),{definition:l,options:e,definitionUrl:t,activeSampleLanguage:r}}),(0,utils_1.useDeepCompareMemoize)([l,e,t]));return(0,react_1.useEffect)((()=>{c&&s(!1)}),[c]),c?a?(0,utils_2.argValueToBoolean)(null==e?void 0:e.hideLoading,!1)?null:(0,jsx_runtime_1.jsx)(theme_1.Loading,{color:"--loading-spinner-color"}):(0,react_1.isValidElement)(o)?(0,react_1.cloneElement)(o,{store:c}):null:null};exports.AppProvider=AppProvider;const DEFAULT_OPTIONS={ignoreNamedSchemas:["java.io.ObjectStreamField"],maxDisplayedEnumValues:10,markdocOptions:{tags:{schemaDefinition:{render:"SchemaDefinition",attributes:{schemaRef:{type:String},exampleRef:{type:String},showReadOnly:{type:Boolean},showWriteOnly:{type:Boolean},htmlWrap:{type:String,default:!1}}}},nodes:{heading:{children:["inline"],attributes:{id:{type:String},level:{type:Number,required:!0,default:1}},transform(e,t){const i=e.transformAttributes(t),r=e.transformChildren(t),o="string"==typeof i.id?i.id:(0,utils_1.getMarkdownHeaderId)(r);return new markdoc_1.Tag("Heading",Object.assign(Object.assign({},i),{id:o,level:e.attributes.level}),r)}}},components:{SchemaDefinition:SchemaDefinition_1.SchemaDefinition,Heading:linkify_1.MarkdownHeading}}};exports.StoreProvider=(0,react_1.memo)((({children:e,options:t,definitionUrl:i,definition:r,withState:o})=>{const n=(0,react_1.useCallback)((()=>{const e=(0,services_1.normalizeOptions)(t,DEFAULT_OPTIONS);return{options:e,parser:new services_1.OpenAPIParser(r,i,e)}}),[r,i,t]),a=(0,react_1.useMemo)((()=>{var e,t;const i=(0,jotai_1.createStore)(),r=n();i.set(store_1.globalStoreAtom,r);const a=(0,utils_2.normalizeServers)(r.parser.definitionUrl,(0,operation_1.mergeInMockServer)((null===(e=r.parser.definition)||void 0===e?void 0:e.servers)||[],r.options.mockServer)),s=Object.fromEntries(a.map((e=>[(0,environments_1.getServerEnvName)(e),Object.assign({server:e.url},(0,object_1.mapObject)(e.variables||{},(e=>e.default||"")))])));return i.sub(app_1.appStore,(()=>{})),i.set(app_1.layoutAtom,(null===(t=r.options)||void 0===t?void 0:t.layout)||theme_1.LayoutVariant.THREE_PANEL),i.set(app_1.environmentAtom,{environments:s}),o&&i.set(app_1.appStoreOverrideAtom,{environment:o.environment,environments:o.environments,activeMimeName:o.activeMimeName}),(null==o?void 0:o.operation)&&i.set((0,operation_2.operationStore)(o.operation.pointer),(0,operation_2.getDefaultOperationStore)(o.operation.pointer,o.operation.state.requestValues)),i}),[n,o]);return(0,react_1.useEffect)((()=>{(null==o?void 0:o.layout)&&a.set(app_1.layoutAtom,null==o?void 0:o.layout)}),[a,null==o?void 0:o.layout]),(0,jsx_runtime_1.jsxs)(jotai_1.Provider,{store:a,children:[(0,jsx_runtime_1.jsx)(nexus_1.default,{}),e]})}));
|
|
2
2
|
//# sourceMappingURL=Providers.js.map
|
|
@@ -8,3 +8,11 @@ export declare function Link(props: PropsWithChildren<{
|
|
|
8
8
|
}>): ReactElement | null;
|
|
9
9
|
export declare const StyledShareLink: import("styled-components").StyledComponent<typeof Link, any, {}, never>;
|
|
10
10
|
export declare function ShareLink(props: any): ReactElement;
|
|
11
|
+
export declare function MarkdownHeading({ level, id, children, 'data-source': dataSource, 'data-hash': dataHash, className, }: PropsWithChildren<{
|
|
12
|
+
level: number;
|
|
13
|
+
id: string;
|
|
14
|
+
'data-source'?: string;
|
|
15
|
+
'data-hash'?: string;
|
|
16
|
+
className?: string;
|
|
17
|
+
source?: string | 'openapi-docs';
|
|
18
|
+
}>): JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.StyledShareLink=void 0,exports.Link=Link,exports.ShareLink=ShareLink;const jsx_runtime_1=require("react/jsx-runtime"),styled_components_1=__importDefault(require("styled-components")),jotai_1=require("jotai"),react_router_dom_1=require("react-router-dom"),theme_1=require("@redocly/theme"),store_1=require("../../jotai/store"),utils_1=require("../../utils");function Link(e){var t;const{routingBasePath:i,unstable_hooks:r,onDeepLinkClick:
|
|
1
|
+
"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.StyledShareLink=void 0,exports.Link=Link,exports.ShareLink=ShareLink,exports.MarkdownHeading=MarkdownHeading;const jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),styled_components_1=__importDefault(require("styled-components")),jotai_1=require("jotai"),react_router_dom_1=require("react-router-dom"),theme_1=require("@redocly/theme"),store_1=require("../../jotai/store"),utils_1=require("../../utils"),services_1=require("../../services");function Link(e){var t;const{routingBasePath:i,unstable_hooks:r,onDeepLinkClick:a}=(0,jotai_1.useAtomValue)(store_1.globalOptionsAtom),n=e.security?null===(t=null==r?void 0:r.replaceSecurityLink)||void 0===t?void 0:t.call(r,{securityRequirementId:e.to}):e.to,o=a&&{onClick:e=>{e.preventDefault(),a(i+n)}};return n?(0,jsx_runtime_1.jsx)(react_router_dom_1.Link,Object.assign({"aria-label":e["aria-label"]||`link to ${n}`,id:(0,utils_1.tryDecodeURIComponent)(e.id||""),className:e.className||"",to:(null==n?void 0:n.startsWith("#"))?n:i+n},o,{children:e.children})):e.children?(0,jsx_runtime_1.jsxs)("span",{"aria-label":e["aria-label"]||`link to ${n}`,className:e.className,children:[" ",e.children," "]}):null}function ShareLink(e){return(0,jsx_runtime_1.jsx)(exports.StyledShareLink,Object.assign({},e,{children:(0,jsx_runtime_1.jsx)(theme_1.LinkIcon,{size:"13px",color:"--heading-anchor-color"})}))}exports.StyledShareLink=(0,styled_components_1.default)(Link)`
|
|
2
2
|
position: absolute;
|
|
3
3
|
top: 50%;
|
|
4
4
|
left: 0;
|
|
@@ -17,5 +17,5 @@
|
|
|
17
17
|
visibility: visible;
|
|
18
18
|
opacity: 1;
|
|
19
19
|
}
|
|
20
|
-
`;
|
|
20
|
+
`;const MD_CLASS_NAME="md";function MarkdownHeading({level:e,id:t,children:i,"data-source":r,"data-hash":a,className:n}){const{routingBasePath:o}=(0,jotai_1.useAtomValue)(store_1.globalOptionsAtom),s=(0,services_1.joinWithSeparator)(o,t.toLocaleLowerCase()),l=(0,jsx_runtime_1.jsx)(theme_1.Link,{"aria-label":`link to ${s}`,to:s,className:(0,theme_1.concatClassNames)("anchor","before"),children:(0,jsx_runtime_1.jsx)(theme_1.LinkIcon,{size:"14px",color:"--heading-anchor-color"})});return(0,react_1.createElement)(`h${e}`,{id:t,className:(0,theme_1.concatClassNames)("heading-anchor",MD_CLASS_NAME,n),"data-component-name":"Markdoc/Heading/Heading","data-source":r,"data-hash":a},(0,jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment,{children:[l,i]}))}
|
|
21
21
|
//# sourceMappingURL=linkify.js.map
|
|
@@ -24,5 +24,6 @@ export declare function getCodeSample({ lang, operation, exampleName, pathParams
|
|
|
24
24
|
environment: Record<string, string>;
|
|
25
25
|
translate: TFunction;
|
|
26
26
|
}): string;
|
|
27
|
+
export declare function getDataRequest(exampleValue: any, properties: any): boolean | any;
|
|
27
28
|
export declare function isDefined<T>(arg?: T): arg is T;
|
|
28
29
|
export declare function capitalizeFirst(str: string): string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,a,r){void 0===r&&(r=a);var s=Object.getOwnPropertyDescriptor(t,a);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,r,s)}:function(e,t,a,r){void 0===r&&(r=a),e[r]=t[a]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),__importStar=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var a in e)"default"!==a&&Object.prototype.hasOwnProperty.call(e,a)&&__createBinding(t,e,a);return __setModuleDefault(t,e),t},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.getCodeSample=getCodeSample,exports.isDefined=isDefined,exports.capitalizeFirst=capitalizeFirst;const Sampler=__importStar(require("openapi-sampler")),deepmerge_1=__importDefault(require("deepmerge")),jstoxml_1=require("jstoxml"),utils_1=require("../../utils"),utils_2=require("../utils"),constants_1=require("../../constants"),httpsnippet_1=require("./httpsnippet"),mediaContent_1=require("../../models/mediaContent"),string_utility_1=__importDefault(require("./httpsnippet/helpers/string-utility"));function getSelectedSecurityScheme(e,t){return e.find((e=>{const a=e.schemes.map((e=>e.id));return(0,utils_1.areArraysEqual)(a,t||[])}))}function mapOperationToHAR(e,{exampleName:t="",skipOptionalParameters:a=!1,withOAuth2Call:r=!1,spec:s,generatedPayloadSamplesMaxDepth:i=8,pathParams:n={},properties:o={}},{environment:l,requestValues:u,activeSecuritySchemeIds:c}){var p,d,m;const f=l.server,h=e.servers.find((e=>e.url===f))||e.servers[0],_=getSelectedSecurityScheme(e.security,c),{securityHeaders:y,securityCookies:g,securityQueries:v,securityOAuth2ExtraCalls:O,basicAuth:S}=getSecurityData(_||(null===(p=e.security)||void 0===p?void 0:p[0]),r,l),T=(null===(d=null==e?void 0:e.requestBody)||void 0===d?void 0:d.content)&&(0,mediaContent_1.getActiveMediaType)(e.requestBody.content),C={skipNonRequired:a,skipReadOnly:!0,maxSampleDepth:i,quiet:!0},b=u;let j=!1;const D=e.parameters.filter((e=>"header"===e.in)).filter((e=>!(a&&!e.required))).map((e=>{var t;return{name:e.name,value:(null===(t=b.header)||void 0===t?void 0:t[e.name])||(0,utils_1.getParameterValue)("header",e.name)||(0,utils_1.serializeParameterValue)(e,Sampler.sample(e.schema.rawSchema,C,s))}})).map((e=>((null==T?void 0:T.name)&&"content-type"===e.name.toLowerCase()&&(j=!0,e.value=T.name),e))).concat(y);!j&&(null==T?void 0:T.name)&&D.unshift({name:"Content-Type",value:null==T?void 0:T.name});const E=e.parameters.filter((e=>"cookie"===e.in)).filter((e=>!(a&&!e.required))).map((e=>utils_1.queryString.parse((0,utils_1.serializeParameterValue)(e,Sampler.sample(e.schema.rawSchema,C,s))))).reduce(((e,t)=>{var a;for(const[r,s]of Object.entries(t))e.push({name:r,value:String((null===(a=b.cookie)||void 0===a?void 0:a[r])||s)});return e}),[]).concat(g),q=e.parameters.filter((e=>"query"===e.in)).filter((e=>!(a&&!e.required))).map((e=>utils_1.queryString.parse((0,utils_1.serializeParameterValue)(e,Sampler.sample(e.schema.rawSchema,C,s))))).reduce(((e,t)=>{var a,r,s;for(const[i,n]of Object.entries(t))e.push({name:i,value:(0,utils_1.isArrayOfObjects)(null===(a=b.query)||void 0===a?void 0:a[i])&&JSON.stringify((0,utils_1.deleteEmptyArrayItem)(null===(r=b.query)||void 0===r?void 0:r[i]))||String((null===(s=b.query)||void 0===s?void 0:s[i])||n)});return e}),[]).concat(v),P=`${null==h?void 0:h.url.replace(/\/$/,"")}/${e.path.replace(/^\//,"")}`,k=e.parameters.filter((e=>"path"===e.in)).reduce(((e,t)=>{var a;const{in:r,name:s}=t;return e[s]=(null===(a=b.path)||void 0===a?void 0:a[s])||n[s]||(0,utils_1.getParameterValue)(r,s),e}),{}),w=null===(m=null==T?void 0:T.examples)||void 0===m?void 0:m[t],A=(null==T?void 0:T.examples)||{},[R]=Object.values(A),M=(null==b?void 0:b.body)||(null==w?void 0:w.value)||(null==R?void 0:R.value)||(null==T?void 0:T.schema)&&Sampler.sample(null==T?void 0:T.schema.rawSchema,C,s),x=null==T?void 0:T.name.toLowerCase();let N="",H=[];switch((0,utils_2.normalizeMimeType)(x)){case constants_1.MediaTypes.JSON:N=JSON.stringify(getDataRequest(M,o));break;case constants_1.MediaTypes.XML:N="object"==typeof M?(0,jstoxml_1.toXML)(getDataRequest(M,o),{indent:" "}):M;break;case constants_1.MediaTypes.URL_ENCODED:case constants_1.MediaTypes.MULTIPART:N=utils_1.queryString.stringify(getDataRequest(M,o)),H=objectToHarParams(getDataRequest(M,o));break;default:N=String(M||"")}const U=N?{mimeType:(null==T?void 0:T.name)||constants_1.MediaTypes.OCTET_STREAM,text:N,params:H}:void 0,z=e.responses.map((e=>e.code));return{method:e.httpVerb,url:P,httpVersion:"HTTP/1.1",cookies:E,headers:D,queryString:q,postData:U,headersSize:-1,bodySize:-1,securityOAuth2ExtraCalls:O,basicAuth:S,pathParameters:k,serverVariables:l,allResponseCodes:z}}const defaultOptions={withImports:!0,withComments:!1},langToSnippetConfig={curl:{code:"shell",defaultTarget:"curl",defaultOptions:Object.assign(Object.assign({},defaultOptions),{short:!0})},JavaScript:{code:"javascript",defaultTarget:"fetch",defaultOptions:Object.assign(Object.assign({},defaultOptions),{withImports:!1})},"Node.js":{code:"node",defaultTarget:"fetch",defaultOptions:Object.assign({},defaultOptions)},Python:{code:"python",defaultTarget:"requests",defaultOptions:Object.assign({},defaultOptions)},"Java8+Apache":{code:"java8",defaultTarget:"apachehttp",defaultOptions:Object.assign({},defaultOptions)},Java:{code:"java",defaultTarget:"httpclient",defaultOptions:Object.assign({},defaultOptions)},"C#":{code:"csharp",defaultTarget:"httpclient",defaultOptions:Object.assign({},defaultOptions)},"C#+Newtonsoft":{code:"csharpNewtonsoft",defaultTarget:"httpclient",defaultOptions:Object.assign({},defaultOptions)},Go:{code:"go",defaultTarget:"http.DefaultClient",defaultOptions:Object.assign({},defaultOptions)},PHP:{code:"php",defaultTarget:"curl",defaultOptions:Object.assign({},defaultOptions)},Ruby:{code:"ruby",defaultTarget:"net::http",defaultOptions:Object.assign({},defaultOptions)},R:{code:"r",defaultTarget:"httr",defaultOptions:Object.assign({},defaultOptions)}};function getCodeSample({lang:e,operation:t,exampleName:a,pathParams:r,properties:s,options:i={},environment:n,translate:o}){try{const{skipOptionalParameters:l,withOAuth2Call:u,spec:c,generatedPayloadSamplesMaxDepth:p,store:d}=i,m=mapOperationToHAR(t,{exampleName:a,pathParams:r,properties:s,skipOptionalParameters:l,withOAuth2Call:u,spec:c,generatedPayloadSamplesMaxDepth:p},{environment:n,requestValues:d.requestValues,activeSecuritySchemeIds:d.activeSecuritySchemeIds}),f=new httpsnippet_1.HTTPSnippet(m);return langToSnippetConfig[e]?f.convert(langToSnippetConfig[e].code,langToSnippetConfig[e].defaultTarget,Object.assign(Object.assign({},langToSnippetConfig[e].defaultOptions),i)):o("openapi.unsupportedLanguage","Language is not supported.")}catch(e){return console.error(e),o("openapi.failedToGenerateCodeSample","Failed to generate code sample.")}}function getSecurityData(e,t,a){var r,s,i,n,o;const l={securityHeaders:[],securityCookies:[],securityQueries:[],securityOAuth2ExtraCalls:[],basicAuth:void 0};for(const u of(null==e?void 0:e.schemes)||[]){const e=(0,utils_1.getSecurityDetails)(u.id,a);switch(u.type){case"openIdConnect":null===(r=l.securityHeaders)||void 0===r||r.push({name:"Authorization",value:e.token?`${e.token.token_type||"Bearer"} ${e.token.access_token}`:"Bearer <YOUR_TOKEN_HERE>"});break;case"oauth2":{const a=e.token?`${e.token.token_type||"Bearer"} ${e.token.access_token}`:"Bearer <YOUR_TOKEN_HERE>";u.flows.clientCredentials&&t?l.securityOAuth2ExtraCalls.push(getOAuth2ClientCredsCallHar(u.flows.clientCredentials,u.scopes,e)):u.flows.password&&t&&l.securityOAuth2ExtraCalls.push(getOAuth2PasswordCallHar(u.flows.password,u.scopes,e)),null===(s=l.securityHeaders)||void 0===s||s.push({name:"Authorization",value:a});break}case"apiKey":{const t=e.raw||"YOUR_API_KEY_HERE";"header"===u.in&&(null===(i=l.securityHeaders)||void 0===i||i.push({name:u.name,value:t})),"cookie"===u.in&&l.securityCookies.push({name:u.name,value:t}),"query"===u.in&&l.securityQueries.push({name:u.name,value:t});break}case"http":if("basic"===u.scheme)l.basicAuth={username:e.username||`<${string_utility_1.default.toSnakeCase("Username")}>`,password:e.password||`<${string_utility_1.default.toSnakeCase("Password")}>`};else{const t=(null===(n=e.token)||void 0===n?void 0:n.access_token)||`<YOUR_${u.bearerFormat||"TOKEN"}_HERE>`;null===(o=l.securityHeaders)||void 0===o||o.push({name:"Authorization",value:`${capitalizeFirst(u.scheme||"bearer")} ${t}`})}}}return l}function getOAuth2PasswordCallHar(e,t,a){return{method:"POST",url:e.tokenUrl,httpVersion:"HTTP/1.1",headers:[{name:"Content-Type",value:constants_1.MediaTypes.URL_ENCODED},{name:"Accept",value:constants_1.MediaTypes.JSON}],queryString:[],postData:{mimeType:constants_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:constants_1.MediaTypes.URL_ENCODED},{name:"Accept",value:constants_1.MediaTypes.JSON}],queryString:[],postData:{mimeType:constants_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,t=""){const a=[];for(const[r,s]of Object.entries(e)){const e=t?`${t}[${r}]`:r;"object"==typeof s&&null!==s?a.push(...objectToHarParams(s,e)):a.push({name:e,value:String(s)})}return a}function isDefined(e){return void 0!==e}function capitalizeFirst(e){return e.charAt(0).toUpperCase()+e.slice(1)}
|
|
1
|
+
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,a,r){void 0===r&&(r=a);var s=Object.getOwnPropertyDescriptor(t,a);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,r,s)}:function(e,t,a,r){void 0===r&&(r=a),e[r]=t[a]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),__importStar=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var a in e)"default"!==a&&Object.prototype.hasOwnProperty.call(e,a)&&__createBinding(t,e,a);return __setModuleDefault(t,e),t},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.getCodeSample=getCodeSample,exports.getDataRequest=getDataRequest,exports.isDefined=isDefined,exports.capitalizeFirst=capitalizeFirst;const Sampler=__importStar(require("openapi-sampler")),deepmerge_1=__importDefault(require("deepmerge")),jstoxml_1=require("jstoxml"),theme_1=require("@redocly/theme"),utils_1=require("../../utils"),utils_2=require("../utils"),constants_1=require("../../constants"),httpsnippet_1=require("./httpsnippet"),mediaContent_1=require("../../models/mediaContent"),string_utility_1=__importDefault(require("./httpsnippet/helpers/string-utility"));function getSelectedSecurityScheme(e,t){return e.find((e=>{const a=e.schemes.map((e=>e.id));return(0,utils_1.areArraysEqual)(a,t||[])}))}function mapOperationToHAR(e,{exampleName:t="",skipOptionalParameters:a=!1,withOAuth2Call:r=!1,spec:s,generatedPayloadSamplesMaxDepth:i=8,pathParams:n={},properties:o={}},{environment:l,requestValues:u,activeSecuritySchemeIds:c}){var p,d,m;const h=l.server,f=e.servers.find((e=>e.url===h))||e.servers[0],_=getSelectedSecurityScheme(e.security,c),{securityHeaders:g,securityCookies:y,securityQueries:v,securityOAuth2ExtraCalls:O,basicAuth:S}=getSecurityData(_||(null===(p=e.security)||void 0===p?void 0:p[0]),r,l),T=(null===(d=null==e?void 0:e.requestBody)||void 0===d?void 0:d.content)&&(0,mediaContent_1.getActiveMediaType)(e.requestBody.content),b={skipNonRequired:a,skipReadOnly:!0,maxSampleDepth:i,quiet:!0},C=u;let j=!1;const D=e.parameters.filter((e=>"header"===e.in)).filter((e=>!(a&&!e.required))).map((e=>{var t;return{name:e.name,value:(null===(t=C.header)||void 0===t?void 0:t[e.name])||(0,utils_1.getParameterValue)("header",e.name)||(0,utils_1.serializeParameterValue)(e,Sampler.sample(e.schema.rawSchema,b,s))}})).map((e=>((null==T?void 0:T.name)&&"content-type"===e.name.toLowerCase()&&(j=!0,e.value=T.name),e))).concat(g);!j&&(null==T?void 0:T.name)&&D.unshift({name:"Content-Type",value:null==T?void 0:T.name});const E=e.parameters.filter((e=>"cookie"===e.in)).filter((e=>!(a&&!e.required))).map((e=>utils_1.queryString.parse((0,utils_1.serializeParameterValue)(e,Sampler.sample(e.schema.rawSchema,b,s))))).reduce(((e,t)=>{var a;for(const[r,s]of Object.entries(t))e.push({name:r,value:String((null===(a=C.cookie)||void 0===a?void 0:a[r])||s)});return e}),[]).concat(y),q=e.parameters.filter((e=>"query"===e.in)).filter((e=>!(a&&!e.required))).map((e=>utils_1.queryString.parse((0,utils_1.serializeParameterValue)(e,Sampler.sample(e.schema.rawSchema,b,s))))).reduce(((e,t)=>{var a,r,s;for(const[i,n]of Object.entries(t))e.push({name:i,value:(0,utils_1.isArrayOfObjects)(null===(a=C.query)||void 0===a?void 0:a[i])&&JSON.stringify((0,utils_1.deleteEmptyArrayItem)(null===(r=C.query)||void 0===r?void 0:r[i]))||String((null===(s=C.query)||void 0===s?void 0:s[i])||n)});return e}),[]).concat(v),k=`${null==f?void 0:f.url.replace(/\/$/,"")}/${e.path.replace(/^\//,"")}`,P=e.parameters.filter((e=>"path"===e.in)).reduce(((e,t)=>{var a;const{in:r,name:s}=t;return e[s]=(null===(a=C.path)||void 0===a?void 0:a[s])||n[s]||(0,utils_1.getParameterValue)(r,s),e}),{}),w=null===(m=null==T?void 0:T.examples)||void 0===m?void 0:m[t],R=(null==T?void 0:T.examples)||{},[A]=Object.values(R),M=(null==C?void 0:C.body)||(null==w?void 0:w.value)||(null==A?void 0:A.value)||(null==T?void 0:T.schema)&&Sampler.sample(null==T?void 0:T.schema.rawSchema,b,s),x=null==T?void 0:T.name.toLowerCase();let N="",H=[];switch((0,utils_2.normalizeMimeType)(x)){case constants_1.MediaTypes.JSON:N=JSON.stringify(getDataRequest(M,o));break;case constants_1.MediaTypes.XML:N="object"==typeof M?(0,jstoxml_1.toXML)(getDataRequest(M,o),{indent:" "}):M;break;case constants_1.MediaTypes.URL_ENCODED:case constants_1.MediaTypes.MULTIPART:N=utils_1.queryString.stringify(getDataRequest(M,o)),H=objectToHarParams(getDataRequest(M,o));break;default:N=String(M||"")}const U=N?{mimeType:(null==T?void 0:T.name)||constants_1.MediaTypes.OCTET_STREAM,text:N,params:H}:void 0,z=e.responses.map((e=>e.code));return{method:e.httpVerb,url:k,httpVersion:"HTTP/1.1",cookies:E,headers:D,queryString:q,postData:U,headersSize:-1,bodySize:-1,securityOAuth2ExtraCalls:O,basicAuth:S,pathParameters:P,serverVariables:l,allResponseCodes:z}}const defaultOptions={withImports:!0,withComments:!1},langToSnippetConfig={curl:{code:"shell",defaultTarget:"curl",defaultOptions:Object.assign(Object.assign({},defaultOptions),{short:!0})},JavaScript:{code:"javascript",defaultTarget:"fetch",defaultOptions:Object.assign(Object.assign({},defaultOptions),{withImports:!1})},"Node.js":{code:"node",defaultTarget:"fetch",defaultOptions:Object.assign({},defaultOptions)},Python:{code:"python",defaultTarget:"requests",defaultOptions:Object.assign({},defaultOptions)},"Java8+Apache":{code:"java8",defaultTarget:"apachehttp",defaultOptions:Object.assign({},defaultOptions)},Java:{code:"java",defaultTarget:"httpclient",defaultOptions:Object.assign({},defaultOptions)},"C#":{code:"csharp",defaultTarget:"httpclient",defaultOptions:Object.assign({},defaultOptions)},"C#+Newtonsoft":{code:"csharpNewtonsoft",defaultTarget:"httpclient",defaultOptions:Object.assign({},defaultOptions)},Go:{code:"go",defaultTarget:"http.DefaultClient",defaultOptions:Object.assign({},defaultOptions)},PHP:{code:"php",defaultTarget:"curl",defaultOptions:Object.assign({},defaultOptions)},Ruby:{code:"ruby",defaultTarget:"net::http",defaultOptions:Object.assign({},defaultOptions)},R:{code:"r",defaultTarget:"httr",defaultOptions:Object.assign({},defaultOptions)}};function getCodeSample({lang:e,operation:t,exampleName:a,pathParams:r,properties:s,options:i={},environment:n,translate:o}){try{const{skipOptionalParameters:l,withOAuth2Call:u,spec:c,generatedPayloadSamplesMaxDepth:p,store:d}=i,m=mapOperationToHAR(t,{exampleName:a,pathParams:r,properties:s,skipOptionalParameters:l,withOAuth2Call:u,spec:c,generatedPayloadSamplesMaxDepth:p},{environment:n,requestValues:d.requestValues,activeSecuritySchemeIds:d.activeSecuritySchemeIds}),h=new httpsnippet_1.HTTPSnippet(m);return langToSnippetConfig[e]?h.convert(langToSnippetConfig[e].code,langToSnippetConfig[e].defaultTarget,Object.assign(Object.assign({},langToSnippetConfig[e].defaultOptions),i)):o("openapi.unsupportedLanguage","Language is not supported.")}catch(e){return console.error(e),o("openapi.failedToGenerateCodeSample","Failed to generate code sample.")}}function getSecurityData(e,t,a){var r,s,i,n,o;const l={securityHeaders:[],securityCookies:[],securityQueries:[],securityOAuth2ExtraCalls:[],basicAuth:void 0};for(const u of(null==e?void 0:e.schemes)||[]){const e=(0,utils_1.getSecurityDetails)(u.id,a);switch(u.type){case"openIdConnect":null===(r=l.securityHeaders)||void 0===r||r.push({name:"Authorization",value:e.token?`${e.token.token_type||"Bearer"} ${e.token.access_token}`:"Bearer <YOUR_TOKEN_HERE>"});break;case"oauth2":{const a=e.token?`${e.token.token_type||"Bearer"} ${e.token.access_token}`:"Bearer <YOUR_TOKEN_HERE>";u.flows.clientCredentials&&t?l.securityOAuth2ExtraCalls.push(getOAuth2ClientCredsCallHar(u.flows.clientCredentials,u.scopes,e)):u.flows.password&&t&&l.securityOAuth2ExtraCalls.push(getOAuth2PasswordCallHar(u.flows.password,u.scopes,e)),null===(s=l.securityHeaders)||void 0===s||s.push({name:"Authorization",value:a});break}case"apiKey":{const t=e.raw||"YOUR_API_KEY_HERE";"header"===u.in&&(null===(i=l.securityHeaders)||void 0===i||i.push({name:u.name,value:t})),"cookie"===u.in&&l.securityCookies.push({name:u.name,value:t}),"query"===u.in&&l.securityQueries.push({name:u.name,value:t});break}case"http":if("basic"===u.scheme)l.basicAuth={username:e.username||`<${string_utility_1.default.toSnakeCase("Username")}>`,password:e.password||`<${string_utility_1.default.toSnakeCase("Password")}>`};else{const t=(null===(n=e.token)||void 0===n?void 0:n.access_token)||`<YOUR_${u.bearerFormat||"TOKEN"}_HERE>`;null===(o=l.securityHeaders)||void 0===o||o.push({name:"Authorization",value:`${capitalizeFirst(u.scheme||"bearer")} ${t}`})}}}return l}function getOAuth2PasswordCallHar(e,t,a){return{method:"POST",url:e.tokenUrl,httpVersion:"HTTP/1.1",headers:[{name:"Content-Type",value:constants_1.MediaTypes.URL_ENCODED},{name:"Accept",value:constants_1.MediaTypes.JSON}],queryString:[],postData:{mimeType:constants_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:constants_1.MediaTypes.URL_ENCODED},{name:"Accept",value:constants_1.MediaTypes.JSON}],queryString:[],postData:{mimeType:constants_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((0,theme_1.isObject)(e))return Object.keys(e).length>0&&0===Object.keys(t).length?e:(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,t=""){const a=[];for(const[r,s]of Object.entries(e)){const e=t?`${t}[${r}]`:r;"object"==typeof s&&null!==s?a.push(...objectToHarParams(s,e)):a.push({name:e,value:String(s)})}return a}function isDefined(e){return void 0!==e}function capitalizeFirst(e){return e.charAt(0).toUpperCase()+e.slice(1)}
|
|
2
2
|
//# sourceMappingURL=generator.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.normalizeOptions=normalizeOptions;const theme_1=require("@redocly/theme"),constants_1=require("../../constants"),utils_1=require("../../utils"),helpers_1=require("./helpers"),constants_2=require("../code-samples/constants");function normalizeOptions(e,o){var s,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.normalizeOptions=normalizeOptions;const theme_1=require("@redocly/theme"),constants_1=require("../../constants"),utils_1=require("../../utils"),helpers_1=require("./helpers"),constants_2=require("../code-samples/constants"),linkify_1=require("../../components/common/linkify");function normalizeOptions(e,o){var n,s,i,a,l,t,r,d,u,c,p;e=Object.assign(Object.assign(Object.assign({},o),e),{markdocOptions:Object.assign(Object.assign({},null==e?void 0:e.markdocOptions),{components:Object.assign(Object.assign(Object.assign({},null===(n=null==o?void 0:o.markdocOptions)||void 0===n?void 0:n.components),null===(s=null==e?void 0:e.markdocOptions)||void 0===s?void 0:s.components),{Heading:linkify_1.MarkdownHeading}),tags:Object.assign(Object.assign({},null===(i=null==o?void 0:o.markdocOptions)||void 0===i?void 0:i.tags),null===(a=null==e?void 0:e.markdocOptions)||void 0===a?void 0:a.tags),nodes:Object.assign(Object.assign(Object.assign({},null===(l=null==o?void 0:o.markdocOptions)||void 0===l?void 0:l.nodes),null===(t=null==e?void 0:e.markdocOptions)||void 0===t?void 0:t.nodes),{heading:(null===(d=null===(r=null==o?void 0:o.markdocOptions)||void 0===r?void 0:r.nodes)||void 0===d?void 0:d.heading)||(null===(u=null==e?void 0:e.markdocOptions)||void 0===u?void 0:u.nodes.heading)})})});const m=Array.isArray(e.ignoreNamedSchemas)?e.ignoreNamedSchemas:null===(c=e.ignoreNamedSchemas)||void 0===c?void 0:c.split(",").map((e=>e.trim()));return{downloadUrls:e.downloadUrls,schemaDefinitionsTagName:e.schemaDefinitionsTagName,corsProxyUrl:e.corsProxyUrl&&(0,theme_1.addTrailingSlash)(e.corsProxyUrl),hideSidebar:(0,utils_1.argValueToBoolean)(e.hideSidebar,!1),jsonSamplesExpandLevel:(0,utils_1.argValueToExpandLevel)(e.jsonSamplesExpandLevel,2),generatedSamplesMaxDepth:(0,utils_1.argValueToInt)(e.generatedSamplesMaxDepth,8),hideDownloadButtons:(0,utils_1.argValueToBoolean)(e.hideDownloadButtons,!1),hideInfoMetadata:(0,utils_1.argValueToBoolean)(e.hideInfoMetadata,!1),hideLoading:(0,utils_1.argValueToBoolean)(e.hideLoading,!1),hideSchemaTitles:(0,utils_1.argValueToBoolean)(e.hideSchemaTitles,!1),maxDisplayedEnumValues:(0,utils_1.argValueToNumber)(e.maxDisplayedEnumValues),mockServer:(null===(p=e.mockServer)||void 0===p?void 0:p.url)?{url:e.mockServer.url,position:e.mockServer.position||"first",description:e.mockServer.description||"Mock server"}:void 0,hideReplay:(0,utils_1.argValueToBoolean)(e.hideReplay,!1),oAuth2RedirectURI:e.oAuth2RedirectURI||null,onlyRequiredInSamples:(0,utils_1.argValueToBoolean)(e.onlyRequiredInSamples,!1),onDeepLinkClick:e.onDeepLinkClick||(0,utils_1.getWindowReferenceOptions)(constants_1.WindowReferenceOptions.ON_DEEP_LINK_CLICK),requestInterceptor:e.requestInterceptor||(0,utils_1.getWindowReferenceOptions)(constants_1.WindowReferenceOptions.REQUEST_INTERCEPTOR),routingBasePath:(0,theme_1.isUndefined)(e.disableRouter)?"":e.routingBasePath&&(0,utils_1.normalizePath)(e.routingBasePath)||"",schemasExpansionLevel:(0,utils_1.argValueToExpandLevel)(e.schemasExpansionLevel),feedback:e.feedback||{hide:!1},sortRequiredPropsFirst:(0,utils_1.argValueToBoolean)(e.sortRequiredPropsFirst,!1),scrollYOffset:(0,helpers_1.normalizeScrollYOffset)(e.scrollYOffset),showExtensions:(0,helpers_1.normalizeShowExtensions)(e.showExtensions),sanitize:(0,utils_1.argValueToBoolean)(e.sanitize,!1),skipBundle:(0,utils_1.argValueToBoolean)(e.skipBundle,!1),ignoreNamedSchemas:new Set(m),markdocOptions:null==e?void 0:e.markdocOptions,codeSamples:e.codeSamples||{languages:Object.values(constants_2.Languages).map((e=>({lang:e})))},layout:e.layout||theme_1.LayoutVariant.THREE_PANEL,events:e.events||{},unstable_hooks:e.unstable_hooks||(0,utils_1.getWindowReferenceOptions)(constants_1.WindowReferenceOptions.HOOKS)||{},unstable_skipSamples:(0,utils_1.argValueToBoolean)(e.unstable_skipSamples,!1),unstable_externalCodeSamples:e.unstable_externalCodeSamples||[],hidePropertiesPrefix:(0,utils_1.argValueToBoolean)(null==e?void 0:e.hidePropertiesPrefix,!1)}}
|
|
2
2
|
//# sourceMappingURL=normalizeOptions.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(e,t,
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(e,o,t,i){return new(t||(t=Promise))((function(n,r){function a(e){try{l(i.next(e))}catch(e){r(e)}}function s(e){try{l(i.throw(e))}catch(e){r(e)}}function l(e){var o;e.done?n(e.value):(o=e.value,o instanceof t?o:new t((function(e){e(o)}))).then(a,s)}l((i=i.apply(e,o||[])).next())}))};import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{cloneElement,isValidElement,memo,useCallback,useEffect,useMemo,useState}from"react";import{Tag}from"@markdoc/markdoc";import{LayoutVariant,Loading}from"@redocly/theme";import{createStore,Provider}from"jotai";import{normalizeOptions,OpenAPIParser}from"../../services";import{getMarkdownHeaderId,loadSingle,useDeepCompareMemoize}from"./utils";import{argValueToBoolean,normalizeServers}from"../../utils";import{SchemaDefinition}from"../SchemaDefinition";import{appStore,appStoreOverrideAtom,environmentAtom,layoutAtom}from"../../jotai/app";import JotaiNexus from"../../jotai/nexus";import{mapObject}from"../../utils/object";import{mergeInMockServer}from"../../models/operation";import{getDefaultOperationStore,operationStore}from"../../jotai/operation";import{getServerEnvName}from"../../utils/environments";import{globalStoreAtom}from"../../jotai/store";import{MarkdownHeading}from"../common/linkify";export const AppProvider=({options:e,definitionUrl:o,definition:t,activeSampleLanguage:i,children:n})=>{const[,r]=useState(),[a,s]=useState(!0),[l,m]=useState(null);useEffect((()=>{!function(){__awaiter(this,void 0,void 0,(function*(){s(!0);try{m(yield loadSingle(t,o,e))}catch(e){r((()=>{throw e}))}}))}()}),[t,o,e]);const u=useMemo((()=>{var t,n,r;if(l)return(null===(t=null==e?void 0:e.unstable_hooks)||void 0===t?void 0:t.onInit)&&(null===(r=null===(n=e.unstable_hooks)||void 0===n?void 0:n.onInit)||void 0===r||r.call(n,{store:{definition:l,options:e,definitionUrl:o,activeSampleLanguage:i}})),{definition:l,options:e,definitionUrl:o,activeSampleLanguage:i}}),useDeepCompareMemoize([l,e,o]));return useEffect((()=>{u&&s(!1)}),[u]),u?a?argValueToBoolean(null==e?void 0:e.hideLoading,!1)?null:_jsx(Loading,{color:"--loading-spinner-color"}):isValidElement(n)?cloneElement(n,{store:u}):null:null};const DEFAULT_OPTIONS={ignoreNamedSchemas:["java.io.ObjectStreamField"],maxDisplayedEnumValues:10,markdocOptions:{tags:{schemaDefinition:{render:"SchemaDefinition",attributes:{schemaRef:{type:String},exampleRef:{type:String},showReadOnly:{type:Boolean},showWriteOnly:{type:Boolean},htmlWrap:{type:String,default:!1}}}},nodes:{heading:{children:["inline"],attributes:{id:{type:String},level:{type:Number,required:!0,default:1}},transform(e,o){const t=e.transformAttributes(o),i=e.transformChildren(o),n="string"==typeof t.id?t.id:getMarkdownHeaderId(i);return new Tag("Heading",Object.assign(Object.assign({},t),{id:n,level:e.attributes.level}),i)}}},components:{SchemaDefinition:SchemaDefinition,Heading:MarkdownHeading}}};export const StoreProvider=memo((({children:e,options:o,definitionUrl:t,definition:i,withState:n})=>{const r=useCallback((()=>{const e=normalizeOptions(o,DEFAULT_OPTIONS);return{options:e,parser:new OpenAPIParser(i,t,e)}}),[i,t,o]),a=useMemo((()=>{var e,o;const t=createStore(),i=r();t.set(globalStoreAtom,i);const a=normalizeServers(i.parser.definitionUrl,mergeInMockServer((null===(e=i.parser.definition)||void 0===e?void 0:e.servers)||[],i.options.mockServer)),s=Object.fromEntries(a.map((e=>[getServerEnvName(e),Object.assign({server:e.url},mapObject(e.variables||{},(e=>e.default||"")))])));return t.sub(appStore,(()=>{})),t.set(layoutAtom,(null===(o=i.options)||void 0===o?void 0:o.layout)||LayoutVariant.THREE_PANEL),t.set(environmentAtom,{environments:s}),n&&t.set(appStoreOverrideAtom,{environment:n.environment,environments:n.environments,activeMimeName:n.activeMimeName}),(null==n?void 0:n.operation)&&t.set(operationStore(n.operation.pointer),getDefaultOperationStore(n.operation.pointer,n.operation.state.requestValues)),t}),[r,n]);return useEffect((()=>{(null==n?void 0:n.layout)&&a.set(layoutAtom,null==n?void 0:n.layout)}),[a,null==n?void 0:n.layout]),_jsxs(Provider,{store:a,children:[_jsx(JotaiNexus,{}),e]})}));
|
|
2
2
|
//# sourceMappingURL=Providers.js.map
|
|
@@ -8,3 +8,11 @@ export declare function Link(props: PropsWithChildren<{
|
|
|
8
8
|
}>): ReactElement | null;
|
|
9
9
|
export declare const StyledShareLink: import("styled-components").StyledComponent<typeof Link, any, {}, never>;
|
|
10
10
|
export declare function ShareLink(props: any): ReactElement;
|
|
11
|
+
export declare function MarkdownHeading({ level, id, children, 'data-source': dataSource, 'data-hash': dataHash, className, }: PropsWithChildren<{
|
|
12
|
+
level: number;
|
|
13
|
+
id: string;
|
|
14
|
+
'data-source'?: string;
|
|
15
|
+
'data-hash'?: string;
|
|
16
|
+
className?: string;
|
|
17
|
+
source?: string | 'openapi-docs';
|
|
18
|
+
}>): JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import styled from"styled-components";import{useAtomValue}from"jotai";import{Link as LinkRouter}from"react-router-dom";import{LinkIcon}from"@redocly/theme";import{globalOptionsAtom}from"../../jotai/store";import{tryDecodeURIComponent}from"../../utils";export function Link(
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";import{createElement}from"react";import styled from"styled-components";import{useAtomValue}from"jotai";import{Link as LinkRouter}from"react-router-dom";import{LinkIcon,Link as ThemeLink,concatClassNames}from"@redocly/theme";import{globalOptionsAtom}from"../../jotai/store";import{tryDecodeURIComponent}from"../../utils";import{joinWithSeparator}from"../../services";export function Link(e){var o;const{routingBasePath:a,unstable_hooks:t,onDeepLinkClick:i}=useAtomValue(globalOptionsAtom),n=e.security?null===(o=null==t?void 0:t.replaceSecurityLink)||void 0===o?void 0:o.call(t,{securityRequirementId:e.to}):e.to,r=i&&{onClick:e=>{e.preventDefault(),i(a+n)}};return n?_jsx(LinkRouter,Object.assign({"aria-label":e["aria-label"]||`link to ${n}`,id:tryDecodeURIComponent(e.id||""),className:e.className||"",to:(null==n?void 0:n.startsWith("#"))?n:a+n},r,{children:e.children})):e.children?_jsxs("span",{"aria-label":e["aria-label"]||`link to ${n}`,className:e.className,children:[" ",e.children," "]}):null}export const StyledShareLink=styled(Link)`
|
|
2
2
|
position: absolute;
|
|
3
3
|
top: 50%;
|
|
4
4
|
left: 0;
|
|
@@ -17,5 +17,5 @@ import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import styled from"styl
|
|
|
17
17
|
visibility: visible;
|
|
18
18
|
opacity: 1;
|
|
19
19
|
}
|
|
20
|
-
`;export function ShareLink(
|
|
20
|
+
`;export function ShareLink(e){return _jsx(StyledShareLink,Object.assign({},e,{children:_jsx(LinkIcon,{size:"13px",color:"--heading-anchor-color"})}))}const MD_CLASS_NAME="md";export function MarkdownHeading({level:e,id:o,children:a,"data-source":t,"data-hash":i,className:n}){const{routingBasePath:r}=useAtomValue(globalOptionsAtom),s=joinWithSeparator(r,o.toLocaleLowerCase()),l=_jsx(ThemeLink,{"aria-label":`link to ${s}`,to:s,className:concatClassNames("anchor","before"),children:_jsx(LinkIcon,{size:"14px",color:"--heading-anchor-color"})});return createElement(`h${e}`,{id:o,className:concatClassNames("heading-anchor",MD_CLASS_NAME,n),"data-component-name":"Markdoc/Heading/Heading","data-source":t,"data-hash":i},_jsxs(_Fragment,{children:[l,a]}))}
|
|
21
21
|
//# sourceMappingURL=linkify.js.map
|
|
@@ -24,5 +24,6 @@ export declare function getCodeSample({ lang, operation, exampleName, pathParams
|
|
|
24
24
|
environment: Record<string, string>;
|
|
25
25
|
translate: TFunction;
|
|
26
26
|
}): string;
|
|
27
|
+
export declare function getDataRequest(exampleValue: any, properties: any): boolean | any;
|
|
27
28
|
export declare function isDefined<T>(arg?: T): arg is T;
|
|
28
29
|
export declare function capitalizeFirst(str: string): string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import*as Sampler from"openapi-sampler";import merge from"deepmerge";import{toXML}from"jstoxml";import{areArraysEqual,serializeParameterValue,getSecurityDetails,getParameterValue,queryString,isArrayOfObjects,deleteEmptyArrayItem}from"../../utils";import{normalizeMimeType,arrayMergeStrategy}from"../utils";import{MediaTypes}from"../../constants";import{HTTPSnippet}from"./httpsnippet";import{getActiveMediaType}from"../../models/mediaContent";import StringUtility from"./httpsnippet/helpers/string-utility";function getSelectedSecurityScheme(e,t){return e.find((e=>{const a=e.schemes.map((e=>e.id));return areArraysEqual(a,t||[])}))}function mapOperationToHAR(e,{exampleName:t="",skipOptionalParameters:a=!1,withOAuth2Call:r=!1,spec:s,generatedPayloadSamplesMaxDepth:i=8,pathParams:n={},properties:o={}},{environment:l,requestValues:u,activeSecuritySchemeIds:p}){var c,d,m;const h=l.server,y=e.servers.find((e=>e.url===h))||e.servers[0],f=getSelectedSecurityScheme(e.security,p),{securityHeaders:g,securityCookies:
|
|
1
|
+
import*as Sampler from"openapi-sampler";import merge from"deepmerge";import{toXML}from"jstoxml";import{isObject}from"@redocly/theme";import{areArraysEqual,serializeParameterValue,getSecurityDetails,getParameterValue,queryString,isArrayOfObjects,deleteEmptyArrayItem}from"../../utils";import{normalizeMimeType,arrayMergeStrategy}from"../utils";import{MediaTypes}from"../../constants";import{HTTPSnippet}from"./httpsnippet";import{getActiveMediaType}from"../../models/mediaContent";import StringUtility from"./httpsnippet/helpers/string-utility";function getSelectedSecurityScheme(e,t){return e.find((e=>{const a=e.schemes.map((e=>e.id));return areArraysEqual(a,t||[])}))}function mapOperationToHAR(e,{exampleName:t="",skipOptionalParameters:a=!1,withOAuth2Call:r=!1,spec:s,generatedPayloadSamplesMaxDepth:i=8,pathParams:n={},properties:o={}},{environment:l,requestValues:u,activeSecuritySchemeIds:p}){var c,d,m;const h=l.server,y=e.servers.find((e=>e.url===h))||e.servers[0],f=getSelectedSecurityScheme(e.security,p),{securityHeaders:g,securityCookies:O,securityQueries:v,securityOAuth2ExtraCalls:S,basicAuth:T}=getSecurityData(f||(null===(c=e.security)||void 0===c?void 0:c[0]),r,l),C=(null===(d=null==e?void 0:e.requestBody)||void 0===d?void 0:d.content)&&getActiveMediaType(e.requestBody.content),b={skipNonRequired:a,skipReadOnly:!0,maxSampleDepth:i,quiet:!0},E=u;let _=!1;const j=e.parameters.filter((e=>"header"===e.in)).filter((e=>!(a&&!e.required))).map((e=>{var t;return{name:e.name,value:(null===(t=E.header)||void 0===t?void 0:t[e.name])||getParameterValue("header",e.name)||serializeParameterValue(e,Sampler.sample(e.schema.rawSchema,b,s))}})).map((e=>((null==C?void 0:C.name)&&"content-type"===e.name.toLowerCase()&&(_=!0,e.value=C.name),e))).concat(g);!_&&(null==C?void 0:C.name)&&j.unshift({name:"Content-Type",value:null==C?void 0:C.name});const k=e.parameters.filter((e=>"cookie"===e.in)).filter((e=>!(a&&!e.required))).map((e=>queryString.parse(serializeParameterValue(e,Sampler.sample(e.schema.rawSchema,b,s))))).reduce(((e,t)=>{var a;for(const[r,s]of Object.entries(t))e.push({name:r,value:String((null===(a=E.cookie)||void 0===a?void 0:a[r])||s)});return e}),[]).concat(O),A=e.parameters.filter((e=>"query"===e.in)).filter((e=>!(a&&!e.required))).map((e=>queryString.parse(serializeParameterValue(e,Sampler.sample(e.schema.rawSchema,b,s))))).reduce(((e,t)=>{var a,r,s;for(const[i,n]of Object.entries(t))e.push({name:i,value:isArrayOfObjects(null===(a=E.query)||void 0===a?void 0:a[i])&&JSON.stringify(deleteEmptyArrayItem(null===(r=E.query)||void 0===r?void 0:r[i]))||String((null===(s=E.query)||void 0===s?void 0:s[i])||n)});return e}),[]).concat(v),P=`${null==y?void 0:y.url.replace(/\/$/,"")}/${e.path.replace(/^\//,"")}`,w=e.parameters.filter((e=>"path"===e.in)).reduce(((e,t)=>{var a;const{in:r,name:s}=t;return e[s]=(null===(a=E.path)||void 0===a?void 0:a[s])||n[s]||getParameterValue(r,s),e}),{}),R=null===(m=null==C?void 0:C.examples)||void 0===m?void 0:m[t],D=(null==C?void 0:C.examples)||{},[q]=Object.values(D),M=(null==E?void 0:E.body)||(null==R?void 0:R.value)||(null==q?void 0:q.value)||(null==C?void 0:C.schema)&&Sampler.sample(null==C?void 0:C.schema.rawSchema,b,s),H=null==C?void 0:C.name.toLowerCase();let N="",x=[];switch(normalizeMimeType(H)){case MediaTypes.JSON:N=JSON.stringify(getDataRequest(M,o));break;case MediaTypes.XML:N="object"==typeof M?toXML(getDataRequest(M,o),{indent:" "}):M;break;case MediaTypes.URL_ENCODED:case MediaTypes.MULTIPART:N=queryString.stringify(getDataRequest(M,o)),x=objectToHarParams(getDataRequest(M,o));break;default:N=String(M||"")}const U=N?{mimeType:(null==C?void 0:C.name)||MediaTypes.OCTET_STREAM,text:N,params:x}:void 0,z=e.responses.map((e=>e.code));return{method:e.httpVerb,url:P,httpVersion:"HTTP/1.1",cookies:k,headers:j,queryString:A,postData:U,headersSize:-1,bodySize:-1,securityOAuth2ExtraCalls:S,basicAuth:T,pathParameters:w,serverVariables:l,allResponseCodes:z}}const defaultOptions={withImports:!0,withComments:!1},langToSnippetConfig={curl:{code:"shell",defaultTarget:"curl",defaultOptions:Object.assign(Object.assign({},defaultOptions),{short:!0})},JavaScript:{code:"javascript",defaultTarget:"fetch",defaultOptions:Object.assign(Object.assign({},defaultOptions),{withImports:!1})},"Node.js":{code:"node",defaultTarget:"fetch",defaultOptions:Object.assign({},defaultOptions)},Python:{code:"python",defaultTarget:"requests",defaultOptions:Object.assign({},defaultOptions)},"Java8+Apache":{code:"java8",defaultTarget:"apachehttp",defaultOptions:Object.assign({},defaultOptions)},Java:{code:"java",defaultTarget:"httpclient",defaultOptions:Object.assign({},defaultOptions)},"C#":{code:"csharp",defaultTarget:"httpclient",defaultOptions:Object.assign({},defaultOptions)},"C#+Newtonsoft":{code:"csharpNewtonsoft",defaultTarget:"httpclient",defaultOptions:Object.assign({},defaultOptions)},Go:{code:"go",defaultTarget:"http.DefaultClient",defaultOptions:Object.assign({},defaultOptions)},PHP:{code:"php",defaultTarget:"curl",defaultOptions:Object.assign({},defaultOptions)},Ruby:{code:"ruby",defaultTarget:"net::http",defaultOptions:Object.assign({},defaultOptions)},R:{code:"r",defaultTarget:"httr",defaultOptions:Object.assign({},defaultOptions)}};export function getCodeSample({lang:e,operation:t,exampleName:a,pathParams:r,properties:s,options:i={},environment:n,translate:o}){try{const{skipOptionalParameters:l,withOAuth2Call:u,spec:p,generatedPayloadSamplesMaxDepth:c,store:d}=i,m=mapOperationToHAR(t,{exampleName:a,pathParams:r,properties:s,skipOptionalParameters:l,withOAuth2Call:u,spec:p,generatedPayloadSamplesMaxDepth:c},{environment:n,requestValues:d.requestValues,activeSecuritySchemeIds:d.activeSecuritySchemeIds}),h=new HTTPSnippet(m);return langToSnippetConfig[e]?h.convert(langToSnippetConfig[e].code,langToSnippetConfig[e].defaultTarget,Object.assign(Object.assign({},langToSnippetConfig[e].defaultOptions),i)):o("openapi.unsupportedLanguage","Language is not supported.")}catch(e){return console.error(e),o("openapi.failedToGenerateCodeSample","Failed to generate code sample.")}}function getSecurityData(e,t,a){var r,s,i,n,o;const l={securityHeaders:[],securityCookies:[],securityQueries:[],securityOAuth2ExtraCalls:[],basicAuth:void 0};for(const u of(null==e?void 0:e.schemes)||[]){const e=getSecurityDetails(u.id,a);switch(u.type){case"openIdConnect":null===(r=l.securityHeaders)||void 0===r||r.push({name:"Authorization",value:e.token?`${e.token.token_type||"Bearer"} ${e.token.access_token}`:"Bearer <YOUR_TOKEN_HERE>"});break;case"oauth2":{const a=e.token?`${e.token.token_type||"Bearer"} ${e.token.access_token}`:"Bearer <YOUR_TOKEN_HERE>";u.flows.clientCredentials&&t?l.securityOAuth2ExtraCalls.push(getOAuth2ClientCredsCallHar(u.flows.clientCredentials,u.scopes,e)):u.flows.password&&t&&l.securityOAuth2ExtraCalls.push(getOAuth2PasswordCallHar(u.flows.password,u.scopes,e)),null===(s=l.securityHeaders)||void 0===s||s.push({name:"Authorization",value:a});break}case"apiKey":{const t=e.raw||"YOUR_API_KEY_HERE";"header"===u.in&&(null===(i=l.securityHeaders)||void 0===i||i.push({name:u.name,value:t})),"cookie"===u.in&&l.securityCookies.push({name:u.name,value:t}),"query"===u.in&&l.securityQueries.push({name:u.name,value:t});break}case"http":if("basic"===u.scheme)l.basicAuth={username:e.username||`<${StringUtility.toSnakeCase("Username")}>`,password:e.password||`<${StringUtility.toSnakeCase("Password")}>`};else{const t=(null===(n=e.token)||void 0===n?void 0:n.access_token)||`<YOUR_${u.bearerFormat||"TOKEN"}_HERE>`;null===(o=l.securityHeaders)||void 0===o||o.push({name:"Authorization",value:`${capitalizeFirst(u.scheme||"bearer")} ${t}`})}}}return l}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:[]}}export function getDataRequest(e,t){if(e){if(isObject(e))return Object.keys(e).length>0&&0===Object.keys(t).length?e:merge(e,t,{arrayMerge:arrayMergeStrategy});try{return merge(JSON.parse(e),t,{arrayMerge:arrayMergeStrategy})}catch(e){return!1}}return!1}function objectToHarParams(e,t=""){const a=[];for(const[r,s]of Object.entries(e)){const e=t?`${t}[${r}]`:r;"object"==typeof s&&null!==s?a.push(...objectToHarParams(s,e)):a.push({name:e,value:String(s)})}return a}export function isDefined(e){return void 0!==e}export function capitalizeFirst(e){return e.charAt(0).toUpperCase()+e.slice(1)}
|
|
2
2
|
//# sourceMappingURL=generator.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{LayoutVariant,isUndefined,addTrailingSlash}from"@redocly/theme";import{WindowReferenceOptions}from"../../constants";import{argValueToBoolean,argValueToExpandLevel,argValueToInt,argValueToNumber,getWindowReferenceOptions,normalizePath}from"../../utils";import{normalizeShowExtensions,normalizeScrollYOffset}from"./helpers";import{Languages}from"../code-samples/constants";export function normalizeOptions(e,o){var a,
|
|
1
|
+
import{LayoutVariant,isUndefined,addTrailingSlash}from"@redocly/theme";import{WindowReferenceOptions}from"../../constants";import{argValueToBoolean,argValueToExpandLevel,argValueToInt,argValueToNumber,getWindowReferenceOptions,normalizePath}from"../../utils";import{normalizeShowExtensions,normalizeScrollYOffset}from"./helpers";import{Languages}from"../code-samples/constants";import{MarkdownHeading}from"../../components/common/linkify";export function normalizeOptions(e,o){var n,a,i,s,l,r,t,d,u,m,c;e=Object.assign(Object.assign(Object.assign({},o),e),{markdocOptions:Object.assign(Object.assign({},null==e?void 0:e.markdocOptions),{components:Object.assign(Object.assign(Object.assign({},null===(n=null==o?void 0:o.markdocOptions)||void 0===n?void 0:n.components),null===(a=null==e?void 0:e.markdocOptions)||void 0===a?void 0:a.components),{Heading:MarkdownHeading}),tags:Object.assign(Object.assign({},null===(i=null==o?void 0:o.markdocOptions)||void 0===i?void 0:i.tags),null===(s=null==e?void 0:e.markdocOptions)||void 0===s?void 0:s.tags),nodes:Object.assign(Object.assign(Object.assign({},null===(l=null==o?void 0:o.markdocOptions)||void 0===l?void 0:l.nodes),null===(r=null==e?void 0:e.markdocOptions)||void 0===r?void 0:r.nodes),{heading:(null===(d=null===(t=null==o?void 0:o.markdocOptions)||void 0===t?void 0:t.nodes)||void 0===d?void 0:d.heading)||(null===(u=null==e?void 0:e.markdocOptions)||void 0===u?void 0:u.nodes.heading)})})});const p=Array.isArray(e.ignoreNamedSchemas)?e.ignoreNamedSchemas:null===(m=e.ignoreNamedSchemas)||void 0===m?void 0:m.split(",").map((e=>e.trim()));return{downloadUrls:e.downloadUrls,schemaDefinitionsTagName:e.schemaDefinitionsTagName,corsProxyUrl:e.corsProxyUrl&&addTrailingSlash(e.corsProxyUrl),hideSidebar:argValueToBoolean(e.hideSidebar,!1),jsonSamplesExpandLevel:argValueToExpandLevel(e.jsonSamplesExpandLevel,2),generatedSamplesMaxDepth:argValueToInt(e.generatedSamplesMaxDepth,8),hideDownloadButtons:argValueToBoolean(e.hideDownloadButtons,!1),hideInfoMetadata:argValueToBoolean(e.hideInfoMetadata,!1),hideLoading:argValueToBoolean(e.hideLoading,!1),hideSchemaTitles:argValueToBoolean(e.hideSchemaTitles,!1),maxDisplayedEnumValues:argValueToNumber(e.maxDisplayedEnumValues),mockServer:(null===(c=e.mockServer)||void 0===c?void 0:c.url)?{url:e.mockServer.url,position:e.mockServer.position||"first",description:e.mockServer.description||"Mock server"}:void 0,hideReplay:argValueToBoolean(e.hideReplay,!1),oAuth2RedirectURI:e.oAuth2RedirectURI||null,onlyRequiredInSamples:argValueToBoolean(e.onlyRequiredInSamples,!1),onDeepLinkClick:e.onDeepLinkClick||getWindowReferenceOptions(WindowReferenceOptions.ON_DEEP_LINK_CLICK),requestInterceptor:e.requestInterceptor||getWindowReferenceOptions(WindowReferenceOptions.REQUEST_INTERCEPTOR),routingBasePath:isUndefined(e.disableRouter)?"":e.routingBasePath&&normalizePath(e.routingBasePath)||"",schemasExpansionLevel:argValueToExpandLevel(e.schemasExpansionLevel),feedback:e.feedback||{hide:!1},sortRequiredPropsFirst:argValueToBoolean(e.sortRequiredPropsFirst,!1),scrollYOffset:normalizeScrollYOffset(e.scrollYOffset),showExtensions:normalizeShowExtensions(e.showExtensions),sanitize:argValueToBoolean(e.sanitize,!1),skipBundle:argValueToBoolean(e.skipBundle,!1),ignoreNamedSchemas:new Set(p),markdocOptions:null==e?void 0:e.markdocOptions,codeSamples:e.codeSamples||{languages:Object.values(Languages).map((e=>({lang:e})))},layout:e.layout||LayoutVariant.THREE_PANEL,events:e.events||{},unstable_hooks:e.unstable_hooks||getWindowReferenceOptions(WindowReferenceOptions.HOOKS)||{},unstable_skipSamples:argValueToBoolean(e.unstable_skipSamples,!1),unstable_externalCodeSamples:e.unstable_externalCodeSamples||[],hidePropertiesPrefix:argValueToBoolean(null==e?void 0:e.hidePropertiesPrefix,!1)}}
|
|
2
2
|
//# sourceMappingURL=normalizeOptions.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/openapi-docs",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.13",
|
|
4
4
|
"description": "Redocly OpenAPI Docs",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib-esm/index.js",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"openapi-docs": "bin.js"
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
|
-
"@redocly/theme": ">=0.
|
|
19
|
+
"@redocly/theme": ">=0.9.4",
|
|
20
20
|
"core-js": "^3.1.4",
|
|
21
21
|
"react": "^18.0.0",
|
|
22
22
|
"react-dom": "^18.0.0",
|
|
@@ -24,13 +24,13 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@markdoc/markdoc": "0.4.0",
|
|
27
|
-
"@redocly/openapi-core": "1.25.
|
|
27
|
+
"@redocly/openapi-core": "1.25.10",
|
|
28
28
|
"deepmerge": "^4.2.2",
|
|
29
29
|
"dompurify": "2.5.4",
|
|
30
30
|
"fast-deep-equal": "^3.1.3",
|
|
31
31
|
"jotai": "^2.4.2",
|
|
32
32
|
"json-pointer": "^0.6.2",
|
|
33
|
-
"
|
|
33
|
+
"jstoxml": "^5.0.2",
|
|
34
34
|
"openapi-sampler": "^1.5.1",
|
|
35
35
|
"path-browserify": "^1.0.1",
|
|
36
36
|
"prismjs": "1.29.0",
|
|
@@ -41,12 +41,11 @@
|
|
|
41
41
|
"styled-components": "^4.1.1 || ^5.3.11",
|
|
42
42
|
"swagger2openapi": "^7.0.8",
|
|
43
43
|
"tslib": "^2.2.0",
|
|
44
|
-
"jstoxml": "^5.0.2",
|
|
45
44
|
"url": "~0.11.0",
|
|
46
45
|
"url-template": "^2.0.8",
|
|
47
46
|
"util": "~0.12.5",
|
|
48
|
-
"@redocly/
|
|
49
|
-
"@redocly/
|
|
47
|
+
"@redocly/config": "0.16.0",
|
|
48
|
+
"@redocly/replay": "0.7.8"
|
|
50
49
|
},
|
|
51
50
|
"devDependencies": {
|
|
52
51
|
"@testing-library/jest-dom": "6.1.5",
|
|
@@ -94,7 +93,7 @@
|
|
|
94
93
|
"webpack": "5.94.0",
|
|
95
94
|
"webpack-cli": "5.1.4",
|
|
96
95
|
"webpack-dev-server": "5.1.0",
|
|
97
|
-
"@redocly/theme": "0.45.
|
|
96
|
+
"@redocly/theme": "0.45.1"
|
|
98
97
|
},
|
|
99
98
|
"scripts": {
|
|
100
99
|
"start": "webpack serve --mode=development --hot",
|