@redocly/openapi-docs 3.20.0-next.7 → 3.20.0-next.8
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 +2501 -2476
- package/lib/services/OpenAPIParser.js +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
import{IS_BROWSER as E,isObject as R,isString as B,isUndefined as
|
|
1
|
+
import{IS_BROWSER as E,isObject as R,isString as B,isUndefined as s}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 w(m,e){return e&&m[m.length-1]!==e?[...m,e]:m}function $(m,e){return e?m.concat(e):m}class _{options;definitionUrl;definition;allowMergeRefs=!1;constructor(e,t,f=z({})){this.options=f,this.definition=Object.assign({},e),this.validate(e),this.definition=e,this.allowMergeRefs=e.openapi.startsWith("3.1");const n=E?window.location.href:"";B(t)&&(this.definitionUrl=new URL(t,n).href)}validate(e){if(s(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=[],f=!1,n=0){const i=e?.["x-refsStack"];if(t=$(t,i),n>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 o=this.byRef(e.$ref);if(!o)throw new Error(`Failed to resolve $ref "${e.$ref}"`);return t.includes(e.$ref)?o=Object.assign({},o,{"x-circular-ref":!0}):this.isRef(o)&&(o=this.deref(o,t,f,n).resolved),this.allowMergeRefs&&(o=this.mergeRefs(e,o,f)),{resolved:o,refsStack:w(t,e.$ref)}}return{resolved:e,refsStack:$(t,i)}}mergeRefs(e,t,f){const{$ref:n,...i}=e,r=Object.keys(i);if(r.length===0)return t;if(f&&r.some(o=>!["description","title","externalDocs","x-refsStack","x-parentRefs","readOnly","writeOnly","x-complex"].includes(o))){const{description:o,title:u,readOnly:y,writeOnly:a,...O}=i;return{allOf:[{description:o,title:u,readOnly:y,writeOnly:a},t,O]}}else return{...t,...i}}mergeAllOf(e,t,f,n="",i=0){if(e["x-circular-ref"])return e;if(e=this.hoistOneOfs(e),e.allOf===void 0)return{absolutePointer:n,...e};let r={...e,"x-parentRefs":[],absolutePointer:g.join(n,["allOf"]),allOf:void 0,title:i===0?e.title||I(t):e.title};!s(r.properties)&&R(r.properties)&&(r.properties={...r.properties}),!s(r.items)&&R(r.items)&&(r.items={...r.items});const o=e.allOf.map((u,y)=>{const{resolved:a,refsStack:O}=this.deref(u,f,!0,i),c=u.$ref,p=c||g.join(n,[String(y)]);if(a["x-complex"])return{$ref:c,refsStack:w(O,c),schema:{"x-complex":!0},absolutePointer:p};const d=this.mergeAllOf(a,c,O,p,i+1);if(!(d["x-circular-ref"]&&d.allOf))return c&&r["x-parentRefs"]?.push(...d["x-parentRefs"]||[],c),{$ref:c,refsStack:w(O,c),schema:d,absolutePointer:p}}).filter(Boolean);for(const[u,{$ref:y,schema:a,refsStack:O,absolutePointer:c}]of o.entries()){const{type:p,enum:d,properties:h,items:D,required:k,title:S,description:C,readOnly:M,writeOnly:N,oneOf:P,anyOf:v,"x-circular-ref":A,"x-complex":b,...U}=a||{};if(!(r.type!==p&&!s(r.type)&&!s(p)&&!i)){if(s(p)||(Array.isArray(p)&&Array.isArray(r.type)?r.type=[...p,...r.type]:r.type=p),s(d)||(Array.isArray(d)&&Array.isArray(r.enum)?r.enum=Array.from(new Set([...d,...r.enum])):r.enum=d),!s(h)&&R(h)){r.properties=r.properties||{};for(const l in h){const x=$(O,h[l]?.["x-refsStack"]);if(!r.properties[l])r.properties[l]={...h[l],absolutePointer:g.join(c,["properties",l]),"x-refsStack":x};else if(!A){const q=this.mergeAllOf({allOf:[r.properties[l],h[l]],"x-refsStack":x},t+"/properties/"+l,x,g.join(c,["allOf",String(u),"properties",l]),i+1);r.properties[l]=q}}}if(!s(D)&&!A&&!b){const l=typeof r.items=="boolean"?{}:Object.assign({},r.items),x=typeof a.items=="boolean"?{}:Object.assign({},a.items);r.items=this.mergeAllOf({allOf:[l,x]},t+"/items",O,"",i+1)}s(P)||(r.oneOf=P),s(v)||(r.anyOf=v),Array.isArray(k)&&(r.required=[...r.required||[],...k]),r={...r,title:e.title||(y&&S?S:r.title||S),description:r.description||C,readOnly:s(r.readOnly)?M:r.readOnly,writeOnly:s(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={},f=this.definition.components&&this.definition.components.schemas||{};for(const n in f){const{resolved:i}=this.deref(f[n]);!s(i.allOf)&&i.allOf.find(r=>!s(r.$ref)&&e.indexOf(r.$ref)>-1)&&(t["#/components/schemas/"+n]=[i["x-discriminator-value"]||n])}return t}hoistOneOfs(e){if(s(e.allOf))return e;const{allOf:t,...f}=e;for(let n=0;n<t.length;n++){const{oneOf:i,...r}=t[n];if(i&&Array.isArray(i)&&s(r.discriminator)&&s(r["x-discriminator"])){const o=t.slice(0,n),u=t.slice(n+1),y=Object.keys(r).length>0?[r]:[];return{...f,oneOf:i.map(a=>({allOf:[...o,...y,a,...u]}))}}}return e}}export{_ as OpenAPIParser,$ as concatRefStacks,w as pushRef};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/openapi-docs",
|
|
3
|
-
"version": "3.20.0-next.
|
|
3
|
+
"version": "3.20.0-next.8",
|
|
4
4
|
"description": "Redocly OpenAPI Docs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"url-template": "^2.0.8",
|
|
39
39
|
"util": "~0.12.5",
|
|
40
40
|
"web-vitals": "3.3.1",
|
|
41
|
-
"@redocly/config": "0.
|
|
41
|
+
"@redocly/config": "0.48.0",
|
|
42
42
|
"@redocly/redoc-opentelemetry": "0.0.8",
|
|
43
|
-
"@redocly/replay": "0.23.0-next.
|
|
43
|
+
"@redocly/replay": "0.23.0-next.6"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@shikijs/transformers": "3.21.0",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"url": "~0.11.0",
|
|
73
73
|
"vite": "7.2.6",
|
|
74
74
|
"vitest": "4.0.10",
|
|
75
|
-
"@redocly/theme": "0.64.0-next.
|
|
75
|
+
"@redocly/theme": "0.64.0-next.6"
|
|
76
76
|
},
|
|
77
77
|
"scripts": {
|
|
78
78
|
"start": "pnpm run copy-highlight-hook && vite",
|