@redocly/openapi-docs 3.23.0-next.6 → 3.23.0-next.7
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 +2724 -2633
- package/lib/services/OpenAPIParser.js +1 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
import{IS_BROWSER as E,isObject as
|
|
1
|
+
import{IS_BROWSER as E,isObject as w,isString as B,isUndefined as i}from"@redocly/theme/core/openapi";import{tryDecodeURIComponent as W,getDefinitionName as I}from"../utils/index.js";import{JsonPointer as g}from"../utils/JsonPointer.js";import{normalizeOptions as z}from"./config-options/normalizeOptions.js";function R(O,e){return e&&O[O.length-1]!==e?[...O,e]:O}function $(O,e){return e?O.concat(e):O}class _{options;definitionUrl;definition;allowMergeRefs=!1;constructor(e,t,l=z({})){this.options=l,this.definition=Object.assign({},e),this.validate(e),this.definition=e,this.allowMergeRefs=e.openapi.startsWith("3.1");const s=E?window.location.href:"";B(t)&&(this.definitionUrl=new URL(t,s).href)}validate(e){if(i(e.openapi))throw new Error("Document must be valid OpenAPI 3.0.0 definition")}byRef=e=>{let t;if(this.definition){e.charAt(0)!=="#"&&(e="#"+e),e=W(e);try{t=g.get(this.definition,e)}catch{}return t||{}}};isRef(e){return e?(e=e,e.$ref!==void 0&&e.$ref!==null):!1}deref(e,t=[],l=!1,s=0){const n=e?.["x-refsStack"];if(t=$(t,n),s>5)return{resolved:Object.assign({},e,{"x-complex":!0}),refsStack:t};if(this.isRef(e)){const r=I(e.$ref);if(r&&this.options.ignoreNamedSchemas.has(r))return{resolved:{type:"object",title:r},refsStack:t};let f=this.byRef(e.$ref);if(!f)throw new Error(`Failed to resolve $ref "${e.$ref}"`);return t.includes(e.$ref)?f=Object.assign({},f,{"x-circular-ref":!0}):this.isRef(f)&&(f=this.deref(f,t,l,s).resolved),this.allowMergeRefs&&(f=this.mergeRefs(e,f,l)),{resolved:f,refsStack:R(t,e.$ref)}}return{resolved:e,refsStack:$(t,n)}}mergeRefs(e,t,l){const{$ref:s,...n}=e,r=Object.keys(n);if(r.length===0)return t;if(l&&r.some(f=>!["description","title","externalDocs","x-refsStack","x-parentRefs","readOnly","writeOnly","x-complex"].includes(f))){const{description:f,title:d,readOnly:h,writeOnly:o,...y}=n;return{allOf:[{description:f,title:d,readOnly:h,writeOnly:o},t,y]}}else return{...t,...n}}mergeAllOf(e,t,l,s="",n=0){if(e["x-circular-ref"])return e;if(e=this.hoistOneOfs(e),e.allOf===void 0)return{absolutePointer:s,...e};let r={...e,"x-parentRefs":[],absolutePointer:g.join(s,["allOf"]),allOf:void 0,title:n===0?e.title||I(t):e.title};!i(r.properties)&&w(r.properties)&&(r.properties={...r.properties}),!i(r.items)&&w(r.items)&&(r.items={...r.items});const f=e.allOf.map((d,h)=>{const{resolved:o,refsStack:y}=this.deref(d,l,!0,n),p=d.$ref,u=p||g.join(s,[String(h)]);if(o["x-complex"]){const c={"x-complex":!0};return i(o.readOnly)||(c.readOnly=o.readOnly),i(o.writeOnly)||(c.writeOnly=o.writeOnly),i(o.title)||(c.title=o.title),i(o.description)||(c.description=o.description),{$ref:p,refsStack:R(y,p),schema:c,absolutePointer:u}}const m=this.mergeAllOf(o,p,y,u,n+1);if(!(m["x-circular-ref"]&&m.allOf))return p&&r["x-parentRefs"]?.push(...m["x-parentRefs"]||[],p),{$ref:p,refsStack:R(y,p),schema:m,absolutePointer:u}}).filter(Boolean);for(const[d,{$ref:h,schema:o,refsStack:y,absolutePointer:p}]of f.entries()){const{type:u,enum:m,properties:c,items:D,required:k,title:S,description:C,readOnly:M,writeOnly:N,oneOf:P,anyOf:v,"x-circular-ref":A,"x-complex":b,...U}=o||{};if(!(r.type!==u&&!i(r.type)&&!i(u)&&!n)){if(i(u)||(Array.isArray(u)&&Array.isArray(r.type)?r.type=[...u,...r.type]:r.type=u),i(m)||(Array.isArray(m)&&Array.isArray(r.enum)?r.enum=Array.from(new Set([...m,...r.enum])):r.enum=m),!i(c)&&w(c)){r.properties=r.properties||{};for(const a in c){const x=$(y,c[a]?.["x-refsStack"]);if(!r.properties[a])r.properties[a]={...c[a],absolutePointer:g.join(p,["properties",a]),"x-refsStack":x};else if(!A){const q=this.mergeAllOf({allOf:[r.properties[a],c[a]],"x-refsStack":x},t+"/properties/"+a,x,g.join(p,["allOf",String(d),"properties",a]),n+1);r.properties[a]=q}}}if(!i(D)&&!A&&!b){const a=typeof r.items=="boolean"?{}:Object.assign({},r.items),x=typeof o.items=="boolean"?{}:Object.assign({},o.items);r.items=this.mergeAllOf({allOf:[a,x]},t+"/items",y,"",n+1)}i(P)||(r.oneOf=P),i(v)||(r.anyOf=v),Array.isArray(k)&&(r.required=[...r.required||[],...k]),r={...r,title:e.title||(h&&S?S:r.title||S),description:r.description||C,readOnly:i(r.readOnly)?M:r.readOnly,writeOnly:i(r.writeOnly)?N:r.writeOnly,"x-circular-ref":r["x-circular-ref"]||A,"x-complex":r["x-complex"]||b,...U}}}return r}findDerived(e){const t={},l=this.definition.components&&this.definition.components.schemas||{};for(const s in l){const{resolved:n}=this.deref(l[s]);!i(n.allOf)&&n.allOf.find(r=>!i(r.$ref)&&e.indexOf(r.$ref)>-1)&&(t["#/components/schemas/"+s]=[n["x-discriminator-value"]||s])}return t}hoistOneOfs(e){if(i(e.allOf))return e;const{allOf:t,...l}=e;for(let s=0;s<t.length;s++){const{oneOf:n,...r}=t[s];if(n&&Array.isArray(n)&&i(r.discriminator)&&i(r["x-discriminator"])){const f=t.slice(0,s),d=t.slice(s+1),h=Object.keys(r).length>0?[r]:[];return{...l,oneOf:n.map(o=>({allOf:[...f,...h,o,...d]}))}}}return e}}export{_ as OpenAPIParser,$ as concatRefStacks,R as pushRef};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/openapi-docs",
|
|
3
|
-
"version": "3.23.0-next.
|
|
3
|
+
"version": "3.23.0-next.7",
|
|
4
4
|
"description": "Redocly OpenAPI Docs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@babel/core": "7.29.7",
|
|
24
24
|
"@markdoc/markdoc": "0.5.2",
|
|
25
|
-
"@redocly/openapi-core": "2.
|
|
25
|
+
"@redocly/openapi-core": "2.37.0",
|
|
26
26
|
"deepmerge": "^4.2.2",
|
|
27
27
|
"dompurify": "3.4.11",
|
|
28
28
|
"fast-deep-equal": "^3.1.3",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"url-template": "^2.0.8",
|
|
40
40
|
"util": "~0.12.5",
|
|
41
41
|
"web-vitals": "3.3.1",
|
|
42
|
-
"@redocly/config": "0.
|
|
42
|
+
"@redocly/config": "0.50.1",
|
|
43
43
|
"@redocly/redoc-opentelemetry": "0.2.2",
|
|
44
|
-
"@redocly/replay": "0.26.0-next.
|
|
44
|
+
"@redocly/replay": "0.26.0-next.7"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@shikijs/transformers": "3.21.0",
|
|
@@ -69,9 +69,9 @@
|
|
|
69
69
|
"tsx": "4.20.3",
|
|
70
70
|
"typescript": "6.0.3",
|
|
71
71
|
"url": "~0.11.0",
|
|
72
|
-
"vite": "7.3.
|
|
72
|
+
"vite": "7.3.6",
|
|
73
73
|
"vitest": "4.1.8",
|
|
74
|
-
"@redocly/theme": "0.67.0-next.
|
|
74
|
+
"@redocly/theme": "0.67.0-next.6"
|
|
75
75
|
},
|
|
76
76
|
"scripts": {
|
|
77
77
|
"start": "pnpm run copy-highlight-hook && vite",
|