@redocly/openapi-docs 3.2.10 → 3.2.11

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.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useAutoScroll=void 0;const react_router_dom_1=require("react-router-dom"),react_1=require("react"),theme_1=require("@redocly/theme"),utils_1=require("../../utils");let initialPageLoad=!0;function useAutoScroll(e){const t=(0,react_router_dom_1.useLocation)(),o=(0,theme_1.addTrailingSlash)(e)||"/";(0,react_1.useLayoutEffect)((()=>{if(t.pathname===o&&""===t.hash)window.scrollTo(0,0);else{const e=t.hash.replace("#","").toLowerCase()||(0,utils_1.normalizePath)(t.pathname).replace(o,""),a=document.getElementById(decodeURIComponent(e));a&&a.scrollIntoView()}}),[t,o]);const a=(0,theme_1.useActiveSectionId)(t,!1,!1);(0,react_1.useEffect)((()=>{if(a&&initialPageLoad)initialPageLoad=!1;else if(theme_1.IS_BROWSER&&!window.location.pathname.includes(a)&&!window.location.hash.includes(a)){const e=(0,utils_1.compose)(theme_1.addLeadingSlash,utils_1.encodeBackSlashes)(a);window.history.replaceState({},"",e)}}),[a])}exports.useAutoScroll=useAutoScroll;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useAutoScroll=void 0;const react_router_dom_1=require("react-router-dom"),react_1=require("react"),theme_1=require("@redocly/theme"),utils_1=require("../../utils");let initialPageLoad=!0;function useAutoScroll(e){const t=(0,react_router_dom_1.useLocation)(),o=e||"/";(0,react_1.useLayoutEffect)((()=>{if(t.pathname===o&&""===t.hash)window.scrollTo(0,0);else{const e=t.hash.replace("#","").toLowerCase()||(0,theme_1.removeLeadingSlash)(t.pathname.replace(o,"")),a=document.getElementById(decodeURIComponent(e));a&&a.scrollIntoView()}}),[t,o]);const a=(0,theme_1.useActiveSectionId)(t,!1,!1);(0,react_1.useEffect)((()=>{if(a&&initialPageLoad)initialPageLoad=!1;else if(theme_1.IS_BROWSER&&!window.location.pathname.includes(a)&&!window.location.hash.includes(a)){const e=(0,utils_1.compose)(theme_1.addLeadingSlash,utils_1.encodeBackSlashes)(a);window.history.replaceState({},"",e)}}),[a])}exports.useAutoScroll=useAutoScroll;
2
2
  //# sourceMappingURL=useAutoScroll.js.map
