@redocly/openapi-docs 3.16.0-next.1 → 3.16.0-next.3
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 +1 @@
|
|
|
1
|
-
import{jsx as d}from"react/jsx-runtime";import{memo as v,useCallback as
|
|
1
|
+
import{jsx as d}from"react/jsx-runtime";import{memo as v,useCallback as y,useEffect as g,useMemo as b}from"react";import E from"@markdoc/markdoc";import{LayoutVariant as S}from"@redocly/config";import{createStore as O,Provider as A}from"jotai";import{html as N}from"@redocly/theme/markdoc/tags/html";import{Heading as M}from"@redocly/theme/markdoc/components/Heading/Heading";import{normalizeOptions as T,OpenAPIParser as D}from"../../services/index.js";import{SchemaDefinition as j}from"../SchemaDefinition/index.js";import{McpTool as k}from"../McpTool/index.js";import{getMarkdownHeaderId as x}from"./utils.js";import{mergeInMockServer as C}from"../../models/operation.js";import{normalizeServers as P}from"../../utils/index.js";import{appStore as H,appStoreOverrideAtom as I,layoutAtom as p,allowedEnvironmentsAtom as L,environmentAtom as R,userClaimsAtom as V}from"../../jotai/app.js";import{mapObject as z}from"../../utils/object.js";import{getServerEnvName as _}from"../../utils/environments.js";import{globalStoreAtom as q}from"../../jotai/store.js";import{getDefaultOperationStore as B,operationStore as F}from"../../jotai/operation.js";const W={ignoreNamedSchemas:["java.io.ObjectStreamField"],maxDisplayedEnumValues:10,markdocOptions:{tags:{html:N.schema,schemaDefinition:{render:"SchemaDefinition",attributes:{schemaRef:{type:String},exampleRef:{type:String},showReadOnly:{type:Boolean},showWriteOnly:{type:Boolean},htmlWrap:{type:String,default:!1}}},mcpTool:{render:"McpTool",attributes:{toolName:{type:String},id:{type:String}}}},nodes:{heading:{children:["inline"],attributes:{id:{type:String},level:{type:Number,required:!0,default:1}},transform(n,m){const t=n.transformAttributes(m),i=n.transformChildren(m),e=typeof t.id=="string"?t.id:x(i);return new E.Tag("Heading",{...t,id:e,level:n.attributes.level},i)}}},components:{SchemaDefinition:j,McpTool:k,Heading:M}}},se=v(({children:n,options:m,definitionUrl:t,definition:i,withState:e})=>{const l=y(()=>{const r=T(m,W),o=new D(i,t,r);return{options:r,parser:o}},[i,t,m]),a=b(()=>{const r=O(),o=l();r.set(q,o);const c=P(o.parser.definitionUrl,C(o.parser.definition?.servers||[],o.options.mockServer));r.sub(H,()=>{}),r.set(p,e?.layout||o.options?.layout||S.THREE_PANEL);const u=Object.fromEntries(c.map(s=>[_(s),{server:s.url,...z(s.variables||{},f=>f.default||"")}]));if(r.set(R,{environments:u}),r.set(V,e?.userClaims||{}),r.set(L,e?.allowedEnvironments),e&&r.set(I,{activeMimeName:e.activeMimeName,userClaims:e.userClaims,environment:e.environment,environments:e.environments}),e?.operation){const s=B(e.operation.pointer,e.operation.state.requestValues,e.operation.state.activeExampleName);r.set(F(e.operation.pointer),s)}return r},[l,e]);return g(()=>{e?.layout&&a.set(p,e?.layout)},[a,e?.layout]),d(A,{store:a,children:n})});export{se as StoreProvider};
|
|
@@ -4,7 +4,8 @@ export type ReplayProps = {
|
|
|
4
4
|
fullOpenApi: OpenAPIDefinition;
|
|
5
5
|
corsProxyUrl?: string;
|
|
6
6
|
pointer: string;
|
|
7
|
+
hideOtherSecuritySchemes?: boolean;
|
|
7
8
|
};
|
|
8
|
-
declare function EmbeddedReplayComponent({ activeOperationId, corsProxyUrl, fullOpenApi, pointer, }: ReplayProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
declare function EmbeddedReplayComponent({ activeOperationId, corsProxyUrl, fullOpenApi, pointer, hideOtherSecuritySchemes, }: ReplayProps): import("react/jsx-runtime").JSX.Element;
|
|
9
10
|
export declare const EmbeddedReplay: import("react").MemoExoticComponent<typeof EmbeddedReplayComponent>;
|
|
10
11
|
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import{Suspense as
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{Suspense as h,lazy as S,memo as x,useEffect as O,useState as R}from"react";import{useAtomValue as o}from"jotai";import{globalOptionsAtom as A}from"../../jotai/store.js";import{operationStore as C}from"../../jotai/operation.js";import{appStore as L,allowedEnvironmentsAtom as T,environmentsAtom as V}from"../../jotai/app.js";import{useTranslate as j}from"../../hooks/index.js";import{convertOperationToReplayValue as k}from"./utils.js";import{getDefaultCollectorUrl as w}from"../../utils/telemetry.js";import{styled as i}from"../../styled-components.js";const U=S(async()=>import("@redocly/replay").then(t=>({default:t.EmbeddedReplay})));function W({activeOperationId:t,corsProxyUrl:p,fullOpenApi:d,pointer:r,hideOtherSecuritySchemes:m}){const a=j(),{mockServer:s}=o(A),c=o(C(r)),f=o(L),u=o(V),n=o(T),[v,y]=R(!1);return O(()=>{y(!0)},[]),e(z,{children:v?e(h,{fallback:e(l,{children:a("openapi.loading","Loading...")}),children:e(U,{activeOperationId:t,activeOperationPointer:r,api:d,settings:{predefinedEnvValues:u,corsProxyUrl:p,mockServer:s,disableCollectionsTab:!0,hideOtherSecuritySchemes:m,...n&&{allowedEnvironments:n},telemetry:{tracerName:"replay-openapi",collectorUrl:w()},convertOperationToReplayValue:(g,b,E)=>k(g,b,E,void 0,c,f)}})}):e(l,{children:a("openapi.loading","Loading...")})})}const J=x(W),l=i.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
justify-content: center;
|
|
4
4
|
align-items: center;
|
|
5
5
|
min-height: 100px;
|
|
6
|
-
`,
|
|
6
|
+
`,z=i.div`
|
|
7
7
|
border: 1px solid var(--border-color-primary);
|
|
8
8
|
border-radius: var(--border-radius-lg);
|
|
9
9
|
padding: 0;
|
|
10
|
-
`;export{
|
|
10
|
+
`;export{J as EmbeddedReplay};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{IS_BROWSER as q,isObject as
|
|
1
|
+
import{IS_BROWSER as q,isObject as A,isString as E,isUndefined as o}from"@redocly/theme/core/openapi";import{tryDecodeURIComponent as B,getDefinitionName as v}from"../utils/index.js";import{JsonPointer as x}from"../utils/JsonPointer.js";import{normalizeOptions as W}from"./config-options/normalizeOptions.js";function S(m,e){return e&&m[m.length-1]!==e?[...m,e]:m}function R(m,e){return e?m.concat(e):m}class V{options;definitionUrl;definition;allowMergeRefs=!1;constructor(e,t,l=W({})){this.options=l,this.definition=Object.assign({},e),this.validate(e),this.definition=e,this.allowMergeRefs=e.openapi.startsWith("3.1");const n=q?window.location.href:"";E(t)&&(this.definitionUrl=new URL(t,n).href)}validate(e){if(o(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=B(e);try{t=x.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,n=0){const i=e?.["x-refsStack"];if(t=R(t,i),n>5)return{resolved:Object.assign({},e,{"x-complex":!0}),refsStack:t};if(this.isRef(e)){const r=v(e.$ref);if(r&&this.options.ignoreNamedSchemas.has(r))return{resolved:{type:"object",title:r},refsStack:t};let s=this.byRef(e.$ref);if(!s)throw new Error(`Failed to resolve $ref "${e.$ref}"`);return t.includes(e.$ref)?s=Object.assign({},s,{"x-circular-ref":!0}):this.isRef(s)&&(s=this.deref(s,t,l,n).resolved),this.allowMergeRefs&&(s=this.mergeRefs(e,s,l)),{resolved:s,refsStack:s.isPureRef?t:S(t,e.$ref)}}return{resolved:e,refsStack:R(t,i)}}mergeRefs(e,t,l){const{$ref:n,...i}=e,r=Object.keys(i);if(r.length===0)return{...t,$ref:n,isPureRef:!0};if(l&&r.some(s=>!["description","title","externalDocs","x-refsStack","x-parentRefs","readOnly","writeOnly","x-complex"].includes(s))){const{description:s,title:p,readOnly:u,writeOnly:d,...O}=i;return{allOf:[{description:s,title:p,readOnly:u,writeOnly:d},t,O]}}else return{...t,...i}}mergeAllOf(e,t,l,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:x.join(n,["allOf"]),allOf:void 0,title:i===0?e.title||v(t):e.title};!o(r.properties)&&A(r.properties)&&(r.properties={...r.properties}),!o(r.items)&&A(r.items)&&(r.items={...r.items});const s=e.allOf.map((p,u)=>{const{resolved:d,refsStack:O}=this.deref(p,l,!0,i),f=p.$ref,y=f||x.join(n,[String(u)]);if(d["x-complex"])return{$ref:f,refsStack:S(O,f),schema:{"x-complex":!0},absolutePointer:y};const a=this.mergeAllOf(d,f,O,y,i+1);if(!(a["x-circular-ref"]&&a.allOf))return f&&r["x-parentRefs"]?.push(...a["x-parentRefs"]||[],f),{$ref:f,refsStack:S(O,f),schema:a,absolutePointer:y}}).filter(Boolean);for(const[p,{schema:u,refsStack:d,absolutePointer:O}]of s.entries()){const{type:f,enum:y,properties:a,items:I,required:w,title:b,description:D,readOnly:C,writeOnly:M,oneOf:$,anyOf:P,"x-circular-ref":g,"x-complex":k,...N}=u||{};if(!(r.type!==f&&!o(r.type)&&!o(f)&&!i)){if(o(f)||(Array.isArray(f)&&Array.isArray(r.type)?r.type=[...f,...r.type]:r.type=f),o(y)||(Array.isArray(y)&&Array.isArray(r.enum)?r.enum=Array.from(new Set([...y,...r.enum])):r.enum=y),!o(a)&&A(a)){r.properties=r.properties||{};for(const c in a){const h=R(d,a[c]?.["x-refsStack"]);if(!r.properties[c])r.properties[c]={...a[c],absolutePointer:x.join(O,["properties",c]),"x-refsStack":h};else if(!g){const U=this.mergeAllOf({allOf:[r.properties[c],a[c]],"x-refsStack":h},t+"/properties/"+c,h,x.join(O,["allOf",String(p),"properties",c]),i+1);r.properties[c]=U}}}if(!o(I)&&!g&&!k){const c=typeof r.items=="boolean"?{}:Object.assign({},r.items),h=typeof u.items=="boolean"?{}:Object.assign({},u.items);r.items=this.mergeAllOf({allOf:[c,h]},t+"/items",d,"",i+1)}o($)||(r.oneOf=$),o(P)||(r.anyOf=P),Array.isArray(w)&&(r.required=[...r.required||[],...w]),r={...r,title:r.title||b,description:r.description||D,readOnly:o(r.readOnly)?C:r.readOnly,writeOnly:o(r.writeOnly)?M:r.writeOnly,"x-circular-ref":r["x-circular-ref"]||g,"x-complex":r["x-complex"]||k,...N}}}return r}findDerived(e){const t={},l=this.definition.components&&this.definition.components.schemas||{};for(const n in l){const{resolved:i}=this.deref(l[n]);!o(i.allOf)&&i.allOf.find(r=>!o(r.$ref)&&e.indexOf(r.$ref)>-1)&&(t["#/components/schemas/"+n]=[i["x-discriminator-value"]||n])}return t}hoistOneOfs(e){if(o(e.allOf))return e;const{allOf:t,...l}=e;for(let n=0;n<t.length;n++){const{oneOf:i,...r}=t[n];if(i&&Array.isArray(i)){const s=t.slice(0,n),p=t.slice(n+1),u=Object.keys(r).length>0?[r]:[];return{...l,oneOf:i.map(d=>({allOf:[...s,...u,d,...p]}))}}}return e}}export{V as OpenAPIParser,R as concatRefStacks,S as pushRef};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/openapi-docs",
|
|
3
|
-
"version": "3.16.0-next.
|
|
3
|
+
"version": "3.16.0-next.3",
|
|
4
4
|
"description": "Redocly OpenAPI Docs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@markdoc/markdoc": "0.5.2",
|
|
24
|
-
"@redocly/openapi-core": "2.
|
|
24
|
+
"@redocly/openapi-core": "2.11.1",
|
|
25
25
|
"deepmerge": "^4.2.2",
|
|
26
26
|
"dompurify": "3.2.7",
|
|
27
27
|
"fast-deep-equal": "^3.1.3",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"util": "~0.12.5",
|
|
38
38
|
"web-vitals": "3.3.1",
|
|
39
39
|
"@redocly/config": "0.38.0",
|
|
40
|
-
"@redocly/replay": "0.19.0-next.
|
|
40
|
+
"@redocly/replay": "0.19.0-next.3"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@jest/globals": "29.5.0",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"typescript": "5.9.3",
|
|
76
76
|
"url": "~0.11.0",
|
|
77
77
|
"vite": "7.1.9",
|
|
78
|
-
"@redocly/theme": "0.60.0-next.
|
|
78
|
+
"@redocly/theme": "0.60.0-next.2"
|
|
79
79
|
},
|
|
80
80
|
"scripts": {
|
|
81
81
|
"start": "npm run copy-highlight-hook && vite",
|
|
@@ -86,7 +86,8 @@
|
|
|
86
86
|
"prepare:community-source-only": "npm run prepare:community-source --ignore /src/* private-readme.md",
|
|
87
87
|
"prepare:community-dependencies": "npx tsx scripts/prepare-community-dependencies.ts",
|
|
88
88
|
"apply:community-source": "npx tsx scripts/apply-changes-from-community-source.ts",
|
|
89
|
-
"test": "jest -w 2",
|
|
89
|
+
"test": "npm run prepare:community-source && npm run redoc:use-workspace && npm run test:redoc && npm run redoc:revert-workspace && jest -w 2",
|
|
90
|
+
"test:redoc": "cd redoc && pnpm install && npm run lint && npm run unit",
|
|
90
91
|
"unit": "jest -w 2",
|
|
91
92
|
"test:update": "jest -u",
|
|
92
93
|
"test:watch": "jest --watch",
|
|
@@ -100,6 +101,8 @@
|
|
|
100
101
|
"license:check": "npx license-checker --production --onlyAllow 'MIT;ISC;Apache-2.0;Apache;CC0-1.0;BSD;BSD-2-Clause;BSD-3-Clause;UNKNOWN' --summary",
|
|
101
102
|
"precdn:serve": "mkdir -p playground/cdn-test/server-dist && cp -Rf dist/* playground/cdn-test/server-dist && cp -Rf playground/cdn-test/template-source/* playground/cdn-test/server-dist",
|
|
102
103
|
"cdn-serve": "http-server playground/cdn-test/server-dist",
|
|
103
|
-
"copy-highlight-hook": "cp -r ../portal/src/client/app/hooks/codeHighlight ./playground/hooks"
|
|
104
|
+
"copy-highlight-hook": "cp -r ../portal/src/client/app/hooks/codeHighlight ./playground/hooks",
|
|
105
|
+
"redoc:use-workspace": "node scripts/use-workspace-deps.js",
|
|
106
|
+
"redoc:revert-workspace": "node scripts/use-workspace-deps.js revert"
|
|
104
107
|
}
|
|
105
108
|
}
|