@redocly/openapi-docs 3.7.0-next.4 → 3.7.0-next.5
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 +1157 -1082
- package/lib/components/Replay/Replay.js +1 -1
- package/lib/services/OpenAPIParser.d.ts +1 -1
- package/lib/services/OpenAPIParser.js +1 -1
- package/lib-esm/components/Replay/Replay.js +1 -1
- package/lib-esm/services/OpenAPIParser.d.ts +1 -1
- package/lib-esm/services/OpenAPIParser.js +1 -1
- package/package.json +4 -4
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,n)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]}),__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 r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&__createBinding(t,e,r);return __setModuleDefault(t,e),t},__awaiter=this&&this.__awaiter||function(e,t,r,o){return new(r||(r=Promise))((function(n,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function s(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}u((o=o.apply(e,t||[])).next())}))},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.Replay=void 0;const jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),theme_1=require("@redocly/theme"),jotai_1=require("jotai"),deepmerge_1=__importDefault(require("deepmerge")),ReplayOverlay=(0,react_1.lazy)((()=>__awaiter(void 0,void 0,void 0,(function*(){return Promise.resolve().then((()=>__importStar(require("@redocly/replay")))).then((e=>({default:e.ReplayOverlay})))})))),store_1=require("../../jotai/store"),replay_1=require("../../jotai/replay"),operation_1=require("../../jotai/operation"),constants_1=require("../../constants"),app_1=require("../../jotai/app"),utils_1=require("./utils"),hooks_1=require("../../hooks"),utils_2=require("../../utils");function ReplayComponent({operation:e,corsProxyUrl:t,fullOpenApi:r}){var o,n;const i=(0,hooks_1.useTranslate)(),a=(0,react_1.useRef)(null),{mockServer:s,oAuth2RedirectURI:u,routingBasePath:l}=(0,jotai_1.useAtomValue)(store_1.globalOptionsAtom),_=(0,jotai_1.useAtomValue)(replay_1.allOperationsAtom),{parser:c}=(0,jotai_1.useAtomValue)(store_1.globalStoreAtom),[p,d]=(0,react_1.useState)(!1),[m,f]=(0,jotai_1.useAtom)(replay_1.replayStateAtom),[h,j]=(0,jotai_1.useAtom)(operation_1.allOperations),[[,y],v]=(0,jotai_1.useAtom)(app_1.environmentAtom);(0,theme_1.useFocusTrap)(a),(0,theme_1.useModalScrollLock)(p);const O=(0,react_1.useCallback)((({operations:e,environment:t,environments:r})=>{const o=e.reduce(((e,t)=>{t.requestValues.body=t.requestValues.body instanceof URLSearchParams?Object.fromEntries(t.requestValues.body.entries()):t.requestValues.body;const{path:r,method:o}=t.sourcePath,n=utils_2.JsonPointer.compile(["paths",r,o]);return e[n]=(0,deepmerge_1.default)((0,operation_1.getDefaultOperationStore)(n),t),e}),{});j(Object.assign(Object.assign({},h),o)),v({environment:t,environments:r})}),[h,j,v]),A=()=>{m!==constants_1.LOADING_STATE.LOADING&&d(!p),m===constants_1.LOADING_STATE.NOT_LOADED&&f(constants_1.LOADING_STATE.LOADING)},x=(0,react_1.useCallback)((e=>{if(!e)return;const t=_.find((t=>t.operationId===e));return l+(null==t?void 0:t.href)}),[_,l]);return r?(0,jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment,{children:[(0,jsx_runtime_1.jsx)(theme_1.Button,{onClick:A,variant:"primary",iconPosition:"left",icon:m===constants_1.LOADING_STATE.LOADING?(0,jsx_runtime_1.jsx)(theme_1.CircleDashIcon,{}):(0,jsx_runtime_1.jsx)(theme_1.RocketIcon,{}),children:m===constants_1.LOADING_STATE.LOADING?i("openapi.loading","Loading..."):i("openapi.tryIt","Try it")}),p&&(0,jsx_runtime_1.jsx)(react_1.Suspense,{children:(0,jsx_runtime_1.jsx)(theme_1.Portal,{mountId:"api-content",children:(0,jsx_runtime_1.jsx)("div",{ref:a,children:(0,jsx_runtime_1.jsx)(ReplayOverlay,{activeOperationId:e.operationId||e.pointer,source:{data:r,type:"openapi"},onRequestChange:O,onClose:A,onLoad:()=>f(constants_1.LOADING_STATE.LOADED),settings:{corsProxyUrl:t,mockServer:s,environment:y,apiId:null===(n=null===(o=null==c?void 0:c.definition.info)||void 0===o?void 0:o["x-metadata"])||void 0===n?void 0:n.apiId,oAuth2RedirectURI:u,disableCollectionsTab:!0,storageKey:l,convertOperationToReplayValue:utils_1.convertOperationToReplayValueForRedoc,getOperationUrl:x}})})})})]}):null}exports.Replay=(0,react_1.memo)(ReplayComponent);
|
|
1
|
+
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,n)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]}),__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 r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&__createBinding(t,e,r);return __setModuleDefault(t,e),t},__awaiter=this&&this.__awaiter||function(e,t,r,o){return new(r||(r=Promise))((function(n,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function s(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}u((o=o.apply(e,t||[])).next())}))},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.Replay=void 0;const jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),theme_1=require("@redocly/theme"),jotai_1=require("jotai"),deepmerge_1=__importDefault(require("deepmerge")),ReplayOverlay=(0,react_1.lazy)((()=>__awaiter(void 0,void 0,void 0,(function*(){return Promise.resolve().then((()=>__importStar(require("@redocly/replay")))).then((e=>({default:e.ReplayOverlay})))})))),store_1=require("../../jotai/store"),replay_1=require("../../jotai/replay"),operation_1=require("../../jotai/operation"),constants_1=require("../../constants"),app_1=require("../../jotai/app"),utils_1=require("./utils"),hooks_1=require("../../hooks"),utils_2=require("../../utils");function ReplayComponent({operation:e,corsProxyUrl:t,fullOpenApi:r}){var o,n;const i=(0,hooks_1.useTranslate)(),a=(0,react_1.useRef)(null),{mockServer:s,oAuth2RedirectURI:u,routingBasePath:l}=(0,jotai_1.useAtomValue)(store_1.globalOptionsAtom),_=(0,jotai_1.useAtomValue)(replay_1.allOperationsAtom),{parser:c}=(0,jotai_1.useAtomValue)(store_1.globalStoreAtom),[p,d]=(0,react_1.useState)(!1),[m,f]=(0,jotai_1.useAtom)(replay_1.replayStateAtom),[h,j]=(0,jotai_1.useAtom)(operation_1.allOperations),[[,y],v]=(0,jotai_1.useAtom)(app_1.environmentAtom);(0,theme_1.useFocusTrap)(a),(0,theme_1.useModalScrollLock)(p);const O=(0,react_1.useCallback)((({operations:e,environment:t,environments:r})=>{const o=e.reduce(((e,t)=>{t.requestValues.body=t.requestValues.body instanceof URLSearchParams?Object.fromEntries(t.requestValues.body.entries()):t.requestValues.body;const{path:r,method:o}=t.sourcePath,n=utils_2.JsonPointer.compile(["paths",r,o]);return e[n]=(0,deepmerge_1.default)((0,operation_1.getDefaultOperationStore)(n),t),e}),{});j(Object.assign(Object.assign({},h),o)),v({environment:t,environments:r})}),[h,j,v]),A=()=>{m!==constants_1.LOADING_STATE.LOADING&&d(!p),m===constants_1.LOADING_STATE.NOT_LOADED&&f(constants_1.LOADING_STATE.LOADING)},x=(0,react_1.useCallback)((e=>{if(!e)return;const t=_.find((t=>t.operationId===e));return l+(null==t?void 0:t.href)}),[_,l]);return r?(0,jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment,{children:[(0,jsx_runtime_1.jsx)(theme_1.Button,{onClick:A,variant:"primary",iconPosition:"left",icon:m===constants_1.LOADING_STATE.LOADING?(0,jsx_runtime_1.jsx)(theme_1.CircleDashIcon,{}):(0,jsx_runtime_1.jsx)(theme_1.RocketIcon,{}),children:m===constants_1.LOADING_STATE.LOADING?i("openapi.loading","Loading..."):i("openapi.tryIt","Try it")}),p&&(0,jsx_runtime_1.jsx)(react_1.Suspense,{children:(0,jsx_runtime_1.jsx)(theme_1.Portal,{mountId:"api-content",children:(0,jsx_runtime_1.jsx)("div",{ref:a,children:(0,jsx_runtime_1.jsx)(ReplayOverlay,{activeOperationId:e.operationId||e.pointer,source:{data:r,type:"openapi"},onRequestChange:O,onClose:A,onLoad:()=>f(constants_1.LOADING_STATE.LOADED),settings:{corsProxyUrl:t,mockServer:s,environment:y,apiId:null===(n=null===(o=null==c?void 0:c.definition.info)||void 0===o?void 0:o["x-metadata"])||void 0===n?void 0:n.apiId,oAuth2RedirectURI:u,disableCollectionsTab:!0,disableWorkflowTab:!0,storageKey:l,convertOperationToReplayValue:utils_1.convertOperationToReplayValueForRedoc,getOperationUrl:x}})})})})]}):null}exports.Replay=(0,react_1.memo)(ReplayComponent);
|
|
2
2
|
//# sourceMappingURL=Replay.js.map
|
|
@@ -29,7 +29,7 @@ export declare class OpenAPIParser {
|
|
|
29
29
|
* @param baseRefsStack
|
|
30
30
|
* @param mergeAsAllOf
|
|
31
31
|
*/
|
|
32
|
-
deref<T>(obj: OpenAPIRef | T, baseRefsStack?: string[], mergeAsAllOf?: boolean): {
|
|
32
|
+
deref<T>(obj: OpenAPIRef | T, baseRefsStack?: string[], mergeAsAllOf?: boolean, level?: number): {
|
|
33
33
|
resolved: T;
|
|
34
34
|
refsStack: string[];
|
|
35
35
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var __rest=this&&this.__rest||function(e,t){var r={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(r[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(i=Object.getOwnPropertySymbols(e);n<i.length;n++)t.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(e,i[n])&&(r[i[n]]=e[i[n]])}return r};Object.defineProperty(exports,"__esModule",{value:!0}),exports.OpenAPIParser=void 0,exports.pushRef=pushRef,exports.concatRefStacks=concatRefStacks;const theme_1=require("@redocly/theme"),utils_1=require("../utils"),JsonPointer_1=require("../utils/JsonPointer"),normalizeOptions_1=require("./config-options/normalizeOptions");function pushRef(e,t){return t&&e[e.length-1]!==t?[...e,t]:e}function concatRefStacks(e,t){return t?e.concat(t):e}class OpenAPIParser{constructor(e,t,r=(0,normalizeOptions_1.normalizeOptions)({})){Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"definitionUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"definition",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"allowMergeRefs",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"byRef",{enumerable:!0,configurable:!0,writable:!0,value:e=>{let t;if(this.definition){"#"!==e.charAt(0)&&(e="#"+e),e=(0,utils_1.tryDecodeURIComponent)(e);try{t=JsonPointer_1.JsonPointer.get(this.definition,e)}catch(e){}return t||{}}}}),this.definition=Object.assign({},e),this.validate(e),this.definition=e,this.allowMergeRefs=e.openapi.startsWith("3.1");const i=theme_1.IS_BROWSER?window.location.href:"";(0,theme_1.isString)(t)&&(this.definitionUrl=new URL(t,i).href)}validate(e){if((0,theme_1.isUndefined)(e.openapi))throw new Error("Document must be valid OpenAPI 3.0.0 definition")}isRef(e){return!!e&&(void 0!==e.$ref&&null!==e.$ref)}deref(e,t=[],r=!1){const
|
|
1
|
+
"use strict";var __rest=this&&this.__rest||function(e,t){var r={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(r[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(i=Object.getOwnPropertySymbols(e);n<i.length;n++)t.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(e,i[n])&&(r[i[n]]=e[i[n]])}return r};Object.defineProperty(exports,"__esModule",{value:!0}),exports.OpenAPIParser=void 0,exports.pushRef=pushRef,exports.concatRefStacks=concatRefStacks;const theme_1=require("@redocly/theme"),utils_1=require("../utils"),JsonPointer_1=require("../utils/JsonPointer"),normalizeOptions_1=require("./config-options/normalizeOptions");function pushRef(e,t){return t&&e[e.length-1]!==t?[...e,t]:e}function concatRefStacks(e,t){return t?e.concat(t):e}class OpenAPIParser{constructor(e,t,r=(0,normalizeOptions_1.normalizeOptions)({})){Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"definitionUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"definition",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"allowMergeRefs",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"byRef",{enumerable:!0,configurable:!0,writable:!0,value:e=>{let t;if(this.definition){"#"!==e.charAt(0)&&(e="#"+e),e=(0,utils_1.tryDecodeURIComponent)(e);try{t=JsonPointer_1.JsonPointer.get(this.definition,e)}catch(e){}return t||{}}}}),this.definition=Object.assign({},e),this.validate(e),this.definition=e,this.allowMergeRefs=e.openapi.startsWith("3.1");const i=theme_1.IS_BROWSER?window.location.href:"";(0,theme_1.isString)(t)&&(this.definitionUrl=new URL(t,i).href)}validate(e){if((0,theme_1.isUndefined)(e.openapi))throw new Error("Document must be valid OpenAPI 3.0.0 definition")}isRef(e){return!!e&&(void 0!==e.$ref&&null!==e.$ref)}deref(e,t=[],r=!1,i=0){const n=null==e?void 0:e["x-refsStack"];if(t=concatRefStacks(t,n),i>5)return{resolved:Object.assign({},e,{"x-complex":!0}),refsStack:t};if(this.isRef(e)){const n=(0,utils_1.getDefinitionName)(e.$ref);if(n&&this.options.ignoreNamedSchemas.has(n))return{resolved:{type:"object",title:n},refsStack:t};let s=this.byRef(e.$ref);if(!s)throw new Error(`Failed to resolve $ref "${e.$ref}"`);if(t.includes(e.$ref))s=Object.assign({},s,{"x-circular-ref":!0});else if(this.isRef(s)){s=this.deref(s,t,r,i).resolved}return this.allowMergeRefs&&(s=this.mergeRefs(e,s,r)),{resolved:s,refsStack:pushRef(t,e.$ref)}}return{resolved:e,refsStack:concatRefStacks(t,n)}}mergeRefs(e,t,r){const{$ref:i}=e,n=__rest(e,["$ref"]),s=Object.keys(n);if(0===s.length)return t;if(r&&s.some((e=>!["description","title","externalDocs","x-refsStack","x-parentRefs","readOnly","writeOnly","x-complex"].includes(e)))){const e=n,{description:r,title:i,readOnly:s,writeOnly:o}=e;return{allOf:[{description:r,title:i,readOnly:s,writeOnly:o},t,__rest(e,["description","title","readOnly","writeOnly"])]}}return Object.assign(Object.assign({},t),n)}mergeAllOf(e,t,r,i="",n=0){var s;if(e["x-circular-ref"])return e;if(void 0===(e=this.hoistOneOfs(e)).allOf)return Object.assign({absolutePointer:i},e);let o=Object.assign(Object.assign({},e),{"x-parentRefs":[],absolutePointer:JsonPointer_1.JsonPointer.join(i,["allOf"]),allOf:void 0,title:e.title||(0,utils_1.getDefinitionName)(t)});!(0,theme_1.isUndefined)(o.properties)&&(0,theme_1.isObject)(o.properties)&&(o.properties=Object.assign({},o.properties)),!(0,theme_1.isUndefined)(o.items)&&(0,theme_1.isObject)(o.items)&&(o.items=Object.assign({},o.items));const l=e.allOf.map(((e,t)=>{var s;const{resolved:l,refsStack:f}=this.deref(e,r,!0,n),a=e.$ref,c=a||JsonPointer_1.JsonPointer.join(i,[String(t)]);if(l["x-complex"])return{$ref:a,refsStack:pushRef(f,a),schema:{"x-complex":!0},absolutePointer:c};const p=this.mergeAllOf(l,a,f,c,n+1);return p["x-circular-ref"]&&p.allOf?void 0:(a&&(null===(s=o["x-parentRefs"])||void 0===s||s.push(...p["x-parentRefs"]||[],a)),{$ref:a,refsStack:pushRef(f,a),schema:p,absolutePointer:c})})).filter(Boolean);for(const[e,{schema:r,refsStack:i,absolutePointer:f}]of l.entries()){const l=r||{},{type:a,enum:c,properties:p,items:d,required:O,title:u,description:m,readOnly:h,writeOnly:y,oneOf:b,anyOf:_,"x-circular-ref":g,"x-complex":x}=l,j=__rest(l,["type","enum","properties","items","required","title","description","readOnly","writeOnly","oneOf","anyOf","x-circular-ref","x-complex"]);if(o.type===a||(0,theme_1.isUndefined)(o.type)||(0,theme_1.isUndefined)(a)||n){if((0,theme_1.isUndefined)(a)||(Array.isArray(a)&&Array.isArray(o.type)?o.type=[...a,...o.type]:o.type=a),(0,theme_1.isUndefined)(c)||(Array.isArray(c)&&Array.isArray(o.enum)?o.enum=Array.from(new Set([...c,...o.enum])):o.enum=c),!(0,theme_1.isUndefined)(p)&&(0,theme_1.isObject)(p)){o.properties=o.properties||{};for(const r in p){const l=concatRefStacks(i,null===(s=p[r])||void 0===s?void 0:s["x-refsStack"]);if(o.properties[r]){if(!g){const i=this.mergeAllOf({allOf:[o.properties[r],p[r]],"x-refsStack":l},t+"/properties/"+r,l,JsonPointer_1.JsonPointer.join(f,["allOf",String(e),"properties",r]),n+1);o.properties[r]=i}}else o.properties[r]=Object.assign(Object.assign({},p[r]),{absolutePointer:JsonPointer_1.JsonPointer.join(f,["properties",r]),"x-refsStack":l})}}if(!(0,theme_1.isUndefined)(d)&&!g&&!x){const e="boolean"==typeof o.items?{}:Object.assign({},o.items),s="boolean"==typeof r.items?{}:Object.assign({},r.items);o.items=this.mergeAllOf({allOf:[e,s]},t+"/items",i,"",n+1)}(0,theme_1.isUndefined)(b)||(o.oneOf=b),(0,theme_1.isUndefined)(_)||(o.anyOf=_),Array.isArray(O)&&(o.required=[...o.required||[],...O]),o=Object.assign(Object.assign(Object.assign({},o),{title:o.title||u,description:o.description||m,readOnly:(0,theme_1.isUndefined)(o.readOnly)?h:o.readOnly,writeOnly:(0,theme_1.isUndefined)(o.writeOnly)?y:o.writeOnly,"x-circular-ref":o["x-circular-ref"]||g,"x-complex":o["x-complex"]||x}),j)}}return o}findDerived(e){const t={},r=this.definition.components&&this.definition.components.schemas||{};for(const i in r){const{resolved:n}=this.deref(r[i]);!(0,theme_1.isUndefined)(n.allOf)&&n.allOf.find((t=>!(0,theme_1.isUndefined)(t.$ref)&&e.indexOf(t.$ref)>-1))&&(t["#/components/schemas/"+i]=[n["x-discriminator-value"]||i])}return t}hoistOneOfs(e){if((0,theme_1.isUndefined)(e.allOf))return e;const{allOf:t}=e,r=__rest(e,["allOf"]);for(let e=0;e<t.length;e++){const i=t[e],{oneOf:n}=i,s=__rest(i,["oneOf"]);if(n&&Array.isArray(n)){const i=t.slice(0,e),o=t.slice(e+1),l=Object.keys(s).length>0?[s]:[];return Object.assign(Object.assign({},r),{oneOf:n.map((e=>({allOf:[...i,...l,e,...o]})))})}}return e}}exports.OpenAPIParser=OpenAPIParser;
|
|
2
2
|
//# sourceMappingURL=OpenAPIParser.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(e,o,t,r){return new(t||(t=Promise))((function(n,a){function i(e){try{l(r.next(e))}catch(e){a(e)}}function s(e){try{l(r.throw(e))}catch(e){a(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(i,s)}l((r=r.apply(e,o||[])).next())}))};import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";import{lazy,memo,Suspense,useCallback,useRef,useState}from"react";import{Button,CircleDashIcon,Portal,RocketIcon,useFocusTrap,useModalScrollLock}from"@redocly/theme";import{useAtom,useAtomValue}from"jotai";import merge from"deepmerge";const ReplayOverlay=lazy((()=>__awaiter(void 0,void 0,void 0,(function*(){return import("@redocly/replay").then((e=>({default:e.ReplayOverlay})))}))));import{globalOptionsAtom,globalStoreAtom}from"../../jotai/store";import{allOperationsAtom,replayStateAtom}from"../../jotai/replay";import{allOperations,getDefaultOperationStore}from"../../jotai/operation";import{LOADING_STATE}from"../../constants";import{environmentAtom}from"../../jotai/app";import{convertOperationToReplayValueForRedoc}from"./utils";import{useTranslate}from"../../hooks";import{JsonPointer}from"../../utils";function ReplayComponent({operation:e,corsProxyUrl:o,fullOpenApi:t}){var r,n;const a=useTranslate(),i=useRef(null),{mockServer:s,oAuth2RedirectURI:l,routingBasePath:u}=useAtomValue(globalOptionsAtom),m=useAtomValue(allOperationsAtom),{parser:p}=useAtomValue(globalStoreAtom),[c,d]=useState(!1),[A,f]=useAtom(replayStateAtom),[y,O]=useAtom(allOperations),[[,v],h]=useAtom(environmentAtom);useFocusTrap(i),useModalScrollLock(c);const _=useCallback((({operations:e,environment:o,environments:t})=>{const r=e.reduce(((e,o)=>{o.requestValues.body=o.requestValues.body instanceof URLSearchParams?Object.fromEntries(o.requestValues.body.entries()):o.requestValues.body;const{path:t,method:r}=o.sourcePath,n=JsonPointer.compile(["paths",t,r]);return e[n]=merge(getDefaultOperationStore(n),o),e}),{});O(Object.assign(Object.assign({},y),r)),h({environment:o,environments:t})}),[y,O,h]),
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(e,o,t,r){return new(t||(t=Promise))((function(n,a){function i(e){try{l(r.next(e))}catch(e){a(e)}}function s(e){try{l(r.throw(e))}catch(e){a(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(i,s)}l((r=r.apply(e,o||[])).next())}))};import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";import{lazy,memo,Suspense,useCallback,useRef,useState}from"react";import{Button,CircleDashIcon,Portal,RocketIcon,useFocusTrap,useModalScrollLock}from"@redocly/theme";import{useAtom,useAtomValue}from"jotai";import merge from"deepmerge";const ReplayOverlay=lazy((()=>__awaiter(void 0,void 0,void 0,(function*(){return import("@redocly/replay").then((e=>({default:e.ReplayOverlay})))}))));import{globalOptionsAtom,globalStoreAtom}from"../../jotai/store";import{allOperationsAtom,replayStateAtom}from"../../jotai/replay";import{allOperations,getDefaultOperationStore}from"../../jotai/operation";import{LOADING_STATE}from"../../constants";import{environmentAtom}from"../../jotai/app";import{convertOperationToReplayValueForRedoc}from"./utils";import{useTranslate}from"../../hooks";import{JsonPointer}from"../../utils";function ReplayComponent({operation:e,corsProxyUrl:o,fullOpenApi:t}){var r,n;const a=useTranslate(),i=useRef(null),{mockServer:s,oAuth2RedirectURI:l,routingBasePath:u}=useAtomValue(globalOptionsAtom),m=useAtomValue(allOperationsAtom),{parser:p}=useAtomValue(globalStoreAtom),[c,d]=useState(!1),[A,f]=useAtom(replayStateAtom),[y,O]=useAtom(allOperations),[[,v],h]=useAtom(environmentAtom);useFocusTrap(i),useModalScrollLock(c);const _=useCallback((({operations:e,environment:o,environments:t})=>{const r=e.reduce(((e,o)=>{o.requestValues.body=o.requestValues.body instanceof URLSearchParams?Object.fromEntries(o.requestValues.body.entries()):o.requestValues.body;const{path:t,method:r}=o.sourcePath,n=JsonPointer.compile(["paths",t,r]);return e[n]=merge(getDefaultOperationStore(n),o),e}),{});O(Object.assign(Object.assign({},y),r)),h({environment:o,environments:t})}),[y,O,h]),T=()=>{A!==LOADING_STATE.LOADING&&d(!c),A===LOADING_STATE.NOT_LOADED&&f(LOADING_STATE.LOADING)},I=useCallback((e=>{if(!e)return;const o=m.find((o=>o.operationId===e));return u+(null==o?void 0:o.href)}),[m,u]);return t?_jsxs(_Fragment,{children:[_jsx(Button,{onClick:T,variant:"primary",iconPosition:"left",icon:A===LOADING_STATE.LOADING?_jsx(CircleDashIcon,{}):_jsx(RocketIcon,{}),children:A===LOADING_STATE.LOADING?a("openapi.loading","Loading..."):a("openapi.tryIt","Try it")}),c&&_jsx(Suspense,{children:_jsx(Portal,{mountId:"api-content",children:_jsx("div",{ref:i,children:_jsx(ReplayOverlay,{activeOperationId:e.operationId||e.pointer,source:{data:t,type:"openapi"},onRequestChange:_,onClose:T,onLoad:()=>f(LOADING_STATE.LOADED),settings:{corsProxyUrl:o,mockServer:s,environment:v,apiId:null===(n=null===(r=null==p?void 0:p.definition.info)||void 0===r?void 0:r["x-metadata"])||void 0===n?void 0:n.apiId,oAuth2RedirectURI:l,disableCollectionsTab:!0,disableWorkflowTab:!0,storageKey:u,convertOperationToReplayValue:convertOperationToReplayValueForRedoc,getOperationUrl:I}})})})})]}):null}export const Replay=memo(ReplayComponent);
|
|
2
2
|
//# sourceMappingURL=Replay.js.map
|
|
@@ -29,7 +29,7 @@ export declare class OpenAPIParser {
|
|
|
29
29
|
* @param baseRefsStack
|
|
30
30
|
* @param mergeAsAllOf
|
|
31
31
|
*/
|
|
32
|
-
deref<T>(obj: OpenAPIRef | T, baseRefsStack?: string[], mergeAsAllOf?: boolean): {
|
|
32
|
+
deref<T>(obj: OpenAPIRef | T, baseRefsStack?: string[], mergeAsAllOf?: boolean, level?: number): {
|
|
33
33
|
resolved: T;
|
|
34
34
|
refsStack: string[];
|
|
35
35
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var __rest=this&&this.__rest||function(e,t){var i={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(i[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(e);n<r.length;n++)t.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(e,r[n])&&(i[r[n]]=e[r[n]])}return i};import{IS_BROWSER,isObject,isString,isUndefined}from"@redocly/theme";import{tryDecodeURIComponent,getDefinitionName}from"../utils";import{JsonPointer}from"../utils/JsonPointer";import{normalizeOptions}from"./config-options/normalizeOptions";export function pushRef(e,t){return t&&e[e.length-1]!==t?[...e,t]:e}export function concatRefStacks(e,t){return t?e.concat(t):e}export class OpenAPIParser{constructor(e,t,i=normalizeOptions({})){Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"definitionUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"definition",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"allowMergeRefs",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"byRef",{enumerable:!0,configurable:!0,writable:!0,value:e=>{let t;if(this.definition){"#"!==e.charAt(0)&&(e="#"+e),e=tryDecodeURIComponent(e);try{t=JsonPointer.get(this.definition,e)}catch(e){}return t||{}}}}),this.definition=Object.assign({},e),this.validate(e),this.definition=e,this.allowMergeRefs=e.openapi.startsWith("3.1");const r=IS_BROWSER?window.location.href:"";isString(t)&&(this.definitionUrl=new URL(t,r).href)}validate(e){if(isUndefined(e.openapi))throw new Error("Document must be valid OpenAPI 3.0.0 definition")}isRef(e){return!!e&&(void 0!==e.$ref&&null!==e.$ref)}deref(e,t=[],i=!1){const
|
|
1
|
+
var __rest=this&&this.__rest||function(e,t){var i={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(i[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(e);n<r.length;n++)t.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(e,r[n])&&(i[r[n]]=e[r[n]])}return i};import{IS_BROWSER,isObject,isString,isUndefined}from"@redocly/theme";import{tryDecodeURIComponent,getDefinitionName}from"../utils";import{JsonPointer}from"../utils/JsonPointer";import{normalizeOptions}from"./config-options/normalizeOptions";export function pushRef(e,t){return t&&e[e.length-1]!==t?[...e,t]:e}export function concatRefStacks(e,t){return t?e.concat(t):e}export class OpenAPIParser{constructor(e,t,i=normalizeOptions({})){Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"definitionUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"definition",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"allowMergeRefs",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"byRef",{enumerable:!0,configurable:!0,writable:!0,value:e=>{let t;if(this.definition){"#"!==e.charAt(0)&&(e="#"+e),e=tryDecodeURIComponent(e);try{t=JsonPointer.get(this.definition,e)}catch(e){}return t||{}}}}),this.definition=Object.assign({},e),this.validate(e),this.definition=e,this.allowMergeRefs=e.openapi.startsWith("3.1");const r=IS_BROWSER?window.location.href:"";isString(t)&&(this.definitionUrl=new URL(t,r).href)}validate(e){if(isUndefined(e.openapi))throw new Error("Document must be valid OpenAPI 3.0.0 definition")}isRef(e){return!!e&&(void 0!==e.$ref&&null!==e.$ref)}deref(e,t=[],i=!1,r=0){const n=null==e?void 0:e["x-refsStack"];if(t=concatRefStacks(t,n),r>5)return{resolved:Object.assign({},e,{"x-complex":!0}),refsStack:t};if(this.isRef(e)){const n=getDefinitionName(e.$ref);if(n&&this.options.ignoreNamedSchemas.has(n))return{resolved:{type:"object",title:n},refsStack:t};let s=this.byRef(e.$ref);if(!s)throw new Error(`Failed to resolve $ref "${e.$ref}"`);if(t.includes(e.$ref))s=Object.assign({},s,{"x-circular-ref":!0});else if(this.isRef(s)){s=this.deref(s,t,i,r).resolved}return this.allowMergeRefs&&(s=this.mergeRefs(e,s,i)),{resolved:s,refsStack:pushRef(t,e.$ref)}}return{resolved:e,refsStack:concatRefStacks(t,n)}}mergeRefs(e,t,i){const{$ref:r}=e,n=__rest(e,["$ref"]),s=Object.keys(n);if(0===s.length)return t;if(i&&s.some((e=>!["description","title","externalDocs","x-refsStack","x-parentRefs","readOnly","writeOnly","x-complex"].includes(e)))){const e=n,{description:i,title:r,readOnly:s,writeOnly:o}=e;return{allOf:[{description:i,title:r,readOnly:s,writeOnly:o},t,__rest(e,["description","title","readOnly","writeOnly"])]}}return Object.assign(Object.assign({},t),n)}mergeAllOf(e,t,i,r="",n=0){var s;if(e["x-circular-ref"])return e;if(void 0===(e=this.hoistOneOfs(e)).allOf)return Object.assign({absolutePointer:r},e);let o=Object.assign(Object.assign({},e),{"x-parentRefs":[],absolutePointer:JsonPointer.join(r,["allOf"]),allOf:void 0,title:e.title||getDefinitionName(t)});!isUndefined(o.properties)&&isObject(o.properties)&&(o.properties=Object.assign({},o.properties)),!isUndefined(o.items)&&isObject(o.items)&&(o.items=Object.assign({},o.items));const f=e.allOf.map(((e,t)=>{var s;const{resolved:f,refsStack:l}=this.deref(e,i,!0,n),a=e.$ref,c=a||JsonPointer.join(r,[String(t)]);if(f["x-complex"])return{$ref:a,refsStack:pushRef(l,a),schema:{"x-complex":!0},absolutePointer:c};const d=this.mergeAllOf(f,a,l,c,n+1);return d["x-circular-ref"]&&d.allOf?void 0:(a&&(null===(s=o["x-parentRefs"])||void 0===s||s.push(...d["x-parentRefs"]||[],a)),{$ref:a,refsStack:pushRef(l,a),schema:d,absolutePointer:c})})).filter(Boolean);for(const[e,{schema:i,refsStack:r,absolutePointer:l}]of f.entries()){const f=i||{},{type:a,enum:c,properties:d,items:p,required:O,title:u,description:m,readOnly:y,writeOnly:b,oneOf:h,anyOf:g,"x-circular-ref":x,"x-complex":j}=f,v=__rest(f,["type","enum","properties","items","required","title","description","readOnly","writeOnly","oneOf","anyOf","x-circular-ref","x-complex"]);if(o.type===a||isUndefined(o.type)||isUndefined(a)||n){if(isUndefined(a)||(Array.isArray(a)&&Array.isArray(o.type)?o.type=[...a,...o.type]:o.type=a),isUndefined(c)||(Array.isArray(c)&&Array.isArray(o.enum)?o.enum=Array.from(new Set([...c,...o.enum])):o.enum=c),!isUndefined(d)&&isObject(d)){o.properties=o.properties||{};for(const i in d){const f=concatRefStacks(r,null===(s=d[i])||void 0===s?void 0:s["x-refsStack"]);if(o.properties[i]){if(!x){const r=this.mergeAllOf({allOf:[o.properties[i],d[i]],"x-refsStack":f},t+"/properties/"+i,f,JsonPointer.join(l,["allOf",String(e),"properties",i]),n+1);o.properties[i]=r}}else o.properties[i]=Object.assign(Object.assign({},d[i]),{absolutePointer:JsonPointer.join(l,["properties",i]),"x-refsStack":f})}}if(!isUndefined(p)&&!x&&!j){const e="boolean"==typeof o.items?{}:Object.assign({},o.items),s="boolean"==typeof i.items?{}:Object.assign({},i.items);o.items=this.mergeAllOf({allOf:[e,s]},t+"/items",r,"",n+1)}isUndefined(h)||(o.oneOf=h),isUndefined(g)||(o.anyOf=g),Array.isArray(O)&&(o.required=[...o.required||[],...O]),o=Object.assign(Object.assign(Object.assign({},o),{title:o.title||u,description:o.description||m,readOnly:isUndefined(o.readOnly)?y:o.readOnly,writeOnly:isUndefined(o.writeOnly)?b:o.writeOnly,"x-circular-ref":o["x-circular-ref"]||x,"x-complex":o["x-complex"]||j}),v)}}return o}findDerived(e){const t={},i=this.definition.components&&this.definition.components.schemas||{};for(const r in i){const{resolved:n}=this.deref(i[r]);!isUndefined(n.allOf)&&n.allOf.find((t=>!isUndefined(t.$ref)&&e.indexOf(t.$ref)>-1))&&(t["#/components/schemas/"+r]=[n["x-discriminator-value"]||r])}return t}hoistOneOfs(e){if(isUndefined(e.allOf))return e;const{allOf:t}=e,i=__rest(e,["allOf"]);for(let e=0;e<t.length;e++){const r=t[e],{oneOf:n}=r,s=__rest(r,["oneOf"]);if(n&&Array.isArray(n)){const r=t.slice(0,e),o=t.slice(e+1),f=Object.keys(s).length>0?[s]:[];return Object.assign(Object.assign({},i),{oneOf:n.map((e=>({allOf:[...r,...f,e,...o]})))})}}return e}}
|
|
2
2
|
//# sourceMappingURL=OpenAPIParser.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/openapi-docs",
|
|
3
|
-
"version": "3.7.0-next.
|
|
3
|
+
"version": "3.7.0-next.5",
|
|
4
4
|
"description": "Redocly OpenAPI Docs",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib-esm/index.js",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@markdoc/markdoc": "0.4.0",
|
|
27
|
-
"@redocly/openapi-core": "1.
|
|
27
|
+
"@redocly/openapi-core": "1.31.1",
|
|
28
28
|
"deepmerge": "^4.2.2",
|
|
29
29
|
"dompurify": "2.5.4",
|
|
30
30
|
"fast-deep-equal": "^3.1.3",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"url-template": "^2.0.8",
|
|
45
45
|
"util": "~0.12.5",
|
|
46
46
|
"@redocly/config": "0.21.0",
|
|
47
|
-
"@redocly/replay": "0.10.0-next.
|
|
47
|
+
"@redocly/replay": "0.10.0-next.3"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@shikijs/transformers": "1.24.0",
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"webpack": "5.94.0",
|
|
96
96
|
"webpack-cli": "5.1.4",
|
|
97
97
|
"webpack-dev-server": "5.1.0",
|
|
98
|
-
"@redocly/theme": "0.51.0-next.
|
|
98
|
+
"@redocly/theme": "0.51.0-next.3"
|
|
99
99
|
},
|
|
100
100
|
"scripts": {
|
|
101
101
|
"start": "npm run copy-highlight-hook && webpack serve --mode=development --hot",
|