@@ -26,7 +26,7 @@ export declare class OpenAPIParser {
26
26
  /**
27
27
  * Resolve given reference object or return as is if it is not a reference
28
28
  * @param obj object to dereference
29
- * @param forceCircular whether to dereference even if it is circular ref
29
+ * @param baseRefsStack
30
30
  * @param mergeAsAllOf
31
31
  */
32
32
  deref<T>(obj: OpenAPIRef | T, baseRefsStack?: string[], mergeAsAllOf?: boolean): {
@@ -38,8 +38,8 @@ export declare class OpenAPIParser {
38
38
  * Merge allOf constraints.
39
39
  * @param schema schema with allOF
40
40
  * @param $ref pointer of the schema
41
- * @param forceCircular whether to dereference children even if it is a circular ref
42
- * @param used$Refs
41
+ * @param refsStack
42
+ * @param absolutePointer
43
43
  */
44
44
  mergeAllOf(schema: MergedOpenAPISchema, $ref: string | undefined, refsStack: string[], absolutePointer?: string): MergedOpenAPISchema;
45
45
  /**
@@ -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=exports.concatRefStacks=exports.pushRef=void 0;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}exports.pushRef=pushRef,exports.concatRefStacks=concatRefStacks;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=decodeURIComponent(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:"";"string"==typeof t&&(this.definitionUrl=new URL(t,i).href)}validate(e){if(void 0===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 i=null==e?void 0:e["x-refsStack"];if(t=concatRefStacks(t,i),this.isRef(e)){const i=(0,utils_1.getDefinitionName)(e.$ref);if(i&&this.options.ignoreNamedSchemas.has(i))return{resolved:{type:"object",title:i},refsStack:t};let n=this.byRef(e.$ref);if(!n)throw new Error(`Failed to resolve $ref "${e.$ref}"`);let s=t;if(t.includes(e.$ref))n=Object.assign({},n,{"x-circular-ref":!0});else if(this.isRef(n)){const e=this.deref(n,t,r);s=e.refsStack,n=e.resolved}return s=pushRef(t,e.$ref),n=this.allowMergeRefs?this.mergeRefs(e,n,r):n,{resolved:n,refsStack:s}}return{resolved:e,refsStack:concatRefStacks(t,i)}}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"].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=""){var n;if(e["x-circular-ref"])return e;if(void 0===(e=this.hoistOneOfs(e)).allOf)return Object.assign({absolutePointer:i},e);let s=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)});void 0!==s.properties&&"object"==typeof s.properties&&(s.properties=Object.assign({},s.properties)),void 0!==s.items&&"object"==typeof s.items&&(s.items=Object.assign({},s.items));const o=e.allOf.map(((e,t)=>{var n;const{resolved:o,refsStack:a}=this.deref(e,r,!0),l=e.$ref,f=l||JsonPointer_1.JsonPointer.join(i,[String(t)]),c=this.mergeAllOf(o,l,a,f);if(!c["x-circular-ref"]||!c.allOf)return l&&(null===(n=s["x-parentRefs"])||void 0===n||n.push(...c["x-parentRefs"]||[],l)),{$ref:l,refsStack:pushRef(a,l),schema:c,absolutePointer:f}})).filter((e=>void 0!==e));for(const[e,{schema:r,refsStack:i,absolutePointer:a}]of o.entries()){const{type:o,enum:l,properties:f,items:c,required:p,title:d,description:O,readOnly:u,writeOnly:y,oneOf:b,anyOf:h,"x-circular-ref":m}=r,v=__rest(r,["type","enum","properties","items","required","title","description","readOnly","writeOnly","oneOf","anyOf","x-circular-ref"]);if(s.type===o||void 0===s.type||void 0===o){if(void 0!==o&&(Array.isArray(o)&&Array.isArray(s.type)?s.type=[...o,...s.type]:s.type=o),void 0!==l&&(Array.isArray(l)&&Array.isArray(s.enum)?s.enum=Array.from(new Set([...l,...s.enum])):s.enum=l),void 0!==f&&"object"==typeof f){s.properties=s.properties||{};for(const r in f){const o=concatRefStacks(i,null===(n=f[r])||void 0===n?void 0:n["x-refsStack"]);if(s.properties[r]){if(!m){const i=this.mergeAllOf({allOf:[s.properties[r],f[r]],"x-refsStack":o},t+"/properties/"+r,o,JsonPointer_1.JsonPointer.join(a,["allOf",String(e),"properties",r]));s.properties[r]=i}}else s.properties[r]=Object.assign(Object.assign({},f[r]),{absolutePointer:JsonPointer_1.JsonPointer.join(a,["properties",r]),"x-refsStack":o})}}if(void 0!==c&&!m){const e="boolean"==typeof s.items?{}:Object.assign({},s.items),n="boolean"==typeof r.items?{}:Object.assign({},r.items);s.items=this.mergeAllOf({allOf:[e,n]},t+"/items",i)}void 0!==b&&(s.oneOf=b),void 0!==h&&(s.anyOf=h),Array.isArray(p)&&(s.required=[...s.required||[],...p]),s=Object.assign(Object.assign(Object.assign({},s),{title:s.title||d,description:s.description||O,readOnly:void 0!==s.readOnly?s.readOnly:u,writeOnly:void 0!==s.writeOnly?s.writeOnly:y,"x-circular-ref":s["x-circular-ref"]||m}),v)}}return s}findDerived(e){const t={},r=this.definition.components&&this.definition.components.schemas||{};for(const i in r){const{resolved:n}=this.deref(r[i]);void 0!==n.allOf&&n.allOf.find((t=>void 0!==t.$ref&&e.indexOf(t.$ref)>-1))&&(t["#/components/schemas/"+i]=[n["x-discriminator-value"]||i])}return t}hoistOneOfs(e){if(void 0===e.allOf)return e;const t=e.allOf;for(let e=0;e<t.length;e++){const r=t[e];if(Array.isArray(r.oneOf)){const i=t.slice(0,e),n=t.slice(e+1);return{oneOf:r.oneOf.map((e=>({allOf:[...i,e,...n]})))}}}return e}}exports.OpenAPIParser=OpenAPIParser;
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=exports.concatRefStacks=exports.pushRef=void 0;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}exports.pushRef=pushRef,exports.concatRefStacks=concatRefStacks;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=decodeURIComponent(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 i=null==e?void 0:e["x-refsStack"];if(t=concatRefStacks(t,i),this.isRef(e)){const i=(0,utils_1.getDefinitionName)(e.$ref);if(i&&this.options.ignoreNamedSchemas.has(i))return{resolved:{type:"object",title:i},refsStack:t};let n=this.byRef(e.$ref);if(!n)throw new Error(`Failed to resolve $ref "${e.$ref}"`);if(t.includes(e.$ref))n=Object.assign({},n,{"x-circular-ref":!0});else if(this.isRef(n)){n=this.deref(n,t,r).resolved}return this.allowMergeRefs&&(n=this.mergeRefs(e,n,r)),{resolved:n,refsStack:pushRef(t,e.$ref)}}return{resolved:e,refsStack:concatRefStacks(t,i)}}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"].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=""){var n;if(e["x-circular-ref"])return e;if(void 0===(e=this.hoistOneOfs(e)).allOf)return Object.assign({absolutePointer:i},e);let s=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)(s.properties)&&(0,theme_1.isObject)(s.properties)&&(s.properties=Object.assign({},s.properties)),!(0,theme_1.isUndefined)(s.items)&&(0,theme_1.isObject)(s.items)&&(s.items=Object.assign({},s.items));const o=e.allOf.map(((e,t)=>{var n;const{resolved:o,refsStack:f}=this.deref(e,r,!0),a=e.$ref,l=a||JsonPointer_1.JsonPointer.join(i,[String(t)]),c=this.mergeAllOf(o,a,f,l);if(!c["x-circular-ref"]||!c.allOf)return a&&(null===(n=s["x-parentRefs"])||void 0===n||n.push(...c["x-parentRefs"]||[],a)),{$ref:a,refsStack:pushRef(f,a),schema:c,absolutePointer:l}})).filter(Boolean);for(const[e,{schema:r,refsStack:i,absolutePointer:f}]of o.entries()){const{type:o,enum:a,properties:l,items:c,required:d,title:p,description:O,readOnly:u,writeOnly:h,oneOf:m,anyOf:y,"x-circular-ref":b}=r,_=__rest(r,["type","enum","properties","items","required","title","description","readOnly","writeOnly","oneOf","anyOf","x-circular-ref"]);if(s.type===o||(0,theme_1.isUndefined)(s.type)||(0,theme_1.isUndefined)(o)){if((0,theme_1.isUndefined)(o)||(Array.isArray(o)&&Array.isArray(s.type)?s.type=[...o,...s.type]:s.type=o),(0,theme_1.isUndefined)(a)||(Array.isArray(a)&&Array.isArray(s.enum)?s.enum=Array.from(new Set([...a,...s.enum])):s.enum=a),!(0,theme_1.isUndefined)(l)&&(0,theme_1.isObject)(l)){s.properties=s.properties||{};for(const r in l){const o=concatRefStacks(i,null===(n=l[r])||void 0===n?void 0:n["x-refsStack"]);if(s.properties[r]){if(!b){const i=this.mergeAllOf({allOf:[s.properties[r],l[r]],"x-refsStack":o},t+"/properties/"+r,o,JsonPointer_1.JsonPointer.join(f,["allOf",String(e),"properties",r]));s.properties[r]=i}}else s.properties[r]=Object.assign(Object.assign({},l[r]),{absolutePointer:JsonPointer_1.JsonPointer.join(f,["properties",r]),"x-refsStack":o})}}if(!(0,theme_1.isUndefined)(c)&&!b){const e="boolean"==typeof s.items?{}:Object.assign({},s.items),n="boolean"==typeof r.items?{}:Object.assign({},r.items);s.items=this.mergeAllOf({allOf:[e,n]},t+"/items",i)}(0,theme_1.isUndefined)(m)||(s.oneOf=m),(0,theme_1.isUndefined)(y)||(s.anyOf=y),Array.isArray(d)&&(s.required=[...s.required||[],...d]),s=Object.assign(Object.assign(Object.assign({},s),{title:s.title||p,description:s.description||O,readOnly:(0,theme_1.isUndefined)(s.readOnly)?u:s.readOnly,writeOnly:(0,theme_1.isUndefined)(s.writeOnly)?h:s.writeOnly,"x-circular-ref":s["x-circular-ref"]||b}),_)}}return s}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 t=e.allOf;for(let e=0;e<t.length;e++){const r=t[e];if(Array.isArray(r.oneOf)){const i=t.slice(0,e),n=t.slice(e+1);return{oneOf:r.oneOf.map((e=>({allOf:[...i,e,...n]})))}}}return e}}exports.OpenAPIParser=OpenAPIParser;
2
2
  //# sourceMappingURL=OpenAPIParser.js.map
@@ -1,2 +1,2 @@
1
- import{useLocation}from"react-router-dom";import{useEffect,useLayoutEffect}from"react";import{addTrailingSlash,addLeadingSlash,IS_BROWSER,useActiveSectionId}from"@redocly/theme";import{compose,encodeBackSlashes,normalizePath}from"../../utils";let initialPageLoad=!0;export function useAutoScroll(e){const o=useLocation(),a=addTrailingSlash(e)||"/";useLayoutEffect((()=>{if(o.pathname===a&&""===o.hash)window.scrollTo(0,0);else{const e=o.hash.replace("#","").toLowerCase()||normalizePath(o.pathname).replace(a,""),t=document.getElementById(decodeURIComponent(e));t&&t.scrollIntoView()}}),[o,a]);const t=useActiveSectionId(o,!1,!1);useEffect((()=>{if(t&&initialPageLoad)initialPageLoad=!1;else if(IS_BROWSER&&!window.location.pathname.includes(t)&&!window.location.hash.includes(t)){const e=compose(addLeadingSlash,encodeBackSlashes)(t);window.history.replaceState({},"",e)}}),[t])}
1
+ import{useLocation}from"react-router-dom";import{useEffect,useLayoutEffect}from"react";import{addLeadingSlash,IS_BROWSER,useActiveSectionId,removeLeadingSlash}from"@redocly/theme";import{compose,encodeBackSlashes}from"../../utils";let initialPageLoad=!0;export function useAutoScroll(e){const o=useLocation(),t=e||"/";useLayoutEffect((()=>{if(o.pathname===t&&""===o.hash)window.scrollTo(0,0);else{const e=o.hash.replace("#","").toLowerCase()||removeLeadingSlash(o.pathname.replace(t,"")),a=document.getElementById(decodeURIComponent(e));a&&a.scrollIntoView()}}),[o,t]);const a=useActiveSectionId(o,!1,!1);useEffect((()=>{if(a&&initialPageLoad)initialPageLoad=!1;else if(IS_BROWSER&&!window.location.pathname.includes(a)&&!window.location.hash.includes(a)){const e=compose(addLeadingSlash,encodeBackSlashes)(a);window.history.replaceState({},"",e)}}),[a])}
2
2
  //# sourceMappingURL=useAutoScroll.js.map
@@ -26,7 +26,7 @@ export declare class OpenAPIParser {
26
26
  /**
27
27
  * Resolve given reference object or return as is if it is not a reference
28
28
  * @param obj object to dereference
29
- * @param forceCircular whether to dereference even if it is circular ref
29
+ * @param baseRefsStack
30
30
  * @param mergeAsAllOf
31
31
  */
32
32
  deref<T>(obj: OpenAPIRef | T, baseRefsStack?: string[], mergeAsAllOf?: boolean): {
@@ -38,8 +38,8 @@ export declare class OpenAPIParser {
38
38
  * Merge allOf constraints.
39
39
  * @param schema schema with allOF
40
40
  * @param $ref pointer of the schema
41
- * @param forceCircular whether to dereference children even if it is a circular ref
42
- * @param used$Refs
41
+ * @param refsStack
42
+ * @param absolutePointer
43
43
  */
44
44
  mergeAllOf(schema: MergedOpenAPISchema, $ref: string | undefined, refsStack: string[], absolutePointer?: string): MergedOpenAPISchema;
45
45
  /**
@@ -1,2 +1,2 @@
1
- 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};import{IS_BROWSER}from"@redocly/theme";import{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,r=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=decodeURIComponent(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 i=IS_BROWSER?window.location.href:"";"string"==typeof t&&(this.definitionUrl=new URL(t,i).href)}validate(e){if(void 0===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 i=null==e?void 0:e["x-refsStack"];if(t=concatRefStacks(t,i),this.isRef(e)){const i=getDefinitionName(e.$ref);if(i&&this.options.ignoreNamedSchemas.has(i))return{resolved:{type:"object",title:i},refsStack:t};let n=this.byRef(e.$ref);if(!n)throw new Error(`Failed to resolve $ref "${e.$ref}"`);let o=t;if(t.includes(e.$ref))n=Object.assign({},n,{"x-circular-ref":!0});else if(this.isRef(n)){const e=this.deref(n,t,r);o=e.refsStack,n=e.resolved}return o=pushRef(t,e.$ref),n=this.allowMergeRefs?this.mergeRefs(e,n,r):n,{resolved:n,refsStack:o}}return{resolved:e,refsStack:concatRefStacks(t,i)}}mergeRefs(e,t,r){const{$ref:i}=e,n=__rest(e,["$ref"]),o=Object.keys(n);if(0===o.length)return t;if(r&&o.some((e=>!["description","title","externalDocs","x-refsStack","x-parentRefs","readOnly","writeOnly"].includes(e)))){const e=n,{description:r,title:i,readOnly:o,writeOnly:s}=e;return{allOf:[{description:r,title:i,readOnly:o,writeOnly:s},t,__rest(e,["description","title","readOnly","writeOnly"])]}}return Object.assign(Object.assign({},t),n)}mergeAllOf(e,t,r,i=""){var n;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.join(i,["allOf"]),allOf:void 0,title:e.title||getDefinitionName(t)});void 0!==o.properties&&"object"==typeof o.properties&&(o.properties=Object.assign({},o.properties)),void 0!==o.items&&"object"==typeof o.items&&(o.items=Object.assign({},o.items));const s=e.allOf.map(((e,t)=>{var n;const{resolved:s,refsStack:f}=this.deref(e,r,!0),l=e.$ref,a=l||JsonPointer.join(i,[String(t)]),c=this.mergeAllOf(s,l,f,a);if(!c["x-circular-ref"]||!c.allOf)return l&&(null===(n=o["x-parentRefs"])||void 0===n||n.push(...c["x-parentRefs"]||[],l)),{$ref:l,refsStack:pushRef(f,l),schema:c,absolutePointer:a}})).filter((e=>void 0!==e));for(const[e,{schema:r,refsStack:i,absolutePointer:f}]of s.entries()){const{type:s,enum:l,properties:a,items:c,required:p,title:d,description:O,readOnly:u,writeOnly:y,oneOf:m,anyOf:b,"x-circular-ref":h}=r,v=__rest(r,["type","enum","properties","items","required","title","description","readOnly","writeOnly","oneOf","anyOf","x-circular-ref"]);if(o.type===s||void 0===o.type||void 0===s){if(void 0!==s&&(Array.isArray(s)&&Array.isArray(o.type)?o.type=[...s,...o.type]:o.type=s),void 0!==l&&(Array.isArray(l)&&Array.isArray(o.enum)?o.enum=Array.from(new Set([...l,...o.enum])):o.enum=l),void 0!==a&&"object"==typeof a){o.properties=o.properties||{};for(const r in a){const s=concatRefStacks(i,null===(n=a[r])||void 0===n?void 0:n["x-refsStack"]);if(o.properties[r]){if(!h){const i=this.mergeAllOf({allOf:[o.properties[r],a[r]],"x-refsStack":s},t+"/properties/"+r,s,JsonPointer.join(f,["allOf",String(e),"properties",r]));o.properties[r]=i}}else o.properties[r]=Object.assign(Object.assign({},a[r]),{absolutePointer:JsonPointer.join(f,["properties",r]),"x-refsStack":s})}}if(void 0!==c&&!h){const e="boolean"==typeof o.items?{}:Object.assign({},o.items),n="boolean"==typeof r.items?{}:Object.assign({},r.items);o.items=this.mergeAllOf({allOf:[e,n]},t+"/items",i)}void 0!==m&&(o.oneOf=m),void 0!==b&&(o.anyOf=b),Array.isArray(p)&&(o.required=[...o.required||[],...p]),o=Object.assign(Object.assign(Object.assign({},o),{title:o.title||d,description:o.description||O,readOnly:void 0!==o.readOnly?o.readOnly:u,writeOnly:void 0!==o.writeOnly?o.writeOnly:y,"x-circular-ref":o["x-circular-ref"]||h}),v)}}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]);void 0!==n.allOf&&n.allOf.find((t=>void 0!==t.$ref&&e.indexOf(t.$ref)>-1))&&(t["#/components/schemas/"+i]=[n["x-discriminator-value"]||i])}return t}hoistOneOfs(e){if(void 0===e.allOf)return e;const t=e.allOf;for(let e=0;e<t.length;e++){const r=t[e];if(Array.isArray(r.oneOf)){const i=t.slice(0,e),n=t.slice(e+1);return{oneOf:r.oneOf.map((e=>({allOf:[...i,e,...n]})))}}}return e}}
1
+ var __rest=this&&this.__rest||function(e,i){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&i.indexOf(r)<0&&(t[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(e);n<r.length;n++)i.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(e,r[n])&&(t[r[n]]=e[r[n]])}return t};import{IS_BROWSER,isObject,isString,isUndefined}from"@redocly/theme";import{getDefinitionName}from"../utils";import{JsonPointer}from"../utils/JsonPointer";import{normalizeOptions}from"./config-options/normalizeOptions";export function pushRef(e,i){return i&&e[e.length-1]!==i?[...e,i]:e}export function concatRefStacks(e,i){return i?e.concat(i):e}export class OpenAPIParser{constructor(e,i,t=normalizeOptions({})){Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"definitionUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"definition",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"allowMergeRefs",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"byRef",{enumerable:!0,configurable:!0,writable:!0,value:e=>{let i;if(this.definition){"#"!==e.charAt(0)&&(e="#"+e),e=decodeURIComponent(e);try{i=JsonPointer.get(this.definition,e)}catch(e){}return i||{}}}}),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(i)&&(this.definitionUrl=new URL(i,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,i=[],t=!1){const r=null==e?void 0:e["x-refsStack"];if(i=concatRefStacks(i,r),this.isRef(e)){const r=getDefinitionName(e.$ref);if(r&&this.options.ignoreNamedSchemas.has(r))return{resolved:{type:"object",title:r},refsStack:i};let n=this.byRef(e.$ref);if(!n)throw new Error(`Failed to resolve $ref "${e.$ref}"`);if(i.includes(e.$ref))n=Object.assign({},n,{"x-circular-ref":!0});else if(this.isRef(n)){n=this.deref(n,i,t).resolved}return this.allowMergeRefs&&(n=this.mergeRefs(e,n,t)),{resolved:n,refsStack:pushRef(i,e.$ref)}}return{resolved:e,refsStack:concatRefStacks(i,r)}}mergeRefs(e,i,t){const{$ref:r}=e,n=__rest(e,["$ref"]),s=Object.keys(n);if(0===s.length)return i;if(t&&s.some((e=>!["description","title","externalDocs","x-refsStack","x-parentRefs","readOnly","writeOnly"].includes(e)))){const e=n,{description:t,title:r,readOnly:s,writeOnly:o}=e;return{allOf:[{description:t,title:r,readOnly:s,writeOnly:o},i,__rest(e,["description","title","readOnly","writeOnly"])]}}return Object.assign(Object.assign({},i),n)}mergeAllOf(e,i,t,r=""){var n;if(e["x-circular-ref"])return e;if(void 0===(e=this.hoistOneOfs(e)).allOf)return Object.assign({absolutePointer:r},e);let s=Object.assign(Object.assign({},e),{"x-parentRefs":[],absolutePointer:JsonPointer.join(r,["allOf"]),allOf:void 0,title:e.title||getDefinitionName(i)});!isUndefined(s.properties)&&isObject(s.properties)&&(s.properties=Object.assign({},s.properties)),!isUndefined(s.items)&&isObject(s.items)&&(s.items=Object.assign({},s.items));const o=e.allOf.map(((e,i)=>{var n;const{resolved:o,refsStack:f}=this.deref(e,t,!0),l=e.$ref,a=l||JsonPointer.join(r,[String(i)]),c=this.mergeAllOf(o,l,f,a);if(!c["x-circular-ref"]||!c.allOf)return l&&(null===(n=s["x-parentRefs"])||void 0===n||n.push(...c["x-parentRefs"]||[],l)),{$ref:l,refsStack:pushRef(f,l),schema:c,absolutePointer:a}})).filter(Boolean);for(const[e,{schema:t,refsStack:r,absolutePointer:f}]of o.entries()){const{type:o,enum:l,properties:a,items:c,required:d,title:p,description:O,readOnly:u,writeOnly:m,oneOf:y,anyOf:b,"x-circular-ref":h}=t,g=__rest(t,["type","enum","properties","items","required","title","description","readOnly","writeOnly","oneOf","anyOf","x-circular-ref"]);if(s.type===o||isUndefined(s.type)||isUndefined(o)){if(isUndefined(o)||(Array.isArray(o)&&Array.isArray(s.type)?s.type=[...o,...s.type]:s.type=o),isUndefined(l)||(Array.isArray(l)&&Array.isArray(s.enum)?s.enum=Array.from(new Set([...l,...s.enum])):s.enum=l),!isUndefined(a)&&isObject(a)){s.properties=s.properties||{};for(const t in a){const o=concatRefStacks(r,null===(n=a[t])||void 0===n?void 0:n["x-refsStack"]);if(s.properties[t]){if(!h){const r=this.mergeAllOf({allOf:[s.properties[t],a[t]],"x-refsStack":o},i+"/properties/"+t,o,JsonPointer.join(f,["allOf",String(e),"properties",t]));s.properties[t]=r}}else s.properties[t]=Object.assign(Object.assign({},a[t]),{absolutePointer:JsonPointer.join(f,["properties",t]),"x-refsStack":o})}}if(!isUndefined(c)&&!h){const e="boolean"==typeof s.items?{}:Object.assign({},s.items),n="boolean"==typeof t.items?{}:Object.assign({},t.items);s.items=this.mergeAllOf({allOf:[e,n]},i+"/items",r)}isUndefined(y)||(s.oneOf=y),isUndefined(b)||(s.anyOf=b),Array.isArray(d)&&(s.required=[...s.required||[],...d]),s=Object.assign(Object.assign(Object.assign({},s),{title:s.title||p,description:s.description||O,readOnly:isUndefined(s.readOnly)?u:s.readOnly,writeOnly:isUndefined(s.writeOnly)?m:s.writeOnly,"x-circular-ref":s["x-circular-ref"]||h}),g)}}return s}findDerived(e){const i={},t=this.definition.components&&this.definition.components.schemas||{};for(const r in t){const{resolved:n}=this.deref(t[r]);!isUndefined(n.allOf)&&n.allOf.find((i=>!isUndefined(i.$ref)&&e.indexOf(i.$ref)>-1))&&(i["#/components/schemas/"+r]=[n["x-discriminator-value"]||r])}return i}hoistOneOfs(e){if(isUndefined(e.allOf))return e;const i=e.allOf;for(let e=0;e<i.length;e++){const t=i[e];if(Array.isArray(t.oneOf)){const r=i.slice(0,e),n=i.slice(e+1);return{oneOf:t.oneOf.map((e=>({allOf:[...r,e,...n]})))}}}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.2.10",
3
+ "version": "3.2.11",
4
4
  "description": "Redocly OpenAPI Docs",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib-esm/index.js",
@@ -44,7 +44,7 @@
44
44
  "url": "~0.11.0",
45
45
  "url-template": "^2.0.8",
46
46
  "util": "~0.12.5",
47
- "@redocly/replay": "0.3.13",
47
+ "@redocly/replay": "0.3.14",
48
48
  "@redocly/config": "0.8.1"
49
49
  },
50
50
  "devDependencies": {
@@ -92,7 +92,7 @@
92
92
  "webpack": "5.91.0",
93
93
  "webpack-cli": "5.1.4",
94
94
  "webpack-dev-server": "4.15.2",
95
- "@redocly/theme": "0.38.8"
95
+ "@redocly/theme": "0.39.0"
96
96
  },
97
97
  "scripts": {
98
98
  "start": "webpack serve --mode=development --hot",