@redocly/api-docs 0.2.0-next.7 → 0.2.0-next.9

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 o,jsxs as f}from"react/jsx-runtime";import{memo as T,useMemo as v}from"react";import{useAtomValue as S}from"jotai";import{GlobalStyle as x}from"@redocly/theme/core/openapi";import{RedocTelemetry as R}from"./telemetry/RedocTelemetry.js";import{TelemetryContext as b}from"./contexts/telemetry.js";import{MarkdownAdapterProvider as P}from"./contexts/markdownAdapter.js";import{specTypeAtom as A}from"./jotai/store.js";import{useApiDocsRoutes as w}from"./hooks/useApiDocsRoutes.js";import{useVisitedChannelsTracker as U}from"./hooks/useVisitedChannelsTracker.js";import{useRouterHashBridge as C}from"./hooks/useRouterHashBridge.js";import{useScrollSpyUrlSync as D}from"./hooks/useScrollSpyUrlSync.js";import{useTelemetryPageMetrics as V}from"./hooks/useTelemetryPageMetrics.js";import{useInitialTelemetry as j}from"./hooks/useInitialTelemetry.js";import{EntryPage as I}from"./pages/EntryPage.js";import{ErrorBoundary as k}from"./components/ErrorBoundary.js";import{compose as B}from"./utils/compose.js";import{withRouter as M}from"./hoc/withRouter.js";import{withStoreProvider as N}from"./hoc/withStoreProvider.js";import{withLicenseGate as O}from"./hoc/withLicenseGate.js";import{withReplayPrefetch as E}from"./hoc/withReplayPrefetch.js";const d=e=>{const{items:t=[],basePath:s,markdownAdapter:y,telemetryConfig:r}=e,{routeIndex:h}=w(t,s),m=S(A),i=r?.specType,c=r?.collectorUrl,p=r?.serviceName,n=r?.serviceVersion,l=r?.disabled,a=r?.typeOfUsage,g=v(()=>new R({specType:i??m,collectorUrl:c,serviceName:p,serviceVersion:n,disabled:l,typeOfUsage:a}),[m,i,c,p,n,l,a]);return o(P,{value:y,children:f(b.Provider,{value:g,children:[o(G,{}),o(H,{routeIndex:h,basePath:s})]})})};function G(){return U(),C(),D(),null}const H=({routeIndex:e,basePath:t})=>(V(),j(),f(k,{children:[o(x,{}),o(I,{routeIndex:e,basePath:t})]})),u=B(N,M,T,e=>O(e),e=>E(e,{respectHideReplay:!0}))(d);var pe=u;export{u as RedoclyApiDocs,d as RedoclyApiDocsComponent,pe as default};
1
+ import{Fragment as T,jsx as o,jsxs as f}from"react/jsx-runtime";import{memo as v,useMemo as S}from"react";import{useAtomValue as x}from"jotai";import{GlobalStyle as R}from"@redocly/theme/core/openapi";import{RedocTelemetry as b}from"./telemetry/RedocTelemetry.js";import{TelemetryContext as P}from"./contexts/telemetry.js";import{MarkdownAdapterProvider as A}from"./contexts/markdownAdapter.js";import{specTypeAtom as w}from"./jotai/store.js";import{useApiDocsRoutes as U}from"./hooks/useApiDocsRoutes.js";import{useVisitedChannelsTracker as C}from"./hooks/useVisitedChannelsTracker.js";import{useRouterHashBridge as D}from"./hooks/useRouterHashBridge.js";import{useScrollSpyUrlSync as V}from"./hooks/useScrollSpyUrlSync.js";import{useTelemetryPageMetrics as j}from"./hooks/useTelemetryPageMetrics.js";import{useInitialTelemetry as I}from"./hooks/useInitialTelemetry.js";import{EntryPage as k}from"./pages/EntryPage.js";import{ErrorBoundary as B}from"./components/ErrorBoundary.js";import{compose as M}from"./utils/compose.js";import{withRouter as N}from"./hoc/withRouter.js";import{withStoreProvider as O}from"./hoc/withStoreProvider.js";import{withLicenseGate as _}from"./hoc/withLicenseGate.js";import{withReplayPrefetch as E}from"./hoc/withReplayPrefetch.js";const d=e=>{const{items:t=[],basePath:m,markdownAdapter:y,telemetryConfig:r}=e,{routeIndex:g}=U(t,m),s=x(w),i=r?.specType,c=r?.collectorUrl,p=r?.serviceName,n=r?.serviceVersion,l=r?.disabled,a=r?.typeOfUsage,h=S(()=>new b({specType:i??s,collectorUrl:c,serviceName:p,serviceVersion:n,disabled:l,typeOfUsage:a}),[s,i,c,p,n,l,a]);return o(A,{value:y,children:f(P.Provider,{value:h,children:[o(F,{}),o(G,{routeIndex:g,basePath:m})]})})};function F(){return C(),D(),V(),null}const G=({routeIndex:e,basePath:t})=>(j(),I(),f(T,{children:[o(R,{}),o(B,{children:o(k,{routeIndex:e,basePath:t})})]})),u=M(O,N,v,e=>_(e),e=>E(e,{respectHideReplay:!0}))(d);var ne=u;export{u as RedoclyApiDocs,d as RedoclyApiDocsComponent,ne as default};
@@ -1 +1 @@
1
- import{REDOCLY_TEAMS_RBAC as J}from"@redocly/config";import{contentType as me,itemVariant as ue,nodeTypes as h,panelKind as z,schemaKind as B}from"../../../../types/common.js";import{readRbacScope as C,rbacProp as R,registerExample as W,pickRenderableDescription as te,registerSchema as H,resolveContent as G,resolveRef as $}from"../../../helpers.js";import{applyIgnoreNamedSchemasDeep as se}from"../../utils/applyIgnoreNamedSchemasDeep.js";import{isStatusCode as ye}from"../../../../utils/status-code.js";import{parseMarkdown as _}from"../../../utils/parseMarkdown.js";import{extractDescriptionSegments as he,resolveMarkdocHeadingIds as Q}from"../../../utils/markdoc.js";import{getExtensionsForDisplay as Z}from"../../../../utils/extract-extensions.js";import{openApiContext as M}from"../../buildContext.js";import{buildCodeSampleSource as fe}from"../../build-code-sample-source.js";import{pickOperationServers as be}from"../../utils/merge-mock-server.js";import{mergeInMockServer as xe}from"../../utils/merge-mock-server.js";import{normalizePath as Se}from"../../../../utils/url.js";import{toRelativePath as ne}from"../../../../utils/url.js";import{encodeJsonPointerSegment as N}from"../../../../utils/refPointer.js";import{hasOpenApiExampleValue as re,resolveOpenApiExampleValue as ee}from"../../resolve-openapi-example-value.js";const X="request",oe="responses",ie="callbacks";function Te(){const e=new Map;return(r,s)=>{const o=`${r}/${s}`,n=e.get(o)??0;return e.set(o,n+1),n===0?o:`${o}~${n}`}}function Ue(e,r){const{options:s,storeCtx:o,basePath:n}=M.get(),t=e.summary||e.operationId||e.pathName||"Unknown Operation",c=[],{feedback:l}=s,i=e.isWebhook||!1,p=[{nodeType:h.HEADER,level:2,label:t,badges:e["x-badges"],isWebhook:i,deprecated:e.deprecated,showPageActions:!0}],a=Z(e,s.showExtensions);Object.keys(a).length>0&&p.push({nodeType:h.EXTENSIONS,extensions:a}),c.push({nodeType:h.CONTAINER,children:p,panels:[]});const m=s.ignoreNamedSchemas,y=e["x-codeSamples"]?.map(({lang:u,label:I,source:L})=>({lang:u,label:I,source:L}));let b=be(e.servers,o?.document?.servers).filter(u=>typeof u?.url=="string");b=xe(b,s.mockServer);const f=b.map(u=>{const I=C(u);return{url:u.url??"",name:u.name,description:typeof u.description=="string"?u.description:void 0,...u.isMockServer&&{isMockServer:!0},variables:u.variables&&Object.keys(u.variables).length>0?Object.fromEntries(Object.entries(u.variables).map(([L,V])=>[L,{default:V.default}])):void 0,...R(I)}}),x=ae(e,m),d=ne(r,n);let E=[];e.description&&(Q(e.description,d,X),E=he(e.description,s));const g=E.some(u=>u.kind==="schemaDefinition"),S=x.find(u=>u.nodeType===h.ITEM&&u.variant==="body"),q=qe(e,m,i,d||void 0),O=S?.schemaId,k=S?.mediaTypes,j=S?.mediaTypeSchemas,v=C(S),A=[{children:[{kind:z.CODE_SAMPLE,source:q,definitionSamples:y?.length?y:void 0,isWebhook:i,hideReplay:e["x-hideReplay"]===!0,servers:f?.length?f:void 0,schemaId:O,exampleIds:S?.exampleIds,mediaTypes:k,mediaTypeSchemas:j,examples:S?.exampleIds?.map(()=>({}))??[]}],...R(v)}];if(x.length>0||E.length>0)if(g){c.push({nodeType:h.CONTAINER,children:[{nodeType:h.HEADER,level:4,label:"Request",labelTranslationKey:"request",deepLinkSuffix:X}],panels:[]});for(const u of E)u.kind==="schemaDefinition"?c.push(u.node):c.push({nodeType:h.CONTAINER,children:[u.node],panels:[]});c.push({nodeType:h.CONTAINER,children:[...x],panels:A})}else c.push({nodeType:h.CONTAINER,children:[{nodeType:h.HEADER,level:4,label:"Request",labelTranslationKey:"request",deepLinkSuffix:X},...E.map(u=>u.node),...x],panels:A});else c.push({nodeType:h.CONTAINER,children:[{nodeType:h.HEADER,level:4,label:"Request",labelTranslationKey:"request",deepLinkSuffix:X},{nodeType:h.EMPTY_MESSAGE,label:"No request data",labelTranslationKey:"noRequestData"}],panels:A});if(e.responses){const u=de(e,s,d,m);if(u){const I=u.responses?.some(P=>P.schemaId||(P.exampleIds?.length??0)>0),L=u?.responses?.map(P=>{const le=P[J];return{code:P.code,schemaId:P.schemaId,exampleIds:P.exampleIds,mediaTypes:P.mediaTypes,mediaTypeContent:P.mediaTypeContent,...R(le)}}),V=[];I&&V.push({children:[{kind:z.RESPONSE,responseCodes:L,examples:[]}]});const pe=C(e.responses);c.push({nodeType:h.CONTAINER,children:[{nodeType:h.HEADER,level:4,label:"Responses",labelTranslationKey:"responses",deepLinkSuffix:"responses"},u],panels:V.length>0?V:[],...R(pe)})}}Array.isArray(e.callbacks)&&e.callbacks.length>0&&c.push(...Ee(e,d,m)),l?.hide!==!0&&c.push({nodeType:h.CONTAINER,children:[{nodeType:h.FEEDBACK,pageSlug:Se(ne(r,n))}],panels:[]});const D=x.some(u=>{const I=u;return I.variant==="body"&&((I.exampleIds?.length??0)>0||!!I.schemaId)})||(y?.length??0)>0;return{contentType:me.ITEM,itemVariant:ue.HTTP_ITEM,seo:e["x-seo"],meta:{sourceId:e.operationId,name:t,deprecated:e.deprecated,isWebhook:e.isWebhook||!1,pointer:e.pointer,hasSamples:D},children:c}}function Ee(e,r,s){const o=[{nodeType:h.CONTAINER,children:[{nodeType:h.HEADER,level:4,label:"Callbacks",labelTranslationKey:"callbacks",deepLinkSuffix:ie}],panels:[]}],n=Te();for(const t of e.callbacks??[])if(t.operations)for(const c of t.operations){const l=c.httpVerb??"post",i=n(t.name,l);o.push(Ce(e,t,c,i,r,s))}return o}function Ce(e,r,s,o,n,t){const{options:c}=M.get(),l=s.httpVerb??"post",i={pointer:e.pointer+"/callbacks/"+r.name+"/"+l,pathName:s.pathName??r.url??"",httpVerb:l,summary:s.summary,deprecated:s.deprecated,isWebhook:!1,isAdditionalOperation:!1,tags:[],parameters:s.parameters,requestBody:s.requestBody,responses:s.responses,servers:s.servers,security:s.security},p=ae(i,t),a=de(i,c,`${n}/callbacks/${o}`,t),m=[...p];a&&m.push(a);const y=s.externalDocs,T=Z(s,c.showExtensions);let b;s.description&&(b=_(s.description,c),Q(b??[],n,`${ie}/${o}`));const f={httpVerb:l,pathName:i.pathName,summary:i.summary,operationId:typeof s.operationId=="string"?s.operationId:void 0,description:b,deprecated:i.deprecated,callbackName:r.name,callbackId:o,externalDocs:y?{url:y.url,description:y.description}:void 0,extensions:Object.keys(T).length>0?T:void 0,contentChildren:m.length>0?m:void 0},x=ge(s,i,o,t),d=C(r);return{nodeType:h.CONTAINER,children:[{nodeType:h.ITEM,variant:"callback",callback:f,pointer:e.pointer+"/callbacks"}],panels:x,...R(d)}}function ge(e,r,s,o){const{storeCtx:n}=M.get(),t=[];if(!e.requestBody||!("content"in e.requestBody))return t;const c=n?.document??{},l=$(c,e.requestBody,o)??e.requestBody,i=G(c,l,o);if(!i)return t;const p=Object.keys(i);let a=!1;const m={};for(const[f,x]of Object.entries(i)){let d;if(x.schema){const S=x.schema;d=H(n.schemaStore,n.hashIndex,{kind:B.JSON_SCHEMA,data:S})}const E=`${r.pointer}/requestBody/content/${N(f)}`.replace(/^\//,""),g=[];if(x.example!==void 0){const S=W(n.exampleStore,{value:x.example,id:`${E}/example`});g.push(S),a=!0}if(x.examples)for(const[S,q]of Object.entries(x.examples)){const O=$(c,q,o);if(O&&re(O)){const k=W(n.exampleStore,{value:ee(O),summary:O.summary??S,description:te(O.description),id:`${E}/examples/${N(S)}`});g.push(k),a=!0}}m[f]={schemaId:d,exampleIds:g.length>0?g:void 0},d&&(a=!0)}const y=e["x-codeSamples"];if(!(a||(y?.length??0)>0))return t;const b=e.servers?.filter(f=>f.url).map(({url:f,name:x,description:d,variables:E})=>({url:f,name:x,description:d,variables:E}));return t.push({children:[{kind:z.CALLBACK_PAYLOAD,callbackName:s,path:r.pathName,httpVerb:r.httpVerb,servers:b?.length?b:void 0,definitionSamples:y,mediaTypes:p.length>0?p:void 0,mediaTypeSchemas:Object.keys(m).length>0?m:void 0,examples:[]}]}),t}function Oe(e,r,s){const o=$(r,e,s)??e,{$ref:n,...t}=e,c=typeof n=="string"?{...o,...t}:o;return se(c,s)}function F(e,r,s){if(!e||typeof e!="object")return;const o=e,n=$(r,o,s)??o;return se(n,s)}function Re(e,r,s){if(!e||typeof e!="object")return;const o=C(e),n={},t=[];for(const[c,l]of Object.entries(e)){if(c===J)continue;const i=$(r,l,s)??l,p=i.content,a=p?p[Object.keys(p)[0]]:void 0,m=i.schema??a?.schema??a?.itemSchema,y=F(m,r,s);if(!y)continue;const T=ce(i.examples,r,s),b=C(l)??C(i)??o;n[c]={...y,...i.description!==void 0&&{description:i.description},...i.example!==void 0&&{example:i.example},...T&&{examples:T},...R(b)},i.required&&t.push(c)}if(Object.keys(n).length!==0)return{type:"object",properties:n,...t.length>0?{required:t}:{}}}function Ae(e){if(typeof e=="string"||e&&typeof e=="object"&&"$$mdtype"in e||Array.isArray(e)&&e.length>0&&e.every(r=>!!r&&typeof r=="object"&&"$$mdtype"in r))return e}function U(e,r){const{storeCtx:s,options:o}=M.get(),n=s.document;return e.map(t=>{const c=t.schema;let l={};if(c&&typeof c=="object")l=c;else if(t.content&&typeof t.content=="object"){const T=t.content,b=Object.keys(T)[0],f=b?T[b]?.schema:void 0;f&&typeof f=="object"&&(l=f)}const i=H(s.schemaStore,s.hashIndex,{kind:B.JSON_SCHEMA,data:l}),p=t["x-badges"],a=l["x-badges"],m=Array.isArray(p)?p:Array.isArray(a)?a:void 0,y=Z(t,o.showExtensions);return{name:String(t.name??""),in:typeof t.in=="string"?t.in:void 0,schemaId:i,description:Ae(t.description),required:t.required===!0?!0:void 0,deprecated:t.deprecated===!0?!0:void 0,example:t.example,examples:ce(t.examples,n,r),...m?.length?{badges:m}:{},...Object.keys(y).length?{extensions:y}:{},...R(C(t))}})}function ce(e,r,s){if(!e||typeof e!="object")return;const o={};for(const[n,t]of Object.entries(e)){if(!t||typeof t!="object")continue;const c=$(r,t,s)??t;if(!re(c))continue;const l=ee(c);o[n]={...typeof c.summary=="string"&&{summary:c.summary},...typeof c.description=="string"&&{description:c.description},...l!==void 0&&{value:typeof l=="string"?l:JSON.stringify(l)}}}return Object.keys(o).length>0?o:void 0}function ae(e,r){const{storeCtx:s,options:o}=M.get(),n=[],t=s.document,c=ve(e);if(c&&n.push(c),e.parameters&&Array.isArray(e.parameters)){const i=e.parameters.map(d=>Oe(d,t,r)),p=i.filter(d=>d.in==="header"),a=i.filter(d=>d.in==="query"),m=i.filter(d=>d.in==="path"),y=i.filter(d=>d.in==="cookie"),T=i.filter(d=>d.in==="querystring"),b=T.filter(d=>!d.content||typeof d.content!="object"),f=T.filter(d=>d.content&&typeof d.content=="object"),x=T.length>0;m.length>0&&n.push({nodeType:h.ITEM,variant:"path",label:"Path",labelTranslationKey:"path",parameters:U(m,r),pointer:e.pointer+"/parameters"}),a.length>0&&!x&&n.push({nodeType:h.ITEM,variant:"query",label:"Query",labelTranslationKey:"query",parameters:U(a,r),pointer:e.pointer+"/parameters"}),b.length>0&&n.push({nodeType:h.ITEM,variant:"querystring",label:"Query String",labelTranslationKey:"querystring",parameters:U(b,r),pointer:e.pointer+"/parameters"});for(const d of f){const E=d.content,g=Object.keys(E),S={};for(const j of g){const v=E[j];if(!v)continue;let A;const K=v.itemSchema,w=v.schema??K,D=F(w,t,r);D&&(A=H(s.schemaStore,s.hashIndex,{kind:B.JSON_SCHEMA,data:D}));const u=Y(v,r);S[j]={schemaId:A,exampleIds:u,...R(C(w))}}const q=g[0],O=q?S[q]:void 0,k=_(d.description,o);n.push({nodeType:h.ITEM,variant:"querystring-body",label:String(d.name??""),required:d.required===!0?!0:void 0,mediaTypes:g.length>0?g:void 0,mediaTypeSchemas:Object.keys(S).length>0?S:void 0,schemaId:O?.schemaId,exampleIds:O?.exampleIds,pointer:e.pointer+"/parameters",...k!==void 0?{description:k}:{},...R(C(d))})}y.length>0&&n.push({nodeType:h.ITEM,variant:"cookies",label:"Cookies",labelTranslationKey:"cookie",parameters:U(y,r),pointer:e.pointer+"/parameters"}),p.length>0&&n.push({nodeType:h.ITEM,variant:"headers",label:"Headers",labelTranslationKey:"header",parameters:U(p,r),pointer:e.pointer+"/parameters"})}if(e.requestBody){const l=$(t,e.requestBody,r)??e.requestBody,i=G(t,l,r),p=i?Object.keys(i):void 0;let a,m,y;if(i&&p){y={};for(const d of p){const E=i[d];if(!E)continue;let g;const S=E.itemSchema,q=E.schema??S,O=F(q,t,r);O&&(g=H(s.schemaStore,s.hashIndex,{kind:B.JSON_SCHEMA,data:O}));const k=Y(E,r,`${e.pointer}/requestBody/content/${N(d)}`);y[d]={schemaId:g,exampleIds:k,...R(C(q))}}const f=p[0],x=f?y[f]:void 0;a=x?.schemaId,m=x?.exampleIds}const T=_(l.description,o),b=C(e.requestBody)??C(l);n.push({nodeType:h.ITEM,variant:"body",label:"Request Body",labelTranslationKey:"body",required:l.required,mediaTypes:p,mediaTypeSchemas:y,schemaId:a,exampleIds:m,pointer:e.pointer+"/requestBody",...T!==void 0?{description:T}:{},...R(b)})}return n}function de(e,r,s,o){if(!e.responses)return;const{storeCtx:n}=M.get(),t=n?.document??{},c=e.responses,i=Object.entries(c).filter(([p])=>ye(p)).map(([p,a])=>{const m=$(t,a,o)??a;let y=C(a)??C(m);const T=G(t,m,o),b=T?Object.keys(T):[],f=b[0],x=f&&T?T[f]:void 0;let d,E,g,S;if(T&&b.length>0){S={};for(const v of b){const A=T[v];if(!A)continue;let K;const w=A.itemSchema,D=A.schema??w,u=F(D,t,o);u&&(K=H(n.schemaStore,n.hashIndex,{kind:B.JSON_SCHEMA,data:u}));const I=Y(A,o,`${e.pointer}/responses/${N(p)}/content/${N(v)}`);S[v]={schemaId:K,exampleIds:I,...R(C(D))}}const j=f?S[f]:void 0;d=j?.schemaId,E=j?.exampleIds}else if(x){const j=x.itemSchema,v=x.schema??j,A=F(v,t,o);A&&(y=y??C(v),d=H(n.schemaStore,n.hashIndex,{kind:B.JSON_SCHEMA,data:A})),E=Y(x,o,f?`${e.pointer}/responses/${N(p)}/content/${N(f)}`:void 0)}const q=Re(m.headers,t,o);q&&(g=H(n.schemaStore,n.hashIndex,{kind:B.JSON_SCHEMA,data:q}));let O;m.description&&(O=_(m.description,r),Q(O??[],s,`${oe}/${p}`));const k=m["x-summary"]?_(m["x-summary"],r):void 0;return k&&Q(k,s,`${oe}/${p}/summary`),{code:p,summary:k,description:O,mediaType:f,mediaTypes:b.length>0?b:void 0,mediaTypeContent:S,schemaId:d,exampleIds:E,headers:m.headers,headerSchemaId:g,...R(y)}});return{nodeType:h.ITEM,variant:"responses",responses:i,pointer:e.pointer+"/responses"}}function Y(e,r,s){const{storeCtx:o}=M.get(),n=[],t=o.document,c=s?.replace(/^\//,"");if(e.example!==void 0){const l=W(o.exampleStore,{value:e.example,...c&&{id:`${c}/example`}});n.push(l)}if(e.examples&&typeof e.examples=="object"){const l=C(e.examples);for(const[i,p]of Object.entries(e.examples)){if(i===J||!p||typeof p!="object")continue;const a=$(t,p,r)??p,m=C(p)??C(a)??l,y=W(o.exampleStore,{value:ee(a),key:i,summary:typeof a.summary=="string"?a.summary:i,description:te(a.description),externalValue:typeof a.externalValue=="string"?a.externalValue:void 0,...R(m),...c&&{id:`${c}/examples/${N(i)}`}});n.push(y)}}return n.length>0?n:void 0}function ve(e){const{storeCtx:r,options:s}=M.get();if(!e.security||!Array.isArray(e.security)||e.security.length===0)return;const o=e.security.map(n=>{const t=Object.entries(n);if(t.length===0)return null;const c=r?.document?.components?.securitySchemes,l=t.map(([i,p])=>{const a=r?.securitySchemeStore[i],m=C(c?.[i])??a?.[J];return{name:i,scopes:Array.isArray(p)?p:void 0,type:a?.type,scheme:a?.scheme,bearerFormat:a?.bearerFormat,in:a?.in,paramName:a?.paramName,description:a?.description?_(a.description,s):a?.description,openIdConnectUrl:a?.openIdConnectUrl,oauth2MetadataUrl:a?.oauth2MetadataUrl,deprecated:a?.deprecated,flows:a?.flows,...R(m)}}).filter(i=>i.name);return l.length>0?{schemes:l}:null}).filter(n=>n!==null);if(o.length!==0)return{nodeType:h.SECURITY,requirements:o}}function qe(e,r,s,o){const{storeCtx:n}=M.get(),{options:t}=M.get();if(!n)throw new Error("OpenAPI store context is not initialized");return fe(e,n,r,s,o,t)}export{Ue as buildItemContent,Te as createCallbackIdFactory};
1
+ import{REDOCLY_TEAMS_RBAC as J}from"@redocly/config";import{contentType as me,itemVariant as ue,nodeTypes as h,panelKind as z,schemaKind as B}from"../../../../types/common.js";import{readRbacScope as C,rbacProp as O,registerExample as W,pickRenderableDescription as te,registerSchema as H,resolveContent as G,resolveRef as N}from"../../../helpers.js";import{applyIgnoreNamedSchemasDeep as se}from"../../utils/applyIgnoreNamedSchemasDeep.js";import{isStatusCode as ye}from"../../../../utils/status-code.js";import{parseMarkdown as _}from"../../../utils/parseMarkdown.js";import{extractDescriptionSegments as he,isMarkdocAst as fe,resolveMarkdocHeadingIds as Q}from"../../../utils/markdoc.js";import{getExtensionsForDisplay as Z}from"../../../../utils/extract-extensions.js";import{openApiContext as M}from"../../buildContext.js";import{buildCodeSampleSource as be}from"../../build-code-sample-source.js";import{pickOperationServers as xe}from"../../utils/merge-mock-server.js";import{mergeInMockServer as Se}from"../../utils/merge-mock-server.js";import{normalizePath as Te}from"../../../../utils/url.js";import{toRelativePath as ne}from"../../../../utils/url.js";import{encodeJsonPointerSegment as D}from"../../../../utils/refPointer.js";import{hasOpenApiExampleValue as re,resolveOpenApiExampleValue as ee}from"../../resolve-openapi-example-value.js";const X="request",oe="responses",ie="callbacks";function Ee(){const e=new Map;return(c,s)=>{const r=`${c}/${s}`,n=e.get(r)??0;return e.set(r,n+1),n===0?r:`${r}~${n}`}}function Je(e,c){const{options:s,storeCtx:r,basePath:n}=M.get(),t=e.summary||e.operationId||e.pathName||"Unknown Operation",i=[],{feedback:l}=s,o=e.isWebhook||!1,p=[{nodeType:h.HEADER,level:2,label:t,badges:e["x-badges"],isWebhook:o,deprecated:e.deprecated,showPageActions:!0}],a=Z(e,s.showExtensions);Object.keys(a).length>0&&p.push({nodeType:h.EXTENSIONS,extensions:a}),i.push({nodeType:h.CONTAINER,children:p,panels:[]});const m=s.ignoreNamedSchemas,y=e["x-codeSamples"]?.map(({lang:u,label:I,source:L})=>({lang:u,label:I,source:L}));let b=xe(e.servers,r?.document?.servers).filter(u=>typeof u?.url=="string");b=Se(b,s.mockServer);const f=b.map(u=>{const I=C(u);return{url:u.url??"",name:u.name,description:typeof u.description=="string"?u.description:void 0,...u.isMockServer&&{isMockServer:!0},variables:u.variables&&Object.keys(u.variables).length>0?Object.fromEntries(Object.entries(u.variables).map(([L,V])=>[L,{default:V.default}])):void 0,...O(I)}}),x=ae(e,m),d=ne(c,n);let E=[];e.description&&(Q(e.description,d,X),E=he(e.description,s));const g=E.some(u=>u.kind==="schemaDefinition"),S=x.find(u=>u.nodeType===h.ITEM&&u.variant==="body"),q=ke(e,m,o,d||void 0),v=S?.schemaId,k=S?.mediaTypes,j=S?.mediaTypeSchemas,A=C(S),R=[{children:[{kind:z.CODE_SAMPLE,source:q,definitionSamples:y?.length?y:void 0,isWebhook:o,hideReplay:e["x-hideReplay"]===!0,servers:f?.length?f:void 0,schemaId:v,exampleIds:S?.exampleIds,mediaTypes:k,mediaTypeSchemas:j,examples:S?.exampleIds?.map(()=>({}))??[]}],...O(A)}];if(x.length>0||E.length>0)if(g){i.push({nodeType:h.CONTAINER,children:[{nodeType:h.HEADER,level:4,label:"Request",labelTranslationKey:"request",deepLinkSuffix:X}],panels:[]});for(const u of E)u.kind==="schemaDefinition"?i.push(u.node):i.push({nodeType:h.CONTAINER,children:[u.node],panels:[]});i.push({nodeType:h.CONTAINER,children:[...x],panels:R})}else i.push({nodeType:h.CONTAINER,children:[{nodeType:h.HEADER,level:4,label:"Request",labelTranslationKey:"request",deepLinkSuffix:X},...E.map(u=>u.node),...x],panels:R});else i.push({nodeType:h.CONTAINER,children:[{nodeType:h.HEADER,level:4,label:"Request",labelTranslationKey:"request",deepLinkSuffix:X},{nodeType:h.EMPTY_MESSAGE,label:"No request data",labelTranslationKey:"noRequestData"}],panels:R});if(e.responses){const u=de(e,s,d,m);if(u){const I=u.responses?.some(P=>P.schemaId||(P.exampleIds?.length??0)>0),L=u?.responses?.map(P=>{const le=P[J];return{code:P.code,schemaId:P.schemaId,exampleIds:P.exampleIds,mediaTypes:P.mediaTypes,mediaTypeContent:P.mediaTypeContent,...O(le)}}),V=[];I&&V.push({children:[{kind:z.RESPONSE,responseCodes:L,examples:[]}]});const pe=C(e.responses);i.push({nodeType:h.CONTAINER,children:[{nodeType:h.HEADER,level:4,label:"Responses",labelTranslationKey:"responses",deepLinkSuffix:"responses"},u],panels:V.length>0?V:[],...O(pe)})}}Array.isArray(e.callbacks)&&e.callbacks.length>0&&i.push(...Ce(e,d,m)),l?.hide!==!0&&i.push({nodeType:h.CONTAINER,children:[{nodeType:h.FEEDBACK,pageSlug:Te(ne(c,n))}],panels:[]});const $=x.some(u=>{const I=u;return I.variant==="body"&&((I.exampleIds?.length??0)>0||!!I.schemaId)})||(y?.length??0)>0;return{contentType:me.ITEM,itemVariant:ue.HTTP_ITEM,seo:e["x-seo"],meta:{sourceId:e.operationId,name:t,deprecated:e.deprecated,isWebhook:e.isWebhook||!1,pointer:e.pointer,hasSamples:$},children:i}}function Ce(e,c,s){const r=[{nodeType:h.CONTAINER,children:[{nodeType:h.HEADER,level:4,label:"Callbacks",labelTranslationKey:"callbacks",deepLinkSuffix:ie}],panels:[]}],n=Ee();for(const t of e.callbacks??[])if(t.operations)for(const i of t.operations){const l=i.httpVerb??"post",o=n(t.name,l);r.push(ge(e,t,i,o,c,s))}return r}function ge(e,c,s,r,n,t){const{options:i}=M.get(),l=s.httpVerb??"post",o={pointer:e.pointer+"/callbacks/"+c.name+"/"+l,pathName:s.pathName??c.url??"",httpVerb:l,summary:s.summary,deprecated:s.deprecated,isWebhook:!1,isAdditionalOperation:!1,tags:[],parameters:s.parameters,requestBody:s.requestBody,responses:s.responses,servers:s.servers,security:s.security},p=ae(o,t),a=de(o,i,`${n}/callbacks/${r}`,t),m=[...p];a&&m.push(a);const y=s.externalDocs,T=Z(s,i.showExtensions);let b;s.description&&(b=_(s.description,i),Q(b??[],n,`${ie}/${r}`));const f={httpVerb:l,pathName:o.pathName,summary:o.summary,operationId:typeof s.operationId=="string"?s.operationId:void 0,description:b,deprecated:o.deprecated,callbackName:c.name,callbackId:r,externalDocs:y?{url:y.url,description:y.description}:void 0,extensions:Object.keys(T).length>0?T:void 0,contentChildren:m.length>0?m:void 0},x=ve(s,o,r,t),d=C(c);return{nodeType:h.CONTAINER,children:[{nodeType:h.ITEM,variant:"callback",callback:f,pointer:e.pointer+"/callbacks"}],panels:x,...O(d)}}function ve(e,c,s,r){const{storeCtx:n}=M.get(),t=[];if(!e.requestBody||!("content"in e.requestBody))return t;const i=n?.document??{},l=N(i,e.requestBody,r)??e.requestBody,o=G(i,l,r);if(!o)return t;const p=Object.keys(o);let a=!1;const m={};for(const[f,x]of Object.entries(o)){let d;if(x.schema){const S=x.schema;d=H(n.schemaStore,n.hashIndex,{kind:B.JSON_SCHEMA,data:S})}const E=`${c.pointer}/requestBody/content/${D(f)}`.replace(/^\//,""),g=[];if(x.example!==void 0){const S=W(n.exampleStore,{value:x.example,id:`${E}/example`});g.push(S),a=!0}if(x.examples)for(const[S,q]of Object.entries(x.examples)){const v=N(i,q,r);if(v&&re(v)){const k=W(n.exampleStore,{value:ee(v),summary:v.summary??S,description:te(v.description),id:`${E}/examples/${D(S)}`});g.push(k),a=!0}}m[f]={schemaId:d,exampleIds:g.length>0?g:void 0},d&&(a=!0)}const y=e["x-codeSamples"];if(!(a||(y?.length??0)>0))return t;const b=e.servers?.filter(f=>f.url).map(({url:f,name:x,description:d,variables:E})=>({url:f,name:x,description:d,variables:E}));return t.push({children:[{kind:z.CALLBACK_PAYLOAD,callbackName:s,path:c.pathName,httpVerb:c.httpVerb,servers:b?.length?b:void 0,definitionSamples:y,mediaTypes:p.length>0?p:void 0,mediaTypeSchemas:Object.keys(m).length>0?m:void 0,examples:[]}]}),t}function Oe(e,c,s){const r=N(c,e,s)??e,{$ref:n,...t}=e,i=typeof n=="string"?{...r,...t}:r;return se(i,s)}function F(e,c,s){if(!e||typeof e!="object")return;const r=e,n=N(c,r,s)??r;return se(n,s)}function Re(e,c,s){if(!e||typeof e!="object")return;const r=C(e),n={},t=[];for(const[i,l]of Object.entries(e)){if(i===J)continue;const o=N(c,l,s)??l,p=o.content,a=p?p[Object.keys(p)[0]]:void 0,m=o.schema??a?.schema??a?.itemSchema,y=F(m,c,s);if(!y)continue;const T=ce(o.examples,c,s),b=C(l)??C(o)??r;n[i]={...y,...o.description!==void 0&&{description:o.description},...o.example!==void 0&&{example:o.example},...T&&{examples:T},...O(b)},o.required&&t.push(i)}if(Object.keys(n).length!==0)return{type:"object",properties:n,...t.length>0?{required:t}:{}}}function Ae(e){return typeof e=="string"||fe(e)?e:void 0}function U(e,c){const{storeCtx:s,options:r}=M.get(),n=s.document;return e.map(t=>{const i=t.schema;let l={};if(i&&typeof i=="object")l=i;else if(t.content&&typeof t.content=="object"){const T=t.content,b=Object.keys(T)[0],f=b?T[b]?.schema:void 0;f&&typeof f=="object"&&(l=f)}const o=H(s.schemaStore,s.hashIndex,{kind:B.JSON_SCHEMA,data:l}),p=t["x-badges"],a=l["x-badges"],m=Array.isArray(p)?p:Array.isArray(a)?a:void 0,y=Z(t,r.showExtensions);return{name:String(t.name??""),in:typeof t.in=="string"?t.in:void 0,schemaId:o,description:Ae(t.description),required:t.required===!0?!0:void 0,deprecated:t.deprecated===!0?!0:void 0,example:t.example,examples:ce(t.examples,n,c),...m?.length?{badges:m}:{},...Object.keys(y).length?{extensions:y}:{},...O(C(t))}})}function ce(e,c,s){if(!e||typeof e!="object")return;const r={};for(const[n,t]of Object.entries(e)){if(!t||typeof t!="object")continue;const i=N(c,t,s)??t;if(!re(i))continue;const l=ee(i);r[n]={...typeof i.summary=="string"&&{summary:i.summary},...typeof i.description=="string"&&{description:i.description},...l!==void 0&&{value:typeof l=="string"?l:JSON.stringify(l)}}}return Object.keys(r).length>0?r:void 0}function ae(e,c){const{storeCtx:s,options:r}=M.get(),n=[],t=s.document,i=qe(e);if(i&&n.push(i),e.parameters&&Array.isArray(e.parameters)){const o=e.parameters.map(d=>Oe(d,t,c)),p=o.filter(d=>d.in==="header"),a=o.filter(d=>d.in==="query"),m=o.filter(d=>d.in==="path"),y=o.filter(d=>d.in==="cookie"),T=o.filter(d=>d.in==="querystring"),b=T.filter(d=>!d.content||typeof d.content!="object"),f=T.filter(d=>d.content&&typeof d.content=="object"),x=T.length>0;m.length>0&&n.push({nodeType:h.ITEM,variant:"path",label:"Path",labelTranslationKey:"path",parameters:U(m,c),pointer:e.pointer+"/parameters"}),a.length>0&&!x&&n.push({nodeType:h.ITEM,variant:"query",label:"Query",labelTranslationKey:"query",parameters:U(a,c),pointer:e.pointer+"/parameters"}),b.length>0&&n.push({nodeType:h.ITEM,variant:"querystring",label:"Query String",labelTranslationKey:"querystring",parameters:U(b,c),pointer:e.pointer+"/parameters"});for(const d of f){const E=d.content,g=Object.keys(E),S={};for(const j of g){const A=E[j];if(!A)continue;let R;const K=A.itemSchema,w=A.schema??K,$=F(w,t,c);$&&(R=H(s.schemaStore,s.hashIndex,{kind:B.JSON_SCHEMA,data:$}));const u=Y(A,c);S[j]={schemaId:R,exampleIds:u,...O(C(w))}}const q=g[0],v=q?S[q]:void 0,k=_(d.description,r);n.push({nodeType:h.ITEM,variant:"querystring-body",label:String(d.name??""),required:d.required===!0?!0:void 0,mediaTypes:g.length>0?g:void 0,mediaTypeSchemas:Object.keys(S).length>0?S:void 0,schemaId:v?.schemaId,exampleIds:v?.exampleIds,pointer:e.pointer+"/parameters",...k!==void 0?{description:k}:{},...O(C(d))})}y.length>0&&n.push({nodeType:h.ITEM,variant:"cookies",label:"Cookies",labelTranslationKey:"cookie",parameters:U(y,c),pointer:e.pointer+"/parameters"}),p.length>0&&n.push({nodeType:h.ITEM,variant:"headers",label:"Headers",labelTranslationKey:"header",parameters:U(p,c),pointer:e.pointer+"/parameters"})}if(e.requestBody){const l=N(t,e.requestBody,c)??e.requestBody,o=G(t,l,c),p=o?Object.keys(o):void 0;let a,m,y;if(o&&p){y={};for(const d of p){const E=o[d];if(!E)continue;let g;const S=E.itemSchema,q=E.schema??S,v=F(q,t,c);v&&(g=H(s.schemaStore,s.hashIndex,{kind:B.JSON_SCHEMA,data:v}));const k=Y(E,c,`${e.pointer}/requestBody/content/${D(d)}`);y[d]={schemaId:g,exampleIds:k,...O(C(q))}}const f=p[0],x=f?y[f]:void 0;a=x?.schemaId,m=x?.exampleIds}const T=_(l.description,r),b=C(e.requestBody)??C(l);n.push({nodeType:h.ITEM,variant:"body",label:"Request Body",labelTranslationKey:"body",required:l.required,mediaTypes:p,mediaTypeSchemas:y,schemaId:a,exampleIds:m,pointer:e.pointer+"/requestBody",...T!==void 0?{description:T}:{},...O(b)})}return n}function de(e,c,s,r){if(!e.responses)return;const{storeCtx:n}=M.get(),t=n?.document??{},i=e.responses,o=Object.entries(i).filter(([p])=>ye(p)).map(([p,a])=>{const m=N(t,a,r)??a;let y=C(a)??C(m);const T=G(t,m,r),b=T?Object.keys(T):[],f=b[0],x=f&&T?T[f]:void 0;let d,E,g,S;if(T&&b.length>0){S={};for(const A of b){const R=T[A];if(!R)continue;let K;const w=R.itemSchema,$=R.schema??w,u=F($,t,r);u&&(K=H(n.schemaStore,n.hashIndex,{kind:B.JSON_SCHEMA,data:u}));const I=Y(R,r,`${e.pointer}/responses/${D(p)}/content/${D(A)}`);S[A]={schemaId:K,exampleIds:I,...O(C($))}}const j=f?S[f]:void 0;d=j?.schemaId,E=j?.exampleIds}else if(x){const j=x.itemSchema,A=x.schema??j,R=F(A,t,r);R&&(y=y??C(A),d=H(n.schemaStore,n.hashIndex,{kind:B.JSON_SCHEMA,data:R})),E=Y(x,r,f?`${e.pointer}/responses/${D(p)}/content/${D(f)}`:void 0)}const q=Re(m.headers,t,r);q&&(g=H(n.schemaStore,n.hashIndex,{kind:B.JSON_SCHEMA,data:q}));let v;m.description&&(v=_(m.description,c),Q(v??[],s,`${oe}/${p}`));const k=m["x-summary"]?_(m["x-summary"],c):void 0;return k&&Q(k,s,`${oe}/${p}/summary`),{code:p,summary:k,description:v,mediaType:f,mediaTypes:b.length>0?b:void 0,mediaTypeContent:S,schemaId:d,exampleIds:E,headers:m.headers,headerSchemaId:g,...O(y)}});return{nodeType:h.ITEM,variant:"responses",responses:o,pointer:e.pointer+"/responses"}}function Y(e,c,s){const{storeCtx:r}=M.get(),n=[],t=r.document,i=s?.replace(/^\//,"");if(e.example!==void 0){const l=W(r.exampleStore,{value:e.example,...i&&{id:`${i}/example`}});n.push(l)}if(e.examples&&typeof e.examples=="object"){const l=C(e.examples);for(const[o,p]of Object.entries(e.examples)){if(o===J||!p||typeof p!="object")continue;const a=N(t,p,c)??p,m=C(p)??C(a)??l,y=W(r.exampleStore,{value:ee(a),key:o,summary:typeof a.summary=="string"?a.summary:o,description:te(a.description),externalValue:typeof a.externalValue=="string"?a.externalValue:void 0,...O(m),...i&&{id:`${i}/examples/${D(o)}`}});n.push(y)}}return n.length>0?n:void 0}function qe(e){const{storeCtx:c,options:s}=M.get();if(!e.security||!Array.isArray(e.security)||e.security.length===0)return;const r=e.security.map(n=>{const t=Object.entries(n);if(t.length===0)return null;const i=c?.document?.components?.securitySchemes,l=t.map(([o,p])=>{const a=c?.securitySchemeStore[o],m=C(i?.[o])??a?.[J];return{name:o,scopes:Array.isArray(p)?p:void 0,type:a?.type,scheme:a?.scheme,bearerFormat:a?.bearerFormat,in:a?.in,paramName:a?.paramName,description:a?.description?_(a.description,s):a?.description,openIdConnectUrl:a?.openIdConnectUrl,oauth2MetadataUrl:a?.oauth2MetadataUrl,deprecated:a?.deprecated,flows:a?.flows,...O(m)}}).filter(o=>o.name);return l.length>0?{schemes:l}:null}).filter(n=>n!==null);if(r.length!==0)return{nodeType:h.SECURITY,requirements:r}}function ke(e,c,s,r){const{storeCtx:n}=M.get(),{options:t}=M.get();if(!n)throw new Error("OpenAPI store context is not initialized");return be(e,n,c,s,r,t)}export{Je as buildItemContent,Ee as createCallbackIdFactory};
@@ -0,0 +1,6 @@
1
+ import type { Node } from '@markdoc/markdoc';
2
+ /**
3
+ * Serializes a Markdoc AST back into markdown source. Node types outside the registries below
4
+ * fall back to their text content. See `brain/markdown-parser-and-adapter.md`.
5
+ */
6
+ export declare function descriptionToMarkdown(description: string | Node | Node[] | undefined | null): string | undefined;
@@ -0,0 +1,11 @@
1
+ import{collectTextContent as s}from"./markdoc.js";function j(t){if(!t)return;if(typeof t=="string")return t||void 0;const n=Array.isArray(t)?t:[t];return a(n)||void 0}function f(t){return Object.assign(Object.create(null),t)}const b=f({document:t=>a(t.children??[]),paragraph:t=>i(t.children??[]),heading:t=>{const n=typeof t.attributes?.level=="number"?t.attributes.level:1;return`${"#".repeat(n)} ${i(t.children??[])}`},fence:t=>{const n=String(t.attributes?.content??"").replace(/\n$/,"");return`\`\`\`${typeof t.attributes?.language=="string"?t.attributes.language:""}
2
+ ${n}
3
+ \`\`\``},list:m,blockquote:t=>h(a(t.children??[]),"> "),table:$,hr:()=>"---"}),d=f({text:t=>String(t.attributes?.content??""),softbreak:()=>`
4
+ `,hardbreak:()=>`
5
+ `,inline:t=>i(t.children??[]),code:t=>`\`${String(t.attributes?.content??"")}\``,link:t=>{const n=String(t.attributes?.href??""),r=t.attributes?.title,e=typeof r=="string"&&r?` "${r}"`:"";return`[${i(t.children??[])}](${n}${e})`},image:t=>{const n=String(t.attributes?.src??"");return`![${typeof t.attributes?.alt=="string"?t.attributes.alt:""}](${n})`},strong:t=>o(t.children??[],l(t,"**")),em:t=>o(t.children??[],l(t,"_")),s:t=>o(t.children??[],l(t,"~~"))});function a(t){return t.map(p).filter(n=>n.length>0).join(`
6
+
7
+ `)}function p(t){const n=b[t.type];return n?n(t):i(t.children??[])||s(t)}function m(t){const n=t.attributes?.ordered===!0;return(t.children??[]).map((r,e)=>{const u=n?`${e+1}. `:"- ",c=a(r.children??[]);return h(c,u," ".repeat(u.length))}).join(`
8
+ `)}function $(t){const n=[];let r=0;for(const e of t.children??[])for(const u of e.children??[]){const c=(u.children??[]).map(g=>i(g.children??[]));r=Math.max(r,c.length),n.push(c),e.type==="thead"&&n.push([])}return n.map(e=>e.length===0?`| ${Array.from({length:r},()=>"---").join(" | ")} |`:`| ${e.join(" | ")} |`).join(`
9
+ `)}function i(t){return t.map(y).join("")}function y(t){const n=d[t.type];if(n)return n(t);const r=t.children??[];return r.length>0?i(r):s(t)}function l(t,n){return typeof t.attributes?.marker=="string"?t.attributes.marker:n}function o(t,n){return`${n}${i(t)}${n}`}function h(t,n,r=n){return t.split(`
10
+ `).map((e,u)=>{const c=u===0?n:r;return e?`${c}${e}`:c.trimEnd()}).join(`
11
+ `)}export{j as descriptionToMarkdown};
@@ -36,6 +36,9 @@ export declare function extractFullText(ast: Node | Node[] | string): string;
36
36
  export declare function extractFirstParagraphText(ast: Node | Node[] | string, maxLength?: number): string | undefined;
37
37
  export declare function extractSummaryText(description: string | Node | Node[] | undefined | null, options?: ParseMarkdownOptions): string | undefined;
38
38
  export declare function extractSeoDescriptionText(description: string | Node | Node[] | undefined | null, options?: ParseMarkdownOptions): string | undefined;
39
+ /** One Markdoc node, or a non-empty list of them. */
40
+ export declare function isMarkdocAst(value: unknown): value is Node | Node[];
41
+ export declare function collectTextContent(node: Node): string;
39
42
  export declare function collectMarkdownPlainText(ast: Node | Node[] | string): string;
40
43
  export declare function unescapeHTMLChars(str: string): string;
41
44
  export declare function sanitizeMarkdownSource(source: string, options?: MarkdownSanitizeOptions): string;
@@ -1 +1 @@
1
- import{contentType as v,itemVariant as N,nodeTypes as u}from"../../types/common.js";import{safeSlugify as x}from"../../utils/string.js";import{parseMarkdown as p}from"./parseMarkdown.js";import{isPlainText as k}from"./isPlainText.js";import{joinWithSeparator as a}from"../../utils/url.js";import{buildDeepLinkUrl as O}from"../../utils/deep-link.js";import{getDOMPurify as E}from"./dompurify.js";function L(t){return t.type==="tag"&&t.tag==="schemaDefinition"}const W=/^[ \t]{0,3}#{1,6}[ \t]/m;function M(t){const r=t.search(W);return r===-1?t:t.slice(0,r)}function X(t,r){if(typeof t=="string"){const n=M(t).trim();if(k(n))return n}const e=p(t,r);if(!e)return;if(typeof e=="string")return e;if(Array.isArray(e)){const n=e.findIndex(o=>o.type==="heading");return n===-1?e:e.slice(0,n)}if(!e.children||!Array.isArray(e.children))return;const i=e.children.findIndex(n=>n.type==="heading");return i===-1?[e]:(e.children=e.children.slice(0,i),[e])}function Y(t,r,{sliceAtFirstHeading:e=!1}={}){if(typeof t=="string"&&e){const f=M(t).trim();if(k(f))return[{kind:"markdoc",node:{nodeType:u.MARKDOC,content:f}}]}const i=p(t,r);if(!i)return[];if(typeof i=="string")return[{kind:"markdoc",node:{nodeType:u.MARKDOC,content:i}}];let n=Array.isArray(i)?i:i.children??[];if(e){const f=n.findIndex(d=>d.type==="heading");f!==-1&&(n=n.slice(0,f))}const o=[];let c=[];const l=()=>{c.length>0&&(o.push({kind:"markdoc",node:{nodeType:u.MARKDOC,content:c}}),c=[])};for(const f of n)L(f)?(l(),o.push({kind:"schemaDefinition",node:{nodeType:u.MARKDOC,content:[f]}})):c.push(f);return l(),o}function _(t,r,e){const i=t.toLowerCase(),n=i.startsWith("section/")?i.slice(8):i,o=r.toLowerCase();let c=n!==o?n:"";return e&&(c=a(e,c)),c}function S(t,...r){let e=t.toLowerCase();for(const i of r){const n=i?`${i.toLowerCase()}/`:"";n&&`${e}/`.startsWith(n)&&(e=e.slice(n.length))}return e}function J(t,r,e){if(typeof t=="string")return;const i=n=>{if(n.type==="heading"&&n.attributes?.level){const o=n.attributes.id?S(n.attributes.id,r,e):x(m(n).trim()).toLowerCase();if(o){const c=_(o,r,e);n.attributes.id=a(r,c).toLowerCase(),n.attributes.deepLinkHash=O("",r,c)}}for(const o of n.children??[])i(o)};if(Array.isArray(t))for(const n of t)i(n);else i(t)}function H(t,r,e,i){const n=p(t,r);if(!n)return[];if(typeof n=="string")return[];const o=[];let c;const l=(s,h,R=o,y,A)=>{s=z(s);const T=A!==void 0,C=T?A:e;let g;y.attributes.id?g=S(y.attributes.id,C):T||i?g=x(s):g=`section/${x(s)}`;const I=a(C,g).toLowerCase();y.attributes.id=I;const b={id:I,name:s,level:h,items:[],ast:[y]};return R.push(b),b},f=s=>{if(typeof s?.attributes?.content=="string")return s.attributes.content;if(s?.children)return f(s.children[0])},d=s=>{const h=f(s)||"";s.type==="heading"&&s.attributes?.level===1?c=l(h,s.attributes.level,void 0,s):s.attributes?.level?l(h,s.attributes.level,c?.items,s,c?.id):c?.items?.length?c.items[c.items.length-1]?.ast?.push(s):o.length&&o[o.length-1]?.ast?.push(s)};if(Array.isArray(n))for(const s of n)d(s);else if(n.children)for(const s of n.children)d(s);return o}function K({heading:t,basePath:r}){const e=t.items.length>0,i=a(r,t.id).toLowerCase(),n=e?t.items.map(o=>K({heading:o,basePath:r})):[];return{type:e?"group":"link",label:t.name,link:i,routeSlug:i,items:e?n:void 0,content:P(t)}}function Q(t,r,e){const i=[],n=[];for(const o of H(t,e,"")){const{item:c,children:l}=w(o,r);i.push(c),n.push(...l)}return{sectionItems:i,sectionChildren:n}}function w(t,r){const e=a(r,t.id),i=t.items.length>0,n=t.ast?.length?[V(t.ast,a(r,t.id))]:[],o=[];for(const l of t.items){const{item:f,children:d}=w(l,r);o.push(f);const s=a(r,l.id);n.push({nodeType:u.OVERVIEW_SECTION_WRAPPER,children:d,sectionId:s})}return{item:{type:i?"group":"link",label:t.name,link:e,routeSlug:e,items:i?o:void 0,content:null},children:n}}function Z(t){return typeof t=="string"?t.trim():Array.isArray(t)?t.map(r=>m(r)).filter(Boolean).join(" ").trim():m(t).trim()}function D(t,r=50){if(typeof t=="string"){const o=t.split(/\n[ \t]*\n/)[0].replace(/\s+/g," ").trim();return o?o.substring(0,r):void 0}const i=(Array.isArray(t)?t:t.children??[t])[0];if(!i)return;const n=m(i);return n?n.substring(0,r):void 0}function tt(t,r){if(!t)return;const e=p(t,r);if(!e)return;const i=D(e);return i?i.length===50?i+"\u2026":i:void 0}function et(t,r){if(!t)return;const e=p(t,r);if(e)return D(e,Number.POSITIVE_INFINITY)}function m(t){const r=[];function e(i){typeof i.attributes?.content=="string"&&r.push(i.attributes.content);for(const n of i.children??[])e(n)}return e(t),r.join("")}function nt(t){return typeof t=="string"?t.trim():(Array.isArray(t)?t:[t]).map(e=>m(e)).join("").trim()}function z(t){return t.replace(/&#(\d+);/g,(r,e)=>String.fromCharCode(parseInt(e,10))).replace(/"/g,'"').replace(/&/g,"&")}function rt(t,r){const{sanitize:e}=r??{},{unstable_hooks:i}=r??{};return i?.sanitize?i.sanitize(t):e?E().sanitize(t):t}function P(t){const r=[];return t.ast&&t.ast.length>0&&r.push({nodeType:u.MARKDOC,content:t.ast}),{contentType:v.ITEM,itemVariant:N.MARKDOWN,meta:{name:t.name},children:[{nodeType:u.CONTAINER,children:r,panels:[]}]}}function V(t,r){return{nodeType:u.OVERVIEW_SECTION_WRAPPER,children:[{nodeType:u.MARKDOC,content:t}],sectionId:r}}export{K as buildMarkdownSectionItem,nt as collectMarkdownPlainText,Q as collectMarkdownSections,X as extractContentUntilFirstHeading,Y as extractDescriptionSegments,D as extractFirstParagraphText,Z as extractFullText,H as extractMarkdownSections,et as extractSeoDescriptionText,tt as extractSummaryText,_ as resolveMarkdocHeadingDeepSuffix,J as resolveMarkdocHeadingIds,rt as sanitizeMarkdownSource,z as unescapeHTMLChars};
1
+ import{contentType as O,itemVariant as E,nodeTypes as l}from"../../types/common.js";import{safeSlugify as x}from"../../utils/string.js";import{parseMarkdown as p}from"./parseMarkdown.js";import{isPlainText as b}from"./isPlainText.js";import{joinWithSeparator as a}from"../../utils/url.js";import{buildDeepLinkUrl as L}from"../../utils/deep-link.js";import{getDOMPurify as v}from"./dompurify.js";function W(t){return t.type==="tag"&&t.tag==="schemaDefinition"}const _=/^[ \t]{0,3}#{1,6}[ \t]/m;function M(t){const r=t.search(_);return r===-1?t:t.slice(0,r)}function Y(t,r){if(typeof t=="string"){const n=M(t).trim();if(b(n))return n}const e=p(t,r);if(!e)return;if(typeof e=="string")return e;if(Array.isArray(e)){const n=e.findIndex(o=>o.type==="heading");return n===-1?e:e.slice(0,n)}if(!e.children||!Array.isArray(e.children))return;const i=e.children.findIndex(n=>n.type==="heading");return i===-1?[e]:(e.children=e.children.slice(0,i),[e])}function J(t,r,{sliceAtFirstHeading:e=!1}={}){if(typeof t=="string"&&e){const f=M(t).trim();if(b(f))return[{kind:"markdoc",node:{nodeType:l.MARKDOC,content:f}}]}const i=p(t,r);if(!i)return[];if(typeof i=="string")return[{kind:"markdoc",node:{nodeType:l.MARKDOC,content:i}}];let n=Array.isArray(i)?i:i.children??[];if(e){const f=n.findIndex(d=>d.type==="heading");f!==-1&&(n=n.slice(0,f))}const o=[];let c=[];const u=()=>{c.length>0&&(o.push({kind:"markdoc",node:{nodeType:l.MARKDOC,content:c}}),c=[])};for(const f of n)W(f)?(u(),o.push({kind:"schemaDefinition",node:{nodeType:l.MARKDOC,content:[f]}})):c.push(f);return u(),o}function H(t,r,e){const i=t.toLowerCase(),n=i.startsWith("section/")?i.slice(8):i,o=r.toLowerCase();let c=n!==o?n:"";return e&&(c=a(e,c)),c}function S(t,...r){let e=t.toLowerCase();for(const i of r){const n=i?`${i.toLowerCase()}/`:"";n&&`${e}/`.startsWith(n)&&(e=e.slice(n.length))}return e}function Q(t,r,e){if(typeof t=="string")return;const i=n=>{if(n.type==="heading"&&n.attributes?.level){const o=n.attributes.id?S(n.attributes.id,r,e):x(m(n).trim()).toLowerCase();if(o){const c=H(o,r,e);n.attributes.id=a(r,c).toLowerCase(),n.attributes.deepLinkHash=L("",r,c)}}for(const o of n.children??[])i(o)};if(Array.isArray(t))for(const n of t)i(n);else i(t)}function K(t,r,e,i){const n=p(t,r);if(!n)return[];if(typeof n=="string")return[];const o=[];let c;const u=(s,h,R=o,y,A)=>{s=P(s);const T=A!==void 0,C=T?A:e;let g;y.attributes.id?g=S(y.attributes.id,C):T||i?g=x(s):g=`section/${x(s)}`;const I=a(C,g).toLowerCase();y.attributes.id=I;const k={id:I,name:s,level:h,items:[],ast:[y]};return R.push(k),k},f=s=>{if(typeof s?.attributes?.content=="string")return s.attributes.content;if(s?.children)return f(s.children[0])},d=s=>{const h=f(s)||"";s.type==="heading"&&s.attributes?.level===1?c=u(h,s.attributes.level,void 0,s):s.attributes?.level?u(h,s.attributes.level,c?.items,s,c?.id):c?.items?.length?c.items[c.items.length-1]?.ast?.push(s):o.length&&o[o.length-1]?.ast?.push(s)};if(Array.isArray(n))for(const s of n)d(s);else if(n.children)for(const s of n.children)d(s);return o}function z({heading:t,basePath:r}){const e=t.items.length>0,i=a(r,t.id).toLowerCase(),n=e?t.items.map(o=>z({heading:o,basePath:r})):[];return{type:e?"group":"link",label:t.name,link:i,routeSlug:i,items:e?n:void 0,content:V(t)}}function Z(t,r,e){const i=[],n=[];for(const o of K(t,e,"")){const{item:c,children:u}=w(o,r);i.push(c),n.push(...u)}return{sectionItems:i,sectionChildren:n}}function w(t,r){const e=a(r,t.id),i=t.items.length>0,n=t.ast?.length?[j(t.ast,a(r,t.id))]:[],o=[];for(const u of t.items){const{item:f,children:d}=w(u,r);o.push(f);const s=a(r,u.id);n.push({nodeType:l.OVERVIEW_SECTION_WRAPPER,children:d,sectionId:s})}return{item:{type:i?"group":"link",label:t.name,link:e,routeSlug:e,items:i?o:void 0,content:null},children:n}}function tt(t){return typeof t=="string"?t.trim():Array.isArray(t)?t.map(r=>m(r)).filter(Boolean).join(" ").trim():m(t).trim()}function D(t,r=50){if(typeof t=="string"){const o=t.split(/\n[ \t]*\n/)[0].replace(/\s+/g," ").trim();return o?o.substring(0,r):void 0}const i=(Array.isArray(t)?t:t.children??[t])[0];if(!i)return;const n=m(i);return n?n.substring(0,r):void 0}function et(t,r){if(!t)return;const e=p(t,r);if(!e)return;const i=D(e);return i?i.length===50?i+"\u2026":i:void 0}function nt(t,r){if(!t)return;const e=p(t,r);if(e)return D(e,Number.POSITIVE_INFINITY)}function N(t){return!!t&&typeof t=="object"&&"$$mdtype"in t}function rt(t){return Array.isArray(t)?t.length>0&&t.every(N):N(t)}function m(t){const r=[];function e(i){typeof i.attributes?.content=="string"&&r.push(i.attributes.content);for(const n of i.children??[])e(n)}return e(t),r.join("")}function it(t){return typeof t=="string"?t.trim():(Array.isArray(t)?t:[t]).map(e=>m(e)).join("").trim()}function P(t){return t.replace(/&#(\d+);/g,(r,e)=>String.fromCharCode(parseInt(e,10))).replace(/"/g,'"').replace(/&/g,"&")}function ot(t,r){const{sanitize:e}=r??{},{unstable_hooks:i}=r??{};return i?.sanitize?i.sanitize(t):e?v().sanitize(t):t}function V(t){const r=[];return t.ast&&t.ast.length>0&&r.push({nodeType:l.MARKDOC,content:t.ast}),{contentType:O.ITEM,itemVariant:E.MARKDOWN,meta:{name:t.name},children:[{nodeType:l.CONTAINER,children:r,panels:[]}]}}function j(t,r){return{nodeType:l.OVERVIEW_SECTION_WRAPPER,children:[{nodeType:l.MARKDOC,content:t}],sectionId:r}}export{z as buildMarkdownSectionItem,it as collectMarkdownPlainText,Z as collectMarkdownSections,m as collectTextContent,Y as extractContentUntilFirstHeading,J as extractDescriptionSegments,D as extractFirstParagraphText,tt as extractFullText,K as extractMarkdownSections,nt as extractSeoDescriptionText,et as extractSummaryText,rt as isMarkdocAst,H as resolveMarkdocHeadingDeepSuffix,Q as resolveMarkdocHeadingIds,ot as sanitizeMarkdownSource,P as unescapeHTMLChars};
@@ -1 +1,66 @@
1
- import{jsx as o,jsxs as s}from"react/jsx-runtime";import{Component as a}from"react";import{TelemetryContext as i}from"../contexts/telemetry.js";class h extends a{static contextType=i;constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error("[api-docs] Rendering error:",e,t.componentStack);const r=this.context;try{r.sendErrorMessage([{id:"errorBoundaryCatch",object:"error",uri:typeof window<"u"?window.location.href:"",...r.typeOfUsage?{typeOfUsage:r.typeOfUsage}:{},details:{message:e.message,stack:t.componentStack??void 0}}])}catch(n){console.error("[api-docs] error telemetry failed:",n)}}render(){return this.state.hasError?this.props.fallback?this.props.fallback:s("div",{role:"alert",style:{padding:"20px",color:"#c00"},children:[o("h2",{children:"Something went wrong rendering the API documentation."}),s("details",{style:{whiteSpace:"pre-wrap",marginTop:"10px"},children:[o("summary",{children:"Error details"}),this.state.error?.message]})]}):this.props.children}}export{h as ErrorBoundary};
1
+ import{jsx as e,jsxs as i}from"react/jsx-runtime";import{Component as s}from"react";import{styled as r}from"styled-components";import{breakpoints as l}from"@redocly/theme/core/openapi";import{TelemetryContext as c}from"../contexts/telemetry.js";class z extends s{static contextType=c;constructor(t){super(t),this.state={hasError:!1,error:null}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,a){console.error("[api-docs] Rendering error:",t,a.componentStack);const o=this.context;try{o.sendErrorMessage([{id:"errorBoundaryCatch",object:"error",uri:typeof window<"u"?window.location.href:"",...o.typeOfUsage?{typeOfUsage:o.typeOfUsage}:{},details:{message:t.message,stack:a.componentStack??void 0}}])}catch(n){console.error("[api-docs] error telemetry failed:",n)}}render(){return this.state.hasError?this.props.fallback?this.props.fallback:e(p,{role:"alert",className:"api-docs-error-page",children:i(d,{children:[e(h,{children:"Error"}),e(g,{children:"Something went wrong rendering the API documentation."}),i(f,{children:[e("summary",{children:"Error details"}),e(m,{children:this.state.error?.message})]}),e(x,{children:e(v,{type:"button",onClick:()=>window.location.reload(),children:"Reload page"})})]})}):this.props.children}}const p=r.div`
2
+ box-sizing: border-box;
3
+ min-height: calc(100vh - var(--navbar-height, 0px) - var(--banner-height, 0px));
4
+ min-height: calc(100dvh - var(--navbar-height, 0px) - var(--banner-height, 0px));
5
+ background: var(--bg-color, #ffffff);
6
+ font-family: var(--font-family-base, system-ui, sans-serif);
7
+ color: var(--text-color-primary, #1a1c21);
8
+ `,d=r.div`
9
+ display: flex;
10
+ flex-direction: column;
11
+ justify-content: center;
12
+ box-sizing: border-box;
13
+ min-height: inherit;
14
+ max-width: 620px;
15
+ margin: 0 calc(var(--spacing-xxl, 48px) * 2);
16
+ padding: var(--spacing-xl, 32px) 0;
17
+
18
+ @media screen and (max-width: ${l.small}) {
19
+ margin: 0 var(--spacing-lg, 24px);
20
+ }
21
+ `,h=r.div`
22
+ color: var(--text-color-helper, #6e6f7a);
23
+ font-family: var(--font-family-monospaced, monospace);
24
+ font-size: var(--font-size-lg, 16px);
25
+ line-height: var(--line-height-lg, 24px);
26
+ font-weight: var(--font-weight-semibold, 600);
27
+ `,g=r.h1`
28
+ margin: var(--spacing-xs, 8px) 0 0;
29
+ color: var(--text-color-primary, #1a1c21);
30
+ font-size: 32px;
31
+ line-height: 40px;
32
+ font-weight: var(--font-weight-bold, 700);
33
+ `,f=r.details`
34
+ margin: var(--spacing-lg, 24px) 0 0;
35
+ color: var(--text-color-secondary, #3b3c45);
36
+ font-size: var(--font-size-lg, 16px);
37
+ line-height: var(--line-height-lg, 24px);
38
+
39
+ summary {
40
+ cursor: pointer;
41
+ }
42
+ `,m=r.div`
43
+ margin-top: var(--spacing-xs, 8px);
44
+ font-family: var(--font-family-monospaced, monospace);
45
+ white-space: pre-wrap;
46
+ overflow-wrap: anywhere;
47
+ `,x=r.div`
48
+ margin-top: var(--spacing-xl, 32px);
49
+ `,v=r.button`
50
+ display: inline-flex;
51
+ align-items: center;
52
+ padding: 5px var(--spacing-base, 16px);
53
+ border: none;
54
+ border-radius: var(--border-radius-lg, 8px);
55
+ background: var(--button-bg-color-primary, #3e63dd);
56
+ color: #ffffff;
57
+ font-family: inherit;
58
+ font-size: var(--font-size-base, 14px);
59
+ line-height: var(--line-height-base, 22px);
60
+ font-weight: var(--font-weight-semibold, 600);
61
+ cursor: pointer;
62
+
63
+ &:hover {
64
+ filter: brightness(1.08);
65
+ }
66
+ `;export{z as ErrorBoundary};
@@ -1 +1 @@
1
- import{useContext as d,useMemo as l}from"react";import{useAtomValue as p}from"jotai";import{exampleStoreAtom as h,generatedExampleAtom as x,buildExampleAtomKey as S}from"../../jotai/examples.js";import{convertSampleToString as g}from"../../services/code-samples/index.js";import{isSequentialMediaType as A}from"../../utils/media-type.js";import{schemaStoreAtom as C}from"../../jotai/schema.js";import{buildOpenApiSectionSuffix as E,extractDeepLinkParamFromHash as L,hashIsForItem as b,hashIsInsideCallback as k,hashIsOutsideCallbacks as v,hashToElementId as I}from"../../utils/deep-link.js";import{ItemIdContext as D,useCallbackScope as P}from"../../hooks/useDeepLinkSection.js";import{useUrlHash as w}from"../../hooks/useUrlHash.js";import{routingBasePathAtom as y}from"../../jotai/store.js";import{useDeepLinkUrl as B}from"../../hooks/useDeepLinkSection.js";import{toRelativePath as F}from"../../utils/url.js";function H(e){const t=p(h);return!e||e.length===0?[]:e.map(o=>t[o]).filter(Boolean)}function N(e,t,o,n){const i=H(t),a=d(D)??"",r=n?.toLowerCase(),s=e?S(e,o,n,a):"",f=p(x(s)),u=p(C);if(i.length>0){if(r&&A(r)){const m=e?u[e]?.data:void 0;return i.map(c=>typeof c.value=="string"?c.value:g(c.value,r,m))}return i.map(m=>m.value)}return f!==void 0?[f]:[]}function Q(e,t){const o=l(()=>e?E("response",t,e):"",[e,t]);return B(o)}function W(e,t,o){const n=w(),i=p(y),a=P();return l(()=>{if(!e)return;const r=I(n),s=F(e,i).toLowerCase();if(!b(r,s)||!(a?k(r,s,a):v(r,s)))return;const u=L(n,o);if(u)return t?.find(m=>m.toLowerCase()===u)},[n,e,t,o,i,a])}export{H as useExampleEntries,W as useKeyFromHash,N as useResolvedExamples,Q as useResponseSectionDeepLink};
1
+ import{useContext as d,useMemo as l}from"react";import{useAtomValue as p}from"jotai";import{exampleStoreAtom as h,generatedExampleAtom as x,buildExampleAtomKey as S}from"../../jotai/examples.js";import{convertSampleToString as g}from"../../services/code-samples/index.js";import{isSequentialMediaType as A}from"../../utils/media-type.js";import{schemaStoreAtom as E}from"../../jotai/schema.js";import{buildOpenApiSectionSuffix as C,extractDeepLinkParamFromHash as I,hashIsForItem as L,hashIsInsideCallback as b,hashIsOutsideCallbacks as k,hashToElementId as v}from"../../utils/deep-link.js";import{ItemIdContext as D,useCallbackScope as w}from"../../hooks/useDeepLinkSection.js";import{useUrlHash as y}from"../../hooks/useUrlHash.js";import{routingBasePathAtom as B}from"../../jotai/store.js";import{useDeepLinkUrl as F}from"../../hooks/useDeepLinkSection.js";import{toElementId as H}from"../../utils/url.js";function K(e){const t=p(h);return!e||e.length===0?[]:e.map(o=>t[o]).filter(Boolean)}function N(e,t,o,n){const i=K(t),s=d(D)??"",r=n?.toLowerCase(),a=e?S(e,o,n,s):"",f=p(x(a)),u=p(E);if(i.length>0){if(r&&A(r)){const m=e?u[e]?.data:void 0;return i.map(c=>typeof c.value=="string"?c.value:g(c.value,r,m))}return i.map(m=>m.value)}return f!==void 0?[f]:[]}function Q(e,t){const o=l(()=>e?C("response",t,e):"",[e,t]);return F(o)}function W(e,t,o){const n=y(),i=p(B),s=w();return l(()=>{if(!e)return;const r=v(n),a=(H(e,i)??"").toLowerCase();if(!L(r,a)||!(s?b(r,a,s):k(r,a)))return;const u=I(n,o);if(u)return t?.find(m=>m.toLowerCase()===u)},[n,e,t,o,i,s])}export{K as useExampleEntries,W as useKeyFromHash,N as useResolvedExamples,Q as useResponseSectionDeepLink};
@@ -1 +1 @@
1
- import{jsx as o}from"react/jsx-runtime";import{Markdown as n}from"../common/Markdown.js";import{Description as t}from"./styled.js";function i(r){return!!r&&typeof r=="object"&&"$$mdtype"in r}function s({value:r}){return r?typeof r=="string"||typeof r=="number"||typeof r=="boolean"?o(t,{children:o(n,{source:String(r)})}):i(r)||Array.isArray(r)&&r.every(e=>i(e))?o(t,{children:o(n,{source:r})}):null:null}export{s as SchemaDescription};
1
+ import{jsx as o}from"react/jsx-runtime";import{Markdown as t}from"../common/Markdown.js";import{isMarkdocAst as n}from"../../adapters/utils/markdoc.js";import{Description as i}from"./styled.js";function s({value:r}){return r?typeof r=="string"||typeof r=="number"||typeof r=="boolean"?o(i,{children:o(t,{source:String(r)})}):n(r)?o(i,{children:o(t,{source:r})}):null:null}export{s as SchemaDescription};
@@ -1,17 +1,17 @@
1
- import{jsx as o}from"react/jsx-runtime";import{memo as f,useCallback as v}from"react";import{styled as t,css as a}from"styled-components";import{Link as g}from"react-router";import{useUrlHash as k}from"../../hooks/useUrlHash.js";import{useAtomValue as u}from"jotai";import{LinkIcon as b}from"@redocly/theme/icons/LinkIcon/LinkIcon";import{ClipboardService as x}from"@redocly/theme/core/openapi";import{globalOptionsAtom as y}from"../../jotai/store.js";import{hashToElementId as l}from"../../utils/deep-link.js";function A({to:i,label:s,variant:c="heading"}){const{onDeepLinkClick:e}=u(y),p=k({trackSilentReplaces:!0}),r=i.split("#")[1],m=!!r&&l(p)===l(r),d=v(h=>{x.copyCustom(`${window.location.origin}${i}`),e&&(h.preventDefault(),e(i))},[e,i]);return o(C,{className:"deep-link-anchor","data-deep-link-anchor":!0,children:o(L,{$variant:c,to:i,"aria-label":s??`link to ${i}`,"aria-current":m?"location":void 0,onClick:d,children:o(b,{color:"--heading-anchor-color"})})})}const j=f(A),n="data-deep-link-anchor",w=`
2
- & [${n}] svg {
1
+ import{jsx as o}from"react/jsx-runtime";import{memo as f,useCallback as v}from"react";import{styled as a,css as l}from"styled-components";import{Link as g}from"react-router";import{useUrlHash as k}from"../../hooks/useUrlHash.js";import{useAtomValue as u}from"jotai";import{LinkIcon as b}from"@redocly/theme/icons/LinkIcon/LinkIcon";import{ClipboardService as x}from"@redocly/theme/core/openapi";import{globalOptionsAtom as y}from"../../jotai/store.js";import{hashToElementId as s}from"../../utils/deep-link.js";function A({to:e,label:c,variant:p="heading"}){const{onDeepLinkClick:i}=u(y),m=k({trackSilentReplaces:!0}),t=e.split("#")[1],d=!!t&&s(m)===s(t),h=v(n=>{x.copyCustom(n.currentTarget.href),i&&(n.preventDefault(),i(e))},[i,e]);return o(C,{className:"deep-link-anchor","data-deep-link-anchor":!0,children:o(L,{$variant:p,to:e,"aria-label":c??`link to ${e}`,"aria-current":d?"location":void 0,onClick:h,children:o(b,{color:"--heading-anchor-color"})})})}const j=f(A),r="data-deep-link-anchor",O=`
2
+ & [${r}] svg {
3
3
  visibility: hidden;
4
4
  }
5
- &:hover [${n}] svg,
6
- & [${n}] a:focus svg {
5
+ &:hover [${r}] svg,
6
+ & [${r}] a:focus svg {
7
7
  visibility: visible;
8
8
  }
9
- `,C=t.span`
9
+ `,C=a.span`
10
10
  position: relative;
11
11
  display: inline-flex;
12
12
  align-items: center;
13
13
  vertical-align: middle;
14
- `,L=t(g)`
14
+ `,L=a(g)`
15
15
  position: absolute;
16
16
  top: 50%;
17
17
  transform: translate(-100%, -50%);
@@ -19,9 +19,9 @@ import{jsx as o}from"react/jsx-runtime";import{memo as f,useCallback as v}from"r
19
19
  display: flex;
20
20
  align-items: center;
21
21
 
22
- ${({$variant:i})=>i==="field"?a`
22
+ ${({$variant:e})=>e==="field"?l`
23
23
  left: -2px;
24
- `:a`
24
+ `:l`
25
25
  left: 0;
26
26
  padding-right: var(--heading-anchor-offset-right, 4px);
27
27
  `}
@@ -29,4 +29,4 @@ import{jsx as o}from"react/jsx-runtime";import{memo as f,useCallback as v}from"r
29
29
  &&[aria-current] svg {
30
30
  visibility: visible;
31
31
  }
32
- `;export{n as DEEP_LINK_ANCHOR_ATTR,j as DeepLinkAnchor,w as deepLinkHoverReveal};
32
+ `;export{r as DEEP_LINK_ANCHOR_ATTR,j as DeepLinkAnchor,O as deepLinkHoverReveal};
@@ -1 +1 @@
1
- import{createContext as i,useContext as u,useMemo as c}from"react";import{useAtomValue as p}from"jotai";import{routingBasePathAtom as a}from"../jotai/store.js";import{buildDeepLinkUrl as I,buildOpenApiSectionSuffix as C,CALLBACKS_SECTION as S}from"../utils/deep-link.js";import{joinWithSeparator as h,toRelativePath as m}from"../utils/url.js";import{useNavigationUrlNormalizer as L}from"./useNormalizeUrl.js";const l=i(void 0),k=i(void 0);function D(){return u(k)}function P(){const t=u(l),e=p(a);return c(()=>t?m(t,e).toLowerCase():"",[t,e])}const U="synthetic-item:",T=i(null);function f(t,e){const o=u(l),r=D(),n=p(a),s=L();return c(()=>{if(!o||o.startsWith(U))return"";const d=n?m(o,n):o,x=e&&r?h(C(S,r),t):t;return s(I(n,d,x))},[o,r,e,n,t,s])}function _(t){return f(t,!0)}function v(t){return f(t,!1)}export{k as CallbackScopeContext,T as DeepLinkSectionContext,l as ItemIdContext,U as SYNTHETIC_ITEM_ID_PREFIX,D as useCallbackScope,_ as useDeepLinkUrl,v as useFieldDeepLinkUrl,P as useHashItemId};
1
+ import{createContext as i,useContext as u,useMemo as c}from"react";import{useAtomValue as m}from"jotai";import{routingBasePathAtom as p}from"../jotai/store.js";import{buildDeepLinkUrl as I,buildOpenApiSectionSuffix as x,CALLBACKS_SECTION as C}from"../utils/deep-link.js";import{joinWithSeparator as S,toElementId as h,toRelativePath as L}from"../utils/url.js";import{useNavigationUrlNormalizer as k}from"./useNormalizeUrl.js";const a=i(void 0),D=i(void 0);function U(){return u(D)}function T(){const t=u(a),e=m(p);return c(()=>t?(h(t,e)??"").toLowerCase():"",[t,e])}const g="synthetic-item:",_=i(null);function l(t,e){const o=u(a),r=U(),n=m(p),s=k();return c(()=>{if(!o||o.startsWith(g))return"";const f=n?L(o,n):o,d=e&&r?S(x(C,r),t):t;return s(I(n,f,d))},[o,r,e,n,t,s])}function v(t){return l(t,!0)}function z(t){return l(t,!1)}export{D as CallbackScopeContext,_ as DeepLinkSectionContext,a as ItemIdContext,g as SYNTHETIC_ITEM_ID_PREFIX,U as useCallbackScope,v as useDeepLinkUrl,z as useFieldDeepLinkUrl,T as useHashItemId};
@@ -1,7 +1,8 @@
1
1
  type Options = {
2
2
  trackSilentReplaces?: boolean;
3
3
  };
4
- /** Current `window.location.hash`. Ignores scroll-spy's silent hash clears (so
5
- * hash-driven state survives) unless `trackSilentReplaces` is set. */
4
+ /** Current URL hash. Under Redoc standalone's hash router (`#/route#deep-link`) only the
5
+ * trailing deep-link part, or `''` when the fragment holds a route alone. Ignores scroll-spy's
6
+ * silent hash clears (so hash-driven state survives) unless `trackSilentReplaces` is set. */
6
7
  export declare function useUrlHash(options?: Options): string;
7
8
  export {};
@@ -1 +1 @@
1
- import{useSyncExternalStore as r}from"react";import{URL_REPLACE_EVENT as s}from"./useRouterHashBridge.js";function o(e){return t=>{if(typeof window>"u")return()=>{};for(const n of e)window.addEventListener(n,t);return()=>{for(const n of e)window.removeEventListener(n,t)}}}const i=o(["hashchange","popstate"]),a=o(["hashchange","popstate",s]);function u(){return typeof window<"u"?window.location.hash:""}function c(){return""}function p(e){return r(e?.trackSilentReplaces?a:i,u,c)}export{p as useUrlHash};
1
+ import{useSyncExternalStore as o}from"react";import{URL_REPLACE_EVENT as s}from"./useRouterHashBridge.js";function r(e){return t=>{if(typeof window>"u")return()=>{};for(const n of e)window.addEventListener(n,t);return()=>{for(const n of e)window.removeEventListener(n,t)}}}const i=r(["hashchange","popstate"]),a=r(["hashchange","popstate",s]);function c(){if(typeof window>"u")return"";const e=window.location.hash;if(!e.startsWith("#/"))return e;const t=e.indexOf("#",1);return t===-1?"":e.slice(t)}function f(){return""}function p(e){return o(e?.trackSilentReplaces?a:i,c,f)}export{p as useUrlHash};
@@ -1 +1,40 @@
1
- import{jsx as e,jsxs as o}from"react/jsx-runtime";import{Link as c,useLocation as i}from"react-router";import{useNormalizeUrl as d}from"../hooks/useNormalizeUrl.js";function m({routingBasePath:n}){const t=i(),a=d(n||"/");return e("div",{className:"not-found-page",children:o("div",{className:"not-found-content",children:[e("h1",{children:"404"}),e("h2",{children:"Page Not Found"}),o("p",{children:["The page ",e("code",{children:t.pathname})," could not be found."]}),e("p",{children:"This documentation page doesn't exist. It may have been moved or deleted."}),e(c,{to:a,className:"back-link",children:"\u2190 Back to API Documentation"})]})})}export{m as NotFoundPage};
1
+ import{jsx as t,jsxs as e}from"react/jsx-runtime";import{useLocation as s}from"react-router";import{styled as a}from"styled-components";import{Button as p}from"@redocly/theme/components/Button/Button";import{ArrowLeftIcon as g}from"@redocly/theme/icons/ArrowLeftIcon/ArrowLeftIcon";import{breakpoints as c}from"@redocly/theme/core/openapi";import{withoutPathPrefix as h}from"@redocly/theme/core/utils";import{useNormalizeUrl as l}from"../hooks/useNormalizeUrl.js";import{useTranslate as m}from"../hooks/useTranslate.js";function T({routingBasePath:i}){const n=s(),r=h(l(i||"/")),o=m();return e(d,{className:"not-found-page",children:[t(f,{children:"404"}),t(v,{children:o("page.apiNotFound.title","No page at this address")}),e(x,{children:[o("page.apiNotFound.description","There's no page at")," ",t(w,{children:n.pathname}),".",t("br",{}),o("page.apiNotFound.hint","It may have been moved or deleted.")]}),t(u,{children:t(p,{variant:"primary",size:"medium",to:r,icon:t(g,{}),children:o("page.apiNotFound.backButton","Back to docs")})})]})}const d=a.div`
2
+ display: flex;
3
+ flex-direction: column;
4
+ justify-content: center;
5
+ box-sizing: border-box;
6
+ min-height: calc(100vh - var(--navbar-height, 0px) - var(--banner-height, 0px));
7
+ min-height: calc(100dvh - var(--navbar-height, 0px) - var(--banner-height, 0px));
8
+ max-width: var(--page-404-max-width);
9
+ margin: 0 var(--page-404-margin-horizontal);
10
+ padding: var(--page-404-margin-vertical) 0;
11
+ font-family: var(--page-404-font-family);
12
+
13
+ @media screen and (max-width: ${c.small}) {
14
+ margin: 0 var(--spacing-lg);
15
+ }
16
+ `,f=a.div`
17
+ color: var(--page-404-status-text-color);
18
+ font-family: var(--font-family-monospaced);
19
+ font-size: var(--page-404-status-font-size);
20
+ line-height: var(--page-404-status-line-height);
21
+ font-weight: var(--page-404-status-font-weight);
22
+ `,v=a.h1`
23
+ margin: var(--spacing-xs) 0 0;
24
+ color: var(--page-404-title-text-color);
25
+ font-size: 32px;
26
+ line-height: 40px;
27
+ font-weight: var(--page-404-title-font-weight);
28
+ `,x=a.p`
29
+ margin: var(--spacing-lg) 0 0;
30
+ color: var(--page-404-description-text-color);
31
+ font-size: var(--font-size-lg);
32
+ line-height: var(--line-height-lg);
33
+ font-weight: var(--page-404-description-font-weight);
34
+ `,u=a.div`
35
+ margin-top: var(--spacing-xl);
36
+ `,w=a.code`
37
+ font-family: var(--font-family-monospaced);
38
+ font-weight: var(--font-weight-bold);
39
+ overflow-wrap: anywhere;
40
+ `;export{T as NotFoundPage};
@@ -34,3 +34,8 @@ export type HARBuildResolvers = {
34
34
  applyDiscriminatorValue?: (sample: unknown, variantSchemaId: string, mappingKey?: string) => void;
35
35
  };
36
36
  export declare function buildCodeSampleHAR(source: CodeSampleSource, selections: HARBuildSelections, options: HARBuildOptions, resolvers: HARBuildResolvers): CodeSampleHAR;
37
+ /**
38
+ * Reducer that mirrors openapi-docs `httpsnippet/helpers/reducer.ts`:
39
+ * collapse duplicate keys into arrays so generators can render them correctly.
40
+ */
41
+ export declare function appendKeyValue(obj: Record<string, string | string[]>, name: string, value: string): void;
@@ -1 +1 @@
1
- import $ from"url-template";import{SecurityVariablesEnvSuffix as g}from"@redocly/theme/core/openapi";import{mergeBodyValue as F}from"../../adapters/openapi/configure/merge-utils.js";import{formUrlEncodeValue as K,stringifyFormFieldValue as E}from"../../utils/form-urlencoded.js";import{isSequentialMediaType as H}from"../../utils/media-type.js";import{parseMultipartFormData as M}from"../../utils/multipart.js";import{objectToHarParams as J}from"../../utils/serialize-querystring.js";import{jsonToXml as L}from"../../utils/xml.js";import{MediaTypes as k}from"../../constants/openapi.js";import{convertSampleToString as Y}from"./convertSampleToString.js";import{findExampleIdByKey as Q,mediaTypeContainingKey as X}from"./example-key.js";import{resolveServerUrl as G}from"./normalize-servers.js";import{serverMatchesUrl as W}from"./server-variables.js";function Ie(e,n,a,r){const o=e.servers.find(f=>W(f,n.serverUrl))||e.servers[0],u=o?.url?.replace(/\/$/,"")??"",c=u?G(u).replace(/\/$/,""):"",t={};if(o?.variables)for(const[f,A]of Object.entries(o.variables))t[f]=n.environment?.[f]||A.default||"";const l=e.path.replace(/^\//,""),s=`${c}/${l}`,d={skipReadOnly:!0,maxDepth:a.generatedPayloadSamplesMaxDepth??8,format:"json"},i=o?.url??n.serverUrl??"",p=n.requestValues??{},m=Z(e.security,n.activeSecuritySchemeIds),y=ee(m,n,a,i),S=b(e.parameters.header,"header",i,p,a,r,d).concat(y.headers),h=n.mediaType||X(e.requestBody,n.exampleName,r.resolveExample)||(e.requestBody?Object.keys(e.requestBody)[0]:void 0);let R=!1;for(const f of S)f.name.toLowerCase()==="content-type"&&h&&(f.value=h,R=!0);!R&&h&&S.unshift({name:"Content-Type",value:h});const v=b(e.parameters.cookie,"cookie",i,p,a,r,d).concat(y.cookies),O=e.parameters.querystring.length>0,C=b(O?e.parameters.querystring:e.parameters.query,O?"querystring":"query",i,p,a,r,d).concat(y.queries),U={};for(const f of e.parameters.path)U[f.name]=p.path?.[f.name]||f.serverValues?.[i]?.example||f.example||"";let x;if(h&&e.requestBody?.[h]){const f=e.requestBody[h],A=e.requestValues?.serverBody?.[i]??e.requestValues?.body;x=le(f,h,n,r,d,i,A)}const w={};for(const f of S)w[f.name]=f.value;const I={};v.length&&(I.cookie=v.map(f=>`${encodeURIComponent(f.name)}=${encodeURIComponent(f.value)}`).join("; ")),Object.assign(I,w);const j={};for(const f of C)V(j,f.name,f.value);const B=x?.text?ue(x.text):void 0;let _;if(x?.params?.length){_={};for(const f of x.params)V(_,f.name,f.value??"")}const P=C.map(f=>`${encodeURIComponent(f.name)}=${encodeURIComponent(f.value)}`).join("&"),q=P?`${s}?${P}`:s;return{method:e.method.toUpperCase(),url:s,pathname:q,httpVersion:"HTTP/1.1",cookies:v,headers:S,queryString:C,postData:x,headersSize:-1,bodySize:-1,fullUrl:q,headersObj:w,allHeaders:I,queryObj:j,jsonObj:B,paramsObj:_,basicAuth:y.basicAuth,pathParameters:U,serverVariables:t,responseCodes:e.responseCodes,allResponseCodes:e.responseCodes,oAuth2PreRequests:y.oAuth2PreRequests}}function V(e,n,a){const r=e[n];r===void 0?e[n]=a:Array.isArray(r)?r.push(a):e[n]=[r,a]}function Z(e,n){if(e.length){if(n?.length){const a=e.find(r=>{const o=r.schemes.map(u=>u.id);return o.length===n.length&&o.every(u=>n.includes(u))});if(a)return a}return e[0]}}function ee(e,n,a,r){const o={headers:[],cookies:[],queries:[]};if(!e)return o;for(const u of e.schemes)ne(u,o,n,a,r,e.scopes);return o}const te={"x-defaultUsername":g.Username,"x-defaultPassword":g.Password,"x-defaultClientId":g.ClientId,"x-defaultClientSecret":g.ClientSecret};function ne(e,n,a,r,o,u=[]){const c=a.requestValues?.security,t=l=>{const s=e.serverValues?.[o];if(s){const y=s[l];if(y!=null)return String(y)}const d=e[l];if(d!=null&&typeof d=="string")return d;const i=c?.[l];if(i!=null)return String(i);const p=l==="x-defaultAccessToken"?e.type==="apiKey"?g.APIKey:g.Token:te[l],m=p!==void 0?a.environment?.[e.id+p]:void 0;if(m)return m};if(e.type==="http"&&e.scheme==="basic")n.basicAuth={username:t("x-defaultUsername")||c?.username||"<username>",password:t("x-defaultPassword")||c?.password||"<password>"};else if(e.type==="http"){const l=t("x-defaultAccessToken"),s=e.scheme||"bearer",d=s.charAt(0).toUpperCase()+s.slice(1),i=e.bearerFormat?`<YOUR_${e.bearerFormat}_HERE>`:"<YOUR_TOKEN_HERE>";n.headers.push({name:"Authorization",value:l?`${d} ${l}`:`${d} ${i}`})}else if(e.type==="apiKey"&&e.name){const l=t("x-defaultAccessToken")||"YOUR_API_KEY_HERE",s={name:e.name,value:l};e.in==="header"?n.headers.push(s):e.in==="cookie"?n.cookies.push({name:e.name,value:l}):(e.in==="query"||e.in==="querystring"||e.in===void 0)&&n.queries.push({name:e.name,value:l})}else if(e.type==="oauth2"){const l=t("x-defaultAccessToken"),s=t("x-defaultTokenType")||"Bearer";if(n.headers.push({name:"Authorization",value:l?`${s} ${l}`:"Bearer <YOUR_TOKEN_HERE>"}),r.withOAuth2Call&&e.flows){const d=[];if(e.flows.deviceAuthorization){const i=e.flows.deviceAuthorization;d.push(ae(i.deviceAuthorizationUrl,i.tokenUrl,e,o,u))}else if(e.flows.clientCredentials){const i=e.flows.clientCredentials;d.push(z("clientCredentials",i.tokenUrl,e,o,u))}else if(e.flows.password){const i=e.flows.password;d.push(z("password",i.tokenUrl,e,o,u))}d.length>0&&(n.oAuth2PreRequests=(n.oAuth2PreRequests??[]).concat(d))}}else if(e.type==="openIdConnect"){const l=t("x-defaultAccessToken"),s=t("x-defaultTokenType")||"Bearer";n.headers.push({name:"Authorization",value:l?`${s} ${l}`:"Bearer <YOUR_TOKEN_HERE>"})}}function ae(e,n,a,r,o=[]){const u=a.serverValues?.[r]?.["x-defaultClientId"]||a["x-defaultClientId"]||"YOUR_CLIENT_ID",c=[{name:"client_id",value:u}];return o.length>0&&c.push({name:"scope",value:o.join(" ")}),{flowType:"deviceAuthorization",tokenUrl:n,clientId:u,scopes:o.length>0?o:void 0,method:"POST",url:e,httpVersion:"HTTP/1.1",cookies:[],headers:[{name:"Content-Type",value:"application/x-www-form-urlencoded"},{name:"Accept",value:"application/json"}],queryString:[],postData:{mimeType:"application/x-www-form-urlencoded",params:c,text:c.map(t=>`${encodeURIComponent(t.name)}=${encodeURIComponent(t.value??"")}`).join("&")},headersSize:-1,bodySize:-1}}function z(e,n,a,r,o=[]){const u=a.serverValues?.[r]?.["x-defaultClientId"]||a["x-defaultClientId"]||"YOUR_CLIENT_ID",c=a.serverValues?.[r]?.["x-defaultClientSecret"]||a["x-defaultClientSecret"],t=a.serverValues?.[r]?.["x-defaultUsername"]||a["x-defaultUsername"],l=a.serverValues?.[r]?.["x-defaultPassword"]||a["x-defaultPassword"],s=[];return e==="clientCredentials"?s.push({name:"grant_type",value:"client_credentials"}):e==="password"&&s.push({name:"grant_type",value:"password"}),s.push({name:"client_id",value:u}),s.push({name:"client_secret",value:c||"YOUR_CLIENT_SECRET"}),e==="password"&&(s.push({name:"username",value:t||"<username>"}),s.push({name:"password",value:l||"<password>"})),o.length>0&&s.push({name:"scope",value:o.join(" ")}),{flowType:e,tokenUrl:n,clientId:u,clientSecret:c,username:t,password:l,scopes:o.length>0?o:void 0,method:"POST",url:n,httpVersion:"HTTP/1.1",cookies:[],headers:[{name:"Content-Type",value:"application/x-www-form-urlencoded"},{name:"Accept",value:"application/json"}],queryString:[],postData:{mimeType:"application/x-www-form-urlencoded",params:s,text:s.map(d=>`${encodeURIComponent(d.name)}=${encodeURIComponent(d.value??"")}`).join("&")},headersSize:-1,bodySize:-1}}function N(e,n,a){return n==="querystring"&&e.serializationMime===k.URL_ENCODED&&typeof a=="object"&&a!==null?re(J(a)):null}function re(e){const n=new Map,a=[];for(const r of e){const o=n.get(r.name);o?o.push(r.value):(n.set(r.name,[r.value]),a.push(r.name))}return a.map(r=>({name:r,value:(n.get(r)??[]).join(",")}))}function b(e,n,a,r,o,u,c){return e.filter(t=>!o.skipOptionalParameters||t.required).flatMap(t=>{const s=r[n==="querystring"?"query":n]?.[t.name];if(s!=null)return[{name:t.name,value:String(s)}];const d=t.serverValues?.[a]?.example;if(d!=null)return[{name:t.name,value:T(t,d)}];if(t.example!=null){const i=N(t,n,t.example);return i||(t.serializationMime&&u.serializeParameter?[{name:t.name,value:u.serializeParameter(t,t.example)}]:[{name:t.name,value:T(t,t.example)}])}if(n==="querystring"&&t.serializationMime===k.URL_ENCODED&&t.schemaId){const i=u.resolveSchema(t.schemaId);if(i){const p=u.sampleFromSchema(i,c),m=N(t,n,p);if(m)return m}}return[{name:t.name,value:oe(t,u,c)}]})}function oe(e,n,a){if(e.schemaId){const r=n.resolveSchema(e.schemaId);if(r){const o=n.sampleFromSchema(r,a);if(o!=null)return e.serializationMime&&n.serializeParameter?n.serializeParameter(e,o):T(e,o)}}return`{${e.name}}`}function ie(e){switch(e){case"query":case"querystring":case"cookie":return"form";case"path":case"header":return"simple";default:return"form"}}function T(e,n){if(n==null)return"";if(typeof n!="object")return String(n);const a=e.style??ie(e.in),o=e.explode??a==="form"?"*":"",u="__redoc_param_name__";try{switch(a){case"form":{const l=$.parse(`{?${u}${o}}`).expand({[u]:n}).substring(1).replace(/__redoc_param_name__/g,e.name).split(`&${e.name}=`);return l[0]=l[0].replace(new RegExp(`^${se(e.name)}=`),""),l.map(D).join(",")}case"spaceDelimited":return Array.isArray(n)?n.map(String).join(" "):String(n);case"pipeDelimited":return Array.isArray(n)?n.map(String).join("|"):String(n);case"simple":case"label":case"matrix":{const c=a==="label"?".":a==="matrix"?";":"",t=$.parse(`{${c}${u}${o}}`);return D(t.expand({[u]:n}).replace(/__redoc_param_name__/g,e.name))}case"deepObject":return JSON.stringify(n);default:return JSON.stringify(n)}}catch{return Array.isArray(n)?n.map(String).join(","):JSON.stringify(n)}}function se(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function D(e){try{return decodeURIComponent(e)}catch{return e}}function le(e,n,a,r,o,u,c){let t;if(a.replayBody!==void 0&&(t=a.replayBody),t===void 0&&a.exampleName){const i=Q(e.exampleIds,a.exampleName,r.resolveExample),p=i?r.resolveExample(i):void 0;p&&(t=p.value)}if(t===void 0&&e.exampleIds?.length){const i=r.resolveExample(e.exampleIds[0]);i&&(t=i.value)}if(t===void 0&&e.schemaId){const i=r.resolveVariantSchemaForSampling?.(e.schemaId),p=i?.schema??r.resolveSchema(e.schemaId),m=i?.variantSchemaId??e.schemaId;if(p){const y=n.toLowerCase().includes("xml");t=r.sampleFromSchema(p,{...o,format:y?"xml":o.format}),t&&typeof t=="object"&&!Array.isArray(t)&&m!==e.schemaId&&r.applyDiscriminatorValue?.(t,m,i?.mappingKey)}}if(c!==void 0&&a.replayBody===void 0&&(t===void 0?t=c:t=F(t,c)),t===void 0)return;const l=n.toLowerCase();let s,d=[];if(l.includes("x-www-form-urlencoded"))typeof t=="object"&&t!==null?(d=Object.entries(t).map(([i,p])=>({name:i,value:E(p)})),s=K(t)):s=String(t);else if(l.includes("multipart/form-data"))typeof t=="string"?(d=M(t)??[],s=t):(typeof t=="object"&&t!==null&&!Array.isArray(t)&&(d=Object.entries(t).map(([i,p])=>({name:i,value:E(p)}))),s=JSON.stringify(t,null,2));else if(H(l))if(typeof t=="string")s=t;else{const i=e.schemaId?r.resolveSchema(e.schemaId):void 0;s=String(Y(t,l,i,!0))}else l.includes("json")?s=typeof t=="string"?t:JSON.stringify(t,null,2):l.includes("xml")?s=typeof t=="string"?t:t&&typeof t=="object"?L(t):String(t):s=typeof t=="string"?t:JSON.stringify(t,null,2);return{mimeType:n,params:d,text:s}}function ue(e){try{const n=JSON.parse(e);if(n&&typeof n=="object"&&!Array.isArray(n))return n}catch{}}export{Ie as buildCodeSampleHAR};
1
+ import $ from"url-template";import{SecurityVariablesEnvSuffix as g}from"@redocly/theme/core/openapi";import{mergeBodyValue as F}from"../../adapters/openapi/configure/merge-utils.js";import{formUrlEncodeValue as K,stringifyFormFieldValue as E}from"../../utils/form-urlencoded.js";import{isSequentialMediaType as H}from"../../utils/media-type.js";import{parseMultipartFormData as M}from"../../utils/multipart.js";import{objectToHarParams as J}from"../../utils/serialize-querystring.js";import{jsonToXml as L}from"../../utils/xml.js";import{MediaTypes as k}from"../../constants/openapi.js";import{convertSampleToString as Y}from"./convertSampleToString.js";import{findExampleIdByKey as Q,mediaTypeContainingKey as X}from"./example-key.js";import{resolveServerUrl as G}from"./normalize-servers.js";import{serverMatchesUrl as W}from"./server-variables.js";function Ie(e,n,a,r){const o=e.servers.find(f=>W(f,n.serverUrl))||e.servers[0],u=o?.url?.replace(/\/$/,"")??"",c=u?G(u).replace(/\/$/,""):"",t={};if(o?.variables)for(const[f,A]of Object.entries(o.variables))t[f]=n.environment?.[f]||A.default||"";const l=e.path.replace(/^\//,""),s=`${c}/${l}`,d={skipReadOnly:!0,maxDepth:a.generatedPayloadSamplesMaxDepth??8,format:"json"},i=o?.url??n.serverUrl??"",p=n.requestValues??{},m=Z(e.security,n.activeSecuritySchemeIds),y=ee(m,n,a,i),S=b(e.parameters.header,"header",i,p,a,r,d).concat(y.headers),h=n.mediaType||X(e.requestBody,n.exampleName,r.resolveExample)||(e.requestBody?Object.keys(e.requestBody)[0]:void 0);let R=!1;for(const f of S)f.name.toLowerCase()==="content-type"&&h&&(f.value=h,R=!0);!R&&h&&S.unshift({name:"Content-Type",value:h});const v=b(e.parameters.cookie,"cookie",i,p,a,r,d).concat(y.cookies),O=e.parameters.querystring.length>0,C=b(O?e.parameters.querystring:e.parameters.query,O?"querystring":"query",i,p,a,r,d).concat(y.queries),U={};for(const f of e.parameters.path)U[f.name]=p.path?.[f.name]||f.serverValues?.[i]?.example||f.example||"";let x;if(h&&e.requestBody?.[h]){const f=e.requestBody[h],A=e.requestValues?.serverBody?.[i]??e.requestValues?.body;x=le(f,h,n,r,d,i,A)}const w={};for(const f of S)w[f.name]=f.value;const I={};v.length&&(I.cookie=v.map(f=>`${encodeURIComponent(f.name)}=${encodeURIComponent(f.value)}`).join("; ")),Object.assign(I,w);const j={};for(const f of C)V(j,f.name,f.value);const B=x?.text?ue(x.text):void 0;let _;if(x?.params?.length){_={};for(const f of x.params)V(_,f.name,f.value??"")}const P=C.map(f=>`${encodeURIComponent(f.name)}=${encodeURIComponent(f.value)}`).join("&"),q=P?`${s}?${P}`:s;return{method:e.method.toUpperCase(),url:s,pathname:q,httpVersion:"HTTP/1.1",cookies:v,headers:S,queryString:C,postData:x,headersSize:-1,bodySize:-1,fullUrl:q,headersObj:w,allHeaders:I,queryObj:j,jsonObj:B,paramsObj:_,basicAuth:y.basicAuth,pathParameters:U,serverVariables:t,responseCodes:e.responseCodes,allResponseCodes:e.responseCodes,oAuth2PreRequests:y.oAuth2PreRequests}}function V(e,n,a){const r=e[n];r===void 0?e[n]=a:Array.isArray(r)?r.push(a):e[n]=[r,a]}function Z(e,n){if(e.length){if(n?.length){const a=e.find(r=>{const o=r.schemes.map(u=>u.id);return o.length===n.length&&o.every(u=>n.includes(u))});if(a)return a}return e[0]}}function ee(e,n,a,r){const o={headers:[],cookies:[],queries:[]};if(!e)return o;for(const u of e.schemes)ne(u,o,n,a,r,e.scopes);return o}const te={"x-defaultUsername":g.Username,"x-defaultPassword":g.Password,"x-defaultClientId":g.ClientId,"x-defaultClientSecret":g.ClientSecret};function ne(e,n,a,r,o,u=[]){const c=a.requestValues?.security,t=l=>{const s=e.serverValues?.[o];if(s){const y=s[l];if(y!=null)return String(y)}const d=e[l];if(d!=null&&typeof d=="string")return d;const i=c?.[l];if(i!=null)return String(i);const p=l==="x-defaultAccessToken"?e.type==="apiKey"?g.APIKey:g.Token:te[l],m=p!==void 0?a.environment?.[e.id+p]:void 0;if(m)return m};if(e.type==="http"&&e.scheme==="basic")n.basicAuth={username:t("x-defaultUsername")||c?.username||"<username>",password:t("x-defaultPassword")||c?.password||"<password>"};else if(e.type==="http"){const l=t("x-defaultAccessToken"),s=e.scheme||"bearer",d=s.charAt(0).toUpperCase()+s.slice(1),i=e.bearerFormat?`<YOUR_${e.bearerFormat}_HERE>`:"<YOUR_TOKEN_HERE>";n.headers.push({name:"Authorization",value:l?`${d} ${l}`:`${d} ${i}`})}else if(e.type==="apiKey"&&e.name){const l=t("x-defaultAccessToken")||"YOUR_API_KEY_HERE",s={name:e.name,value:l};e.in==="header"?n.headers.push(s):e.in==="cookie"?n.cookies.push({name:e.name,value:l}):(e.in==="query"||e.in==="querystring"||e.in===void 0)&&n.queries.push({name:e.name,value:l})}else if(e.type==="oauth2"){const l=t("x-defaultAccessToken"),s=t("x-defaultTokenType")||"Bearer";if(n.headers.push({name:"Authorization",value:l?`${s} ${l}`:"Bearer <YOUR_TOKEN_HERE>"}),r.withOAuth2Call&&e.flows){const d=[];if(e.flows.deviceAuthorization){const i=e.flows.deviceAuthorization;d.push(ae(i.deviceAuthorizationUrl,i.tokenUrl,e,o,u))}else if(e.flows.clientCredentials){const i=e.flows.clientCredentials;d.push(z("clientCredentials",i.tokenUrl,e,o,u))}else if(e.flows.password){const i=e.flows.password;d.push(z("password",i.tokenUrl,e,o,u))}d.length>0&&(n.oAuth2PreRequests=(n.oAuth2PreRequests??[]).concat(d))}}else if(e.type==="openIdConnect"){const l=t("x-defaultAccessToken"),s=t("x-defaultTokenType")||"Bearer";n.headers.push({name:"Authorization",value:l?`${s} ${l}`:"Bearer <YOUR_TOKEN_HERE>"})}}function ae(e,n,a,r,o=[]){const u=a.serverValues?.[r]?.["x-defaultClientId"]||a["x-defaultClientId"]||"YOUR_CLIENT_ID",c=[{name:"client_id",value:u}];return o.length>0&&c.push({name:"scope",value:o.join(" ")}),{flowType:"deviceAuthorization",tokenUrl:n,clientId:u,scopes:o.length>0?o:void 0,method:"POST",url:e,httpVersion:"HTTP/1.1",cookies:[],headers:[{name:"Content-Type",value:"application/x-www-form-urlencoded"},{name:"Accept",value:"application/json"}],queryString:[],postData:{mimeType:"application/x-www-form-urlencoded",params:c,text:c.map(t=>`${encodeURIComponent(t.name)}=${encodeURIComponent(t.value??"")}`).join("&")},headersSize:-1,bodySize:-1}}function z(e,n,a,r,o=[]){const u=a.serverValues?.[r]?.["x-defaultClientId"]||a["x-defaultClientId"]||"YOUR_CLIENT_ID",c=a.serverValues?.[r]?.["x-defaultClientSecret"]||a["x-defaultClientSecret"],t=a.serverValues?.[r]?.["x-defaultUsername"]||a["x-defaultUsername"],l=a.serverValues?.[r]?.["x-defaultPassword"]||a["x-defaultPassword"],s=[];return e==="clientCredentials"?s.push({name:"grant_type",value:"client_credentials"}):e==="password"&&s.push({name:"grant_type",value:"password"}),s.push({name:"client_id",value:u}),s.push({name:"client_secret",value:c||"YOUR_CLIENT_SECRET"}),e==="password"&&(s.push({name:"username",value:t||"<username>"}),s.push({name:"password",value:l||"<password>"})),o.length>0&&s.push({name:"scope",value:o.join(" ")}),{flowType:e,tokenUrl:n,clientId:u,clientSecret:c,username:t,password:l,scopes:o.length>0?o:void 0,method:"POST",url:n,httpVersion:"HTTP/1.1",cookies:[],headers:[{name:"Content-Type",value:"application/x-www-form-urlencoded"},{name:"Accept",value:"application/json"}],queryString:[],postData:{mimeType:"application/x-www-form-urlencoded",params:s,text:s.map(d=>`${encodeURIComponent(d.name)}=${encodeURIComponent(d.value??"")}`).join("&")},headersSize:-1,bodySize:-1}}function N(e,n,a){return n==="querystring"&&e.serializationMime===k.URL_ENCODED&&typeof a=="object"&&a!==null?re(J(a)):null}function re(e){const n=new Map,a=[];for(const r of e){const o=n.get(r.name);o?o.push(r.value):(n.set(r.name,[r.value]),a.push(r.name))}return a.map(r=>({name:r,value:(n.get(r)??[]).join(",")}))}function b(e,n,a,r,o,u,c){return e.filter(t=>!o.skipOptionalParameters||t.required).flatMap(t=>{const s=r[n==="querystring"?"query":n]?.[t.name];if(s!=null)return[{name:t.name,value:String(s)}];const d=t.serverValues?.[a]?.example;if(d!=null)return[{name:t.name,value:T(t,d)}];if(t.example!=null){const i=N(t,n,t.example);return i||(t.serializationMime&&u.serializeParameter?[{name:t.name,value:u.serializeParameter(t,t.example)}]:[{name:t.name,value:T(t,t.example)}])}if(n==="querystring"&&t.serializationMime===k.URL_ENCODED&&t.schemaId){const i=u.resolveSchema(t.schemaId);if(i){const p=u.sampleFromSchema(i,c),m=N(t,n,p);if(m)return m}}return[{name:t.name,value:oe(t,u,c)}]})}function oe(e,n,a){if(e.schemaId){const r=n.resolveSchema(e.schemaId);if(r){const o=n.sampleFromSchema(r,a);if(o!=null)return e.serializationMime&&n.serializeParameter?n.serializeParameter(e,o):T(e,o)}}return`{${e.name}}`}function ie(e){switch(e){case"query":case"querystring":case"cookie":return"form";case"path":case"header":return"simple";default:return"form"}}function T(e,n){if(n==null)return"";if(typeof n!="object")return String(n);const a=e.style??ie(e.in),o=e.explode??a==="form"?"*":"",u="__redoc_param_name__";try{switch(a){case"form":{const l=$.parse(`{?${u}${o}}`).expand({[u]:n}).substring(1).replace(/__redoc_param_name__/g,e.name).split(`&${e.name}=`);return l[0]=l[0].replace(new RegExp(`^${se(e.name)}=`),""),l.map(D).join(",")}case"spaceDelimited":return Array.isArray(n)?n.map(String).join(" "):String(n);case"pipeDelimited":return Array.isArray(n)?n.map(String).join("|"):String(n);case"simple":case"label":case"matrix":{const c=a==="label"?".":a==="matrix"?";":"",t=$.parse(`{${c}${u}${o}}`);return D(t.expand({[u]:n}).replace(/__redoc_param_name__/g,e.name))}case"deepObject":return JSON.stringify(n);default:return JSON.stringify(n)}}catch{return Array.isArray(n)?n.map(String).join(","):JSON.stringify(n)}}function se(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function D(e){try{return decodeURIComponent(e)}catch{return e}}function le(e,n,a,r,o,u,c){let t;if(a.replayBody!==void 0&&(t=a.replayBody),t===void 0&&a.exampleName){const i=Q(e.exampleIds,a.exampleName,r.resolveExample),p=i?r.resolveExample(i):void 0;p&&(t=p.value)}if(t===void 0&&e.exampleIds?.length){const i=r.resolveExample(e.exampleIds[0]);i&&(t=i.value)}if(t===void 0&&e.schemaId){const i=r.resolveVariantSchemaForSampling?.(e.schemaId),p=i?.schema??r.resolveSchema(e.schemaId),m=i?.variantSchemaId??e.schemaId;if(p){const y=n.toLowerCase().includes("xml");t=r.sampleFromSchema(p,{...o,format:y?"xml":o.format}),t&&typeof t=="object"&&!Array.isArray(t)&&m!==e.schemaId&&r.applyDiscriminatorValue?.(t,m,i?.mappingKey)}}if(c!==void 0&&a.replayBody===void 0&&(t===void 0?t=c:t=F(t,c)),t===void 0)return;const l=n.toLowerCase();let s,d=[];if(l.includes("x-www-form-urlencoded"))typeof t=="object"&&t!==null?(d=Object.entries(t).map(([i,p])=>({name:i,value:E(p)})),s=K(t)):s=String(t);else if(l.includes("multipart/form-data"))typeof t=="string"?(d=M(t)??[],s=t):(typeof t=="object"&&t!==null&&!Array.isArray(t)&&(d=Object.entries(t).map(([i,p])=>({name:i,value:E(p)}))),s=JSON.stringify(t,null,2));else if(H(l))if(typeof t=="string")s=t;else{const i=e.schemaId?r.resolveSchema(e.schemaId):void 0;s=String(Y(t,l,i,!0))}else l.includes("json")?s=typeof t=="string"?t:JSON.stringify(t,null,2):l.includes("xml")?s=typeof t=="string"?t:t&&typeof t=="object"?L(t):String(t):s=typeof t=="string"?t:JSON.stringify(t,null,2);return{mimeType:n,params:d,text:s}}function ue(e){try{const n=JSON.parse(e);if(n&&typeof n=="object"&&!Array.isArray(n))return n}catch{}}export{V as appendKeyValue,Ie as buildCodeSampleHAR};
@@ -1 +1 @@
1
- import{isRecord as h}from"../../../adapters/helpers.js";import{mergeBodyValue as O}from"../../../adapters/openapi/configure/merge-utils.js";import{mapToReplayServers as S}from"./map-servers.js";function x(e){return e.startsWith("#/")?e.slice(2):e}const g="#/components/schemas/";function k(e,i){if(!e)return;const t=Object.create(null),n=[e];for(;n.length;){const a=n.pop();if(Array.isArray(a)){n.push(...a);continue}if(h(a))for(const[r,o]of Object.entries(a)){if(r==="$ref"&&typeof o=="string"&&o.startsWith(g)){const s=o.slice(g.length);if(s in t)continue;const l=i.resolveSchema(x(o));if(!l)continue;t[s]=l,n.push(l);continue}n.push(o)}}return Object.keys(t).length>0?{...e,components:{schemas:t}}:e}function I(e,i){const t={},n=e.discriminator;if(n?.propertyName&&n.mapping){const r=n.propertyName;for(const[o,s]of Object.entries(n.mapping)){if(typeof s!="string")continue;const l=i.resolveSchema(x(s));if(!l)continue;const p=i.sampleFromSchema(l,{skipReadOnly:!0});p!=null&&(h(p)&&(p[r]=o),t[o]={value:p})}if(Object.keys(t).length>0)return t}if(Array.isArray(e.oneOf)&&e.oneOf.length>0){const r=e.oneOf;for(let o=0;o<r.length;o++){const s=r[o];let l;if(h(s)&&(l=s,typeof s.$ref=="string"&&(l=i.resolveSchema(x(s.$ref))??s)),!l)continue;const p=i.sampleFromSchema(l,{skipReadOnly:!0});if(p==null)continue;const c=typeof l.title=="string"?l.title:`option ${o+1}`;t[c]={value:p}}if(Object.keys(t).length>0)return t}const a=i.sampleFromSchema(e,{skipReadOnly:!0});return a!=null&&(t.default={value:a}),t}function b(e,i,t){const n={};if(e.exampleIds?.length)for(const a of e.exampleIds){const r=i.resolveExample(a);r&&(n[a]={value:r.value,summary:r.summary})}if(Object.keys(n).length===0&&e.schemaId){const a=i.resolveSchema(e.schemaId);a&&Object.assign(n,I(a,i))}if(t!==void 0)if(Object.keys(n).length===0)n.default={value:t};else for(const a of Object.keys(n)){const r=n[a];n[a]={...r,value:O(r.value,t)}}return n}function v(e,i){const t=[],n=(c,u)=>{for(const f of c){const d=f.example;let m;if(f.schemaId){const y=i.resolveSchema(f.schemaId);y&&(m={typePrefix:"",title:y.title??f.name,displayType:y.type??"string",displayFormat:y.format,constraints:[],enum:y.enum??void 0})}t.push({name:f.name,in:u,required:f.required??!1,example:d!=null?String(d):void 0,schema:m})}};n(e.parameters.path,"path"),n(e.parameters.query,"query"),n(e.parameters.header,"header"),n(e.parameters.cookie,"cookie");for(const c of e.parameters.querystring)t.push(R(c,i));const a=S(e.servers),r=e.security.map(c=>c.schemes.map(u=>q(u,c.scopes)));let o;if(e.requestBody){const c=e.requestValues?.body,u={};for(const[f,d]of Object.entries(e.requestBody)){const m=b(d,i,c);u[f]={name:f,examples:Object.keys(m).length>0?m:void 0,schema:d.schemaId?k(i.resolveSchema(d.schemaId),i):void 0,parameters:[]}}o={mediaTypes:u}}const s=e.method.toLowerCase(),l=`${s}:${e.path}`,p=e.openApiOperationId??l;return{id:p,name:e.summary||`${e.method.toUpperCase()} ${e.path}`,method:s,path:e.path,href:"",operationId:p,parameters:t,servers:a,security:r,body:o}}function R(e,i){const t=e.schemaId?i.resolveSchema(e.schemaId):void 0,n=e.example!=null?e.example:t?i.sampleFromSchema(t,{skipReadOnly:!0}):void 0,a=j(t,n),r={typePrefix:"",title:t?.title??e.name,displayType:t?.type??"object",constraints:[],...a&&a.length>0?{fields:a}:{},...n!==void 0?{example:n}:{}};return{name:e.name,in:"querystring",required:e.required??!1,schema:r}}function j(e,i){const t=e?.properties;if(!t)return;const n=h(i)?i:{};return Object.keys(t).map(a=>{const r=n[a]!==void 0?n[a]:t[a]?.example;return{name:a,example:r}})}function q(e,i){return{id:e.id,type:e.type,name:e.name,in:e.in==="querystring"?"query":e.in,scheme:e.scheme,openIdConnectUrl:e.openIdConnectUrl,scopes:i,flows:e.flows,"x-defaultAccessToken":e["x-defaultAccessToken"],"x-defaultTokenType":e["x-defaultTokenType"],"x-defaultClientId":e["x-defaultClientId"],"x-defaultClientSecret":e["x-defaultClientSecret"],"x-defaultUsername":e["x-defaultUsername"],"x-defaultPassword":e["x-defaultPassword"],serverValues:e.serverValues}}function $(e,i,t){return(n,a,r)=>{const o=`${a.toLowerCase()}:${n}`,s=e.get(o);if(!s)return;const l=t?t(s):s;return v(l,i)}}export{$ as createReplayConverter,v as toReplayOperation};
1
+ import{isRecord as h}from"../../../adapters/helpers.js";import{descriptionToMarkdown as O}from"../../../adapters/utils/descriptionToMarkdown.js";import{isMarkdocAst as S}from"../../../adapters/utils/markdoc.js";import{mergeBodyValue as k}from"../../../adapters/openapi/configure/merge-utils.js";import{mapToReplayServers as I}from"./map-servers.js";function x(e){return e.startsWith("#/")?e.slice(2):e}const g="#/components/schemas/";function b(e,i){if(!e)return;const n=Object.create(null),a=new Set,r=[],s=new Map;function c(t){if(!h(t)&&!Array.isArray(t))return t;const l=s.get(t);if(s.has(t))return l===void 0?t:l;s.set(t,void 0);const o=Array.isArray(t)?f(t):u(t);return s.set(t,o),o}function f(t){let l=!1;const o=t.map(p=>{const d=c(p);return d!==p&&(l=!0),d});return l?o:t}function u(t){const l=t.$ref;if(typeof l=="string"&&l.startsWith(g)){const p=l.slice(g.length);return a.has(p)||(a.add(p),r.push({name:p,ref:l})),t}let o=t;for(const[p,d]of Object.entries(t)){const y=p==="description"&&S(d)?O(d):c(d);y!==d&&(o===t&&(o={...t}),o[p]=y)}return o}const m=c(e);for(;r.length;){const{name:t,ref:l}=r.pop(),o=i.resolveSchema(x(l));o&&(n[t]=c(o))}return Object.keys(n).length>0?{...m,components:{schemas:n}}:m}function v(e,i){const n={},a=e.discriminator;if(a?.propertyName&&a.mapping){const s=a.propertyName;for(const[c,f]of Object.entries(a.mapping)){if(typeof f!="string")continue;const u=i.resolveSchema(x(f));if(!u)continue;const m=i.sampleFromSchema(u,{skipReadOnly:!0});m!=null&&(h(m)&&(m[s]=c),n[c]={value:m})}if(Object.keys(n).length>0)return n}if(Array.isArray(e.oneOf)&&e.oneOf.length>0){const s=e.oneOf;for(let c=0;c<s.length;c++){const f=s[c];let u;if(h(f)&&(u=f,typeof f.$ref=="string"&&(u=i.resolveSchema(x(f.$ref))??f)),!u)continue;const m=i.sampleFromSchema(u,{skipReadOnly:!0});if(m==null)continue;const t=typeof u.title=="string"?u.title:`option ${c+1}`;n[t]={value:m}}if(Object.keys(n).length>0)return n}const r=i.sampleFromSchema(e,{skipReadOnly:!0});return r!=null&&(n.default={value:r}),n}function R(e,i,n){const a={};if(e.exampleIds?.length)for(const r of e.exampleIds){const s=i.resolveExample(r);s&&(a[r]={value:s.value,summary:s.summary})}if(Object.keys(a).length===0&&e.schemaId){const r=i.resolveSchema(e.schemaId);r&&Object.assign(a,v(r,i))}if(n!==void 0)if(Object.keys(a).length===0)a.default={value:n};else for(const r of Object.keys(a)){const s=a[r];a[r]={...s,value:k(s.value,n)}}return a}function j(e,i){const n=[],a=(t,l)=>{for(const o of t){const p=o.example;let d;if(o.schemaId){const y=i.resolveSchema(o.schemaId);y&&(d={typePrefix:"",title:y.title??o.name,displayType:y.type??"string",displayFormat:y.format,constraints:[],enum:y.enum??void 0})}n.push({name:o.name,in:l,required:o.required??!1,example:p!=null?String(p):void 0,schema:d})}};a(e.parameters.path,"path"),a(e.parameters.query,"query"),a(e.parameters.header,"header"),a(e.parameters.cookie,"cookie");for(const t of e.parameters.querystring)n.push(q(t,i));const r=I(e.servers),s=e.security.map(t=>t.schemes.map(l=>A(l,t.scopes)));let c;if(e.requestBody){const t=e.requestValues?.body,l={};for(const[o,p]of Object.entries(e.requestBody)){const d=R(p,i,t);l[o]={name:o,examples:Object.keys(d).length>0?d:void 0,schema:p.schemaId?b(i.resolveSchema(p.schemaId),i):void 0,parameters:[]}}c={mediaTypes:l}}const f=e.method.toLowerCase(),u=`${f}:${e.path}`,m=e.openApiOperationId??u;return{id:m,name:e.summary||`${e.method.toUpperCase()} ${e.path}`,method:f,path:e.path,href:"",operationId:m,parameters:n,servers:r,security:s,body:c}}function q(e,i){const n=e.schemaId?i.resolveSchema(e.schemaId):void 0,a=e.example!=null?e.example:n?i.sampleFromSchema(n,{skipReadOnly:!0}):void 0,r=w(n,a),s={typePrefix:"",title:n?.title??e.name,displayType:n?.type??"object",constraints:[],...r&&r.length>0?{fields:r}:{},...a!==void 0?{example:a}:{}};return{name:e.name,in:"querystring",required:e.required??!1,schema:s}}function w(e,i){const n=e?.properties;if(!n)return;const a=h(i)?i:{};return Object.keys(n).map(r=>{const s=a[r]!==void 0?a[r]:n[r]?.example;return{name:r,example:s}})}function A(e,i){return{id:e.id,type:e.type,name:e.name,in:e.in==="querystring"?"query":e.in,scheme:e.scheme,openIdConnectUrl:e.openIdConnectUrl,scopes:i,flows:e.flows,"x-defaultAccessToken":e["x-defaultAccessToken"],"x-defaultTokenType":e["x-defaultTokenType"],"x-defaultClientId":e["x-defaultClientId"],"x-defaultClientSecret":e["x-defaultClientSecret"],"x-defaultUsername":e["x-defaultUsername"],"x-defaultPassword":e["x-defaultPassword"],serverValues:e.serverValues}}function E(e,i,n){return(a,r,s)=>{const c=`${r.toLowerCase()}:${a}`,f=e.get(c);if(!f)return;const u=n?n(f):f;return j(u,i)}}export{E as createReplayConverter,j as toReplayOperation};
@@ -1 +1 @@
1
- function m(n,a,r){(n.environment||n.environments)&&a({environment:n.environment,environments:n.environments});for(const h of n.operations??[]){const{apiPath:t,requestValues:e,activeSecuritySchemeIds:o,activeExampleName:c}=h,i={};e.header&&Object.keys(e.header).length>0&&(i.headers=e.header),e.query&&Object.keys(e.query).length>0&&(i.queryString=e.query),e.cookie&&Object.keys(e.cookie).length>0&&(i.cookies=e.cookie),e.body!==void 0&&(i.body=e.body),o?.length&&(i.activeSecuritySchemeIds=o),c&&(i.activeExampleName=c),n.activeMimeName&&(i.activeMimeName=n.activeMimeName),r(t.path,t.method,i)}}export{m as handleReplayParamChange};
1
+ import{appendKeyValue as f}from"../builder.js";function u(e,o,a){(e.environment||e.environments)&&o({environment:e.environment,environments:e.environments});for(const i of e.operations??[]){const{apiPath:r,requestValues:n,activeSecuritySchemeIds:c,activeExampleName:m}=i,t={};n.header&&Object.keys(n.header).length>0&&(t.headers=n.header),n.query&&Object.keys(n.query).length>0&&(t.queryString=n.query),n.cookie&&Object.keys(n.cookie).length>0&&(t.cookies=n.cookie),n.body!==void 0&&(t.body=s(n.body)),c?.length&&(t.activeSecuritySchemeIds=c),m&&(t.activeExampleName=m),e.activeMimeName&&(t.activeMimeName=e.activeMimeName),a(r.path,r.method,t)}}function s(e){if(!(e instanceof FormData)&&!(e instanceof URLSearchParams))return e;const o={};for(const[a,i]of e)f(o,a,typeof i=="string"?i:i.name);return o}export{u as handleReplayParamChange};
@@ -1 +1 @@
1
- import{REDOCLY_TEAMS_RBAC as f}from"@redocly/config";import{nodeTypes as P,contentType as S,schemaKind as E}from"../../types/common.js";import{extractFullText as y}from"../../adapters/utils/markdoc.js";import{appendArraySuffix as D,appendVariantSuffix as g,buildGraphqlSuffix as O,buildOpenApiSectionSuffix as j,makeDeepLink as I}from"../../utils/deep-link.js";const V=10,R="message payload",w="message headers",x=200;function _(k){return k.length>x?`${k.slice(0,x)}\u2026`:k}class G{#a=[];#r;#i;#s;#o;constructor(e,n,t){this.#r=e,this.#i=n,this.#s=t}addItem(e){if(!(!e.link||!e.content))try{switch(e.content.contentType){case S.OVERVIEW:this.#d(e,this.#r);break;case S.GROUP:case S.ITEM:this.#d(e,e.link);break}}catch(n){console.error(`Cannot add item to api-docs search indexer [${e.label}, ${e.link}]:`,n.message)}}#d(e,n){if(!e.content)return;const t=n.startsWith(this.#r+"/")?n.slice(this.#r.length+1):n.split("/").slice(-2).join("/"),r=e.content.children,i=this.#l(r),o=this.#y(r,t),s=e,a={id:n,url:n,title:e.label??"",text:i,path:[],deprecated:e.content.meta?.deprecated,..."httpVerb"in e&&e.httpVerb?{httpMethod:e.httpVerb}:{},..."httpPath"in e&&e.httpPath?{httpPath:e.httpPath}:{},..."badges"in e&&Array.isArray(e.badges)&&e.badges.length?{badges:e.badges}:{},..."isAdditionalOperation"in e&&e.isAdditionalOperation?{isAdditionalOperation:!0}:{},[f]:s[f],...o.length&&{parameters:o}};this.#a.push(a)}#l(e){const n=[],t=r=>{for(const i of r)if(i.nodeType===P.MARKDOC){const o=i;if(this.#h(o.content))continue;const s=y(o.content);s&&n.push(s)}else(i.nodeType===P.CONTAINER||i.nodeType===P.OVERVIEW_SECTION_WRAPPER)&&t(i.children)};return t(e),n.join(" ").trim()}#h(e){let n=!1,t=!1;const r=o=>{o.type==="code"&&o.attributes?.content?n=!0:o.type==="text"&&o.attributes?.content&&(t=!0);for(const s of o.children??[])r(s)},i=Array.isArray(e)?e:[e];for(const o of i)r(o);return n&&!t}#y(e,n){const t={},r=new Set,i=o=>{for(const s of o)if(s.nodeType===P.ITEM){const a=s;if(a[f])continue;this.#m(a,t,n),this.#S(a,t,r,n)}else if(s.nodeType===P.CONTAINER){const a=s;if(a[f])continue;i(a.children)}else s.nodeType===P.OVERVIEW_SECTION_WRAPPER&&i(s.children)};return i(e),Object.values(t)}#m(e,n,t){if(e.parameters?.length)for(const r of e.parameters){if(r[f])continue;const i=this.#g(e.variant),o=this.#k(e.variant),s=r.description?y(r.description):"",a=this.#$(r.schemaId),d={name:r.name,description:s,place:i,mediaType:void 0,type:a,required:r.required??!1,deepLink:this.#c(t,"request",o,void 0,void 0,[r.name]),example:void 0,enum:void 0};n[this.#t(d)]=d}}#t(e){return[...Array.isArray(e.path)?e.path:[],e.name.toString()].join(".")+e.description+e.place}#c(e,n,t,r,i,o){if(!e)return"";const s=o.join("/"),a=[`t=${n}`];return t&&a.push(`in=${t}`),i&&a.push(`c=${i}`),r&&a.push(`ct=${r}`),s&&a.push(`path=${s}`),`/${e}#${e}/${a.join("&")}`.toLowerCase()}#P(e,n,t,r){if(!e)return"";let i="messages";n&&(i+=`&m=${n}`),i+=`&t=${t}`;const o=r.join("/");return o&&(i+=`&path=${o}`),`/${e}#${e}/${i}`.toLowerCase()}#k(e){switch(e){case"query":return"query";case"path":return"path";case"headers":return"header";case"cookies":return"cookie";default:return}}#g(e){switch(e){case"query":return"query parameters";case"path":return"path parameters";case"headers":return"header parameters";case"cookies":return"cookie parameters";case"parameters":return"channel parameters";default:return e?`${e} parameters`:"parameters"}}#$(e){const n=this.#i?.[e];if(!n||n.kind!==E.JSON_SCHEMA)return"unknown";const t=n.data,r=this.#p(t);return this.#f(r)}#f(e){return Array.isArray(e.type)?e.type.join(" | "):e.type?e.type:e.properties||e.additionalProperties?"object":e.items?"array":e.enum?"string":"any"}#S(e,n,t,r){const i=this.#A(e);if(e.graphqlSchema&&Array.isArray(e.graphqlSchema)){this.#I(e.graphqlSchema,i,n,e,r);return}const o=!!this.#i&&!!this.#s;o&&this.#O(e,i,n,t,r);for(const s of e.responses??[])s[f]||(this.#T(s,n,r),o&&this.#b(s,n,r));if(o)for(const s of e.messages??[])s[f]||this.#q(s,n,r)}#O(e,n,t,r,i){const o=n.startsWith("response");if(e.mediaTypeSchemas){const s=Object.entries(e.mediaTypeSchemas),a=s.find(([,d])=>!d[f]);if(a){const[d,c]=a;c.schemaId&&this.#n(c.schemaId,n,d,s.length>1,o,t,[],r,i)}}else e.schemaId&&this.#n(e.schemaId,n,void 0,!1,o,t,[],r,i)}#T(e,n,t){const r=e.description?y(e.description):"",o=[e.summary?y(e.summary):"",r].filter(Boolean).join(" ").trim();if(!o)return;const s={name:e.code,description:o,place:`response ${e.code}`,mediaType:void 0,type:"unknown",required:!1,deepLink:t?I(t,j("response",void 0,e.code)):void 0,example:void 0,enum:void 0};n[this.#t(s)]=s}#b(e,n,t){const r=`response ${e.code} fields`,i=new Set;if(e.mediaTypeContent){const o=Object.entries(e.mediaTypeContent),s=o.find(([,a])=>!a[f]);if(s){const[a,d]=s;d.schemaId&&this.#n(d.schemaId,r,a,o.length>1,!0,n,[],i,t)}}else e.schemaId&&this.#n(e.schemaId,r,e.mediaType,!1,!0,n,[],i,t)}#q(e,n,t){const r=e.description?y(e.description):"",i=e.summary??"",o={name:e.name,description:(r+i).trim(),place:"message",mediaType:void 0,type:"unknown",required:!1,example:void 0,enum:void 0};n[this.#t(o)]=o,this.#o=e.name;const s=new Set;e.schemaId&&this.#n(e.schemaId,R,e.contentType,!1,!1,n,[],s,t),e.headerSchemaId&&this.#n(e.headerSchemaId,w,void 0,!1,!1,n,[],s,t),this.#o=void 0}#A(e){switch(e.variant){case"body":return"request fields";case"responses":return"response fields";case"graphql-fields":return"fields";case"graphql-args":return"arguments";case"return-type":return"return type fields";default:return e.variant??"fields"}}#E(e){return e.variant!=="graphql-args"?e.graphqlTypeName:e.graphqlFieldName?e.graphqlFieldName:e.graphqlTypeName?`@${e.graphqlTypeName}`:void 0}#I(e,n,t,r,i){const o=r.variant==="graphql-args",s=this.#E(r),a=d=>i&&s?I(i,d):void 0;for(const d of e){const c=d.description?y(d.description):"",u=`${s}.${d.name}`,l={name:d.name,description:c,place:n,mediaType:void 0,path:[],type:d.type??"unknown",required:!1,deepLink:a(o?O({t:"argument",path:u,arg:d.name}):O({t:"field",path:u})),example:void 0,enum:void 0};if(t[this.#t(l)]=l,d.args?.length)for(const p of d.args){const m=p.description?y(p.description):"",h={name:p.name,description:m,place:"arguments",mediaType:void 0,path:[d.name],type:p.type??"unknown",required:!1,deepLink:a(O({t:"argument",path:`${u}.${p.name}`,arg:p.name})),example:void 0,enum:void 0};t[this.#t(h)]=h}}}#n(e,n,t,r,i,o,s,a,d=""){const c=this.#i?.[e];if(!c||c.kind!==E.JSON_SCHEMA||c[f])return;const u=c.data,l=r?t:void 0;this.#u(u,n,t,l,i,o,{path:s,linkPath:[...s],depth:0},a,d)}#R(e){const n=e.match(/^response (\d+)/);return n?n[1]:void 0}#p(e){if(e.allOf){const n={};for(const t of e.allOf){const r=t.$ref?this.#e(t.$ref):t;if(r){const i=n.properties,o=n.required;Object.assign(n,r),(i||r.properties)&&(n.properties={...i||{},...r.properties||{}}),(o||r.required)&&(n.required=[...o||[],...r.required||[]])}}return delete n.allOf,e.description&&(n.description=e.description),n}if(e.$ref){const n=this.#e(e.$ref);if(n){const t={...n};return e.description&&(t.description=e.description),t}}return e}#e(e){if(!e.startsWith("#/"))return;const n=e.slice(2).split("/");let t=this.#s;for(const r of n){if(t==null||typeof t!="object")return;t=t[r]}return t!=null&&typeof t=="object"?t:void 0}#u(e,n,t,r,i,o,s,a,d=""){if(s.depth>V||e[f])return;const c=(p,m)=>this.#u(p,n,t,r,i,o,m,a,d);if(e.$ref){this.#w(e.$ref,c,s,a);return}if(e.allOf){c(this.#x(e,a),s);return}const u=e.discriminator??e["x-discriminator"];if(u?.propertyName&&!s.inDiscriminatorVariant){this.#W(e,u,c,s);return}const l=e.oneOf??e.anyOf;if(l){this.#C(e,l,c,s,a);return}if(e.if&&(e.then||e.else)){this.#L(e,c,s);return}e.properties&&this.#D(e,c,{place:n,mediaType:t,deepLinkContentType:r,isResponse:i,paramsMap:o,frame:s,visited:a,slug:d}),this.#v(e,c,s,a)}#w(e,n,t,r){if(r.has(e))return;r.add(e);const i=this.#e(e);i&&n(i,t)}#x(e,n){const t={};for(const r of e.allOf??[]){let i=r;if(r.$ref){if(n.has(r.$ref))continue;n.add(r.$ref),i=this.#e(r.$ref)}if(i){const o=t.properties,s=t.required;Object.assign(t,i),(o||i.properties)&&(t.properties={...o||{},...i.properties||{}}),(s||i.required)&&(t.required=[...s||[],...i.required||[]])}}return delete t.allOf,t}#C(e,n,t,r,i){e.properties&&t({...e,oneOf:void 0,anyOf:void 0},{...r,linkPath:g(r.linkPath,"&oneof=0")}),n.forEach((o,s)=>{if(o.$ref){if(i.has(o.$ref))return;i.add(o.$ref)}const a=o.$ref?this.#e(o.$ref):o;a&&t(a,{...r,linkPath:g(r.linkPath,`&oneof=${s}`),depth:r.depth+1})})}#L(e,n,t){const{if:r,then:i,else:o,...s}=e;[{allOf:[s,i??{},r??{}]},{allOf:[s,o??{}]}].forEach((d,c)=>{n(d,{...t,linkPath:g(t.linkPath,`&oneof=${c}`),depth:t.depth+1})})}#D(e,n,t){const{isResponse:r,paramsMap:i,frame:o,visited:s}=t,a=e.required||[],d=this.#R(t.place),c=r?"response":"request",u=t.place===R?"payload":t.place===w?"headers":void 0,l={requiredList:a,responseCode:d,type:c,asyncSubsection:u,...t};for(const[p,m]of Object.entries(e.properties??{})){if(m[f])continue;const h=this.#j(m,s);if(!h)continue;const C=this.#V(h,s),$=this.#p(h);if(!this.#_(h,$,r))continue;const T=p===o.discriminatorPropertyName,L=[...o.path,p],b=this.#F(p,T,o),q=this.#M(p,h,$,b,l),A=this.#t(q);i[A]==null&&(i[A]=q,!C&&!T&&n($,{path:L,linkPath:b,depth:o.depth+1}))}}#j(e,n){if(!e.$ref)return e;if(!n.has(e.$ref))return n.add(e.$ref),this.#e(e.$ref)}#V(e,n){if(!e.allOf)return!1;let t=!1;for(const r of e.allOf)r.$ref?n.has(r.$ref)||(n.add(r.$ref),t=!0):t=!0;return!t}#_(e,n,t){return!(e[f]||n[f]||n.readOnly&&!t||n.writeOnly&&t||e.additionalProperties!==void 0&&!e.properties)}#F(e,n,t){return[...n&&t.discriminatorLinkPath?t.discriminatorLinkPath:t.linkPath,e]}#M(e,n,t,r,i){const o=n.description??t.description,s=o?y(o):"",a=n.example??t.example,d=a!==void 0?_(typeof a=="string"?a:JSON.stringify(a)):void 0,c=Array.isArray(t.enum)&&t.enum.length?t.enum:void 0;return{name:e,description:s,place:i.place,mediaType:i.mediaType,path:i.frame.path,type:this.#f(t),required:i.requiredList.includes(e),deepLink:i.asyncSubsection?this.#P(i.slug,this.#o,i.asyncSubsection,r):this.#c(i.slug,i.type,void 0,i.deepLinkContentType,i.responseCode,r),example:d,enum:c}}#v(e,n,t,r){if(!e.items||typeof e.items!="object"||Array.isArray(e.items))return;if(e.items.$ref){if(r.has(e.items.$ref))return;r.add(e.items.$ref)}const i=e.items.$ref?this.#e(e.items.$ref):e.items;i&&n(i,{...t,linkPath:D(t.linkPath),depth:t.depth+1})}#W(e,n,t,r){const i=this.#G(e,n),o=s=>({...r,linkPath:g(r.linkPath,`&d=${s}`),inDiscriminatorVariant:!0,discriminatorPropertyName:n.propertyName,discriminatorLinkPath:r.linkPath});e.properties&&t({...e,discriminator:void 0,"x-discriminator":void 0,oneOf:void 0,anyOf:void 0},i.length?o(0):r),i.forEach((s,a)=>{t(s,{...o(a),depth:r.depth+1})})}#G(e,n){const t=e.oneOf??e.anyOf??[],r=Object.values(n.mapping??{});if(r.length===0)return t;const i=s=>t.find(a=>a.$ref===s||a["x-original-ref"]===s)??this.#e(s)??{},o=r.filter(s=>s!==n.defaultMapping).map(i);return n.defaultMapping&&o.push(i(n.defaultMapping)),o}getResult(){return this.#a}}export{G as ApiDocsSearchIndexer};
1
+ import{REDOCLY_TEAMS_RBAC as f}from"@redocly/config";import{nodeTypes as P,contentType as S,schemaKind as E}from"../../types/common.js";import{extractFullText as y}from"../../adapters/utils/markdoc.js";import{toElementId as D}from"../../utils/url.js";import{appendArraySuffix as j,appendVariantSuffix as $,buildGraphqlSuffix as O,buildOpenApiSectionSuffix as V,makeDeepLink as I}from"../../utils/deep-link.js";const _=10,R="message payload",w="message headers",x=200;function F(k){return k.length>x?`${k.slice(0,x)}\u2026`:k}class H{#a=[];#i;#r;#s;#o;constructor(e,n,t){this.#i=e,this.#r=n,this.#s=t}addItem(e){if(!(!e.link||!e.content))try{switch(e.content.contentType){case S.OVERVIEW:this.#d(e,this.#i);break;case S.GROUP:case S.ITEM:this.#d(e,e.link);break}}catch(n){console.error(`Cannot add item to api-docs search indexer [${e.label}, ${e.link}]:`,n.message)}}#d(e,n){if(!e.content)return;const t=D(n,this.#i)??"",r=e.content.children,i=this.#l(r),o=this.#y(r,t),s=e,a={id:n,url:n,title:e.label??"",text:i,path:[],deprecated:e.content.meta?.deprecated,..."httpVerb"in e&&e.httpVerb?{httpMethod:e.httpVerb}:{},..."httpPath"in e&&e.httpPath?{httpPath:e.httpPath}:{},..."badges"in e&&Array.isArray(e.badges)&&e.badges.length?{badges:e.badges}:{},..."isAdditionalOperation"in e&&e.isAdditionalOperation?{isAdditionalOperation:!0}:{},[f]:s[f],...o.length&&{parameters:o}};this.#a.push(a)}#l(e){const n=[],t=r=>{for(const i of r)if(i.nodeType===P.MARKDOC){const o=i;if(this.#h(o.content))continue;const s=y(o.content);s&&n.push(s)}else(i.nodeType===P.CONTAINER||i.nodeType===P.OVERVIEW_SECTION_WRAPPER)&&t(i.children)};return t(e),n.join(" ").trim()}#h(e){let n=!1,t=!1;const r=o=>{o.type==="code"&&o.attributes?.content?n=!0:o.type==="text"&&o.attributes?.content&&(t=!0);for(const s of o.children??[])r(s)},i=Array.isArray(e)?e:[e];for(const o of i)r(o);return n&&!t}#y(e,n){const t={},r=new Set,i=o=>{for(const s of o)if(s.nodeType===P.ITEM){const a=s;if(a[f])continue;this.#m(a,t,n),this.#S(a,t,r,n)}else if(s.nodeType===P.CONTAINER){const a=s;if(a[f])continue;i(a.children)}else s.nodeType===P.OVERVIEW_SECTION_WRAPPER&&i(s.children)};return i(e),Object.values(t)}#m(e,n,t){if(e.parameters?.length)for(const r of e.parameters){if(r[f])continue;const i=this.#$(e.variant),o=this.#k(e.variant),s=r.description?y(r.description):"",a=this.#g(r.schemaId),d={name:r.name,description:s,place:i,mediaType:void 0,type:a,required:r.required??!1,deepLink:this.#c(t,"request",o,void 0,void 0,[r.name]),example:void 0,enum:void 0};n[this.#t(d)]=d}}#t(e){return[...Array.isArray(e.path)?e.path:[],e.name.toString()].join(".")+e.description+e.place}#c(e,n,t,r,i,o){if(!e)return"";const s=o.join("/"),a=[`t=${n}`];return t&&a.push(`in=${t}`),i&&a.push(`c=${i}`),r&&a.push(`ct=${r}`),s&&a.push(`path=${s}`),`/${e}#${e}/${a.join("&")}`.toLowerCase()}#P(e,n,t,r){if(!e)return"";let i="messages";n&&(i+=`&m=${n}`),i+=`&t=${t}`;const o=r.join("/");return o&&(i+=`&path=${o}`),`/${e}#${e}/${i}`.toLowerCase()}#k(e){switch(e){case"query":return"query";case"path":return"path";case"headers":return"header";case"cookies":return"cookie";default:return}}#$(e){switch(e){case"query":return"query parameters";case"path":return"path parameters";case"headers":return"header parameters";case"cookies":return"cookie parameters";case"parameters":return"channel parameters";default:return e?`${e} parameters`:"parameters"}}#g(e){const n=this.#r?.[e];if(!n||n.kind!==E.JSON_SCHEMA)return"unknown";const t=n.data,r=this.#p(t);return this.#f(r)}#f(e){return Array.isArray(e.type)?e.type.join(" | "):e.type?e.type:e.properties||e.additionalProperties?"object":e.items?"array":e.enum?"string":"any"}#S(e,n,t,r){const i=this.#A(e);if(e.graphqlSchema&&Array.isArray(e.graphqlSchema)){this.#I(e.graphqlSchema,i,n,e,r);return}const o=!!this.#r&&!!this.#s;o&&this.#O(e,i,n,t,r);for(const s of e.responses??[])s[f]||(this.#T(s,n,r),o&&this.#b(s,n,r));if(o)for(const s of e.messages??[])s[f]||this.#q(s,n,r)}#O(e,n,t,r,i){const o=n.startsWith("response");if(e.mediaTypeSchemas){const s=Object.entries(e.mediaTypeSchemas),a=s.find(([,d])=>!d[f]);if(a){const[d,c]=a;c.schemaId&&this.#n(c.schemaId,n,d,s.length>1,o,t,[],r,i)}}else e.schemaId&&this.#n(e.schemaId,n,void 0,!1,o,t,[],r,i)}#T(e,n,t){const r=e.description?y(e.description):"",o=[e.summary?y(e.summary):"",r].filter(Boolean).join(" ").trim();if(!o)return;const s={name:e.code,description:o,place:`response ${e.code}`,mediaType:void 0,type:"unknown",required:!1,deepLink:t?I(t,V("response",void 0,e.code)):void 0,example:void 0,enum:void 0};n[this.#t(s)]=s}#b(e,n,t){const r=`response ${e.code} fields`,i=new Set;if(e.mediaTypeContent){const o=Object.entries(e.mediaTypeContent),s=o.find(([,a])=>!a[f]);if(s){const[a,d]=s;d.schemaId&&this.#n(d.schemaId,r,a,o.length>1,!0,n,[],i,t)}}else e.schemaId&&this.#n(e.schemaId,r,e.mediaType,!1,!0,n,[],i,t)}#q(e,n,t){const r=e.description?y(e.description):"",i=e.summary??"",o={name:e.name,description:(r+i).trim(),place:"message",mediaType:void 0,type:"unknown",required:!1,example:void 0,enum:void 0};n[this.#t(o)]=o,this.#o=e.name;const s=new Set;e.schemaId&&this.#n(e.schemaId,R,e.contentType,!1,!1,n,[],s,t),e.headerSchemaId&&this.#n(e.headerSchemaId,w,void 0,!1,!1,n,[],s,t),this.#o=void 0}#A(e){switch(e.variant){case"body":return"request fields";case"responses":return"response fields";case"graphql-fields":return"fields";case"graphql-args":return"arguments";case"return-type":return"return type fields";default:return e.variant??"fields"}}#E(e){return e.variant!=="graphql-args"?e.graphqlTypeName:e.graphqlFieldName?e.graphqlFieldName:e.graphqlTypeName?`@${e.graphqlTypeName}`:void 0}#I(e,n,t,r,i){const o=r.variant==="graphql-args",s=this.#E(r),a=d=>i&&s?I(i,d):void 0;for(const d of e){const c=d.description?y(d.description):"",u=`${s}.${d.name}`,l={name:d.name,description:c,place:n,mediaType:void 0,path:[],type:d.type??"unknown",required:!1,deepLink:a(o?O({t:"argument",path:u,arg:d.name}):O({t:"field",path:u})),example:void 0,enum:void 0};if(t[this.#t(l)]=l,d.args?.length)for(const p of d.args){const m=p.description?y(p.description):"",h={name:p.name,description:m,place:"arguments",mediaType:void 0,path:[d.name],type:p.type??"unknown",required:!1,deepLink:a(O({t:"argument",path:`${u}.${p.name}`,arg:p.name})),example:void 0,enum:void 0};t[this.#t(h)]=h}}}#n(e,n,t,r,i,o,s,a,d=""){const c=this.#r?.[e];if(!c||c.kind!==E.JSON_SCHEMA||c[f])return;const u=c.data,l=r?t:void 0;this.#u(u,n,t,l,i,o,{path:s,linkPath:[...s],depth:0},a,d)}#R(e){const n=e.match(/^response (\d+)/);return n?n[1]:void 0}#p(e){if(e.allOf){const n={};for(const t of e.allOf){const r=t.$ref?this.#e(t.$ref):t;if(r){const i=n.properties,o=n.required;Object.assign(n,r),(i||r.properties)&&(n.properties={...i||{},...r.properties||{}}),(o||r.required)&&(n.required=[...o||[],...r.required||[]])}}return delete n.allOf,e.description&&(n.description=e.description),n}if(e.$ref){const n=this.#e(e.$ref);if(n){const t={...n};return e.description&&(t.description=e.description),t}}return e}#e(e){if(!e.startsWith("#/"))return;const n=e.slice(2).split("/");let t=this.#s;for(const r of n){if(t==null||typeof t!="object")return;t=t[r]}return t!=null&&typeof t=="object"?t:void 0}#u(e,n,t,r,i,o,s,a,d=""){if(s.depth>_||e[f])return;const c=(p,m)=>this.#u(p,n,t,r,i,o,m,a,d);if(e.$ref){this.#w(e.$ref,c,s,a);return}if(e.allOf){c(this.#x(e,a),s);return}const u=e.discriminator??e["x-discriminator"];if(u?.propertyName&&!s.inDiscriminatorVariant){this.#W(e,u,c,s);return}const l=e.oneOf??e.anyOf;if(l){this.#C(e,l,c,s,a);return}if(e.if&&(e.then||e.else)){this.#L(e,c,s);return}e.properties&&this.#D(e,c,{place:n,mediaType:t,deepLinkContentType:r,isResponse:i,paramsMap:o,frame:s,visited:a,slug:d}),this.#v(e,c,s,a)}#w(e,n,t,r){if(r.has(e))return;r.add(e);const i=this.#e(e);i&&n(i,t)}#x(e,n){const t={};for(const r of e.allOf??[]){let i=r;if(r.$ref){if(n.has(r.$ref))continue;n.add(r.$ref),i=this.#e(r.$ref)}if(i){const o=t.properties,s=t.required;Object.assign(t,i),(o||i.properties)&&(t.properties={...o||{},...i.properties||{}}),(s||i.required)&&(t.required=[...s||[],...i.required||[]])}}return delete t.allOf,t}#C(e,n,t,r,i){e.properties&&t({...e,oneOf:void 0,anyOf:void 0},{...r,linkPath:$(r.linkPath,"&oneof=0")}),n.forEach((o,s)=>{if(o.$ref){if(i.has(o.$ref))return;i.add(o.$ref)}const a=o.$ref?this.#e(o.$ref):o;a&&t(a,{...r,linkPath:$(r.linkPath,`&oneof=${s}`),depth:r.depth+1})})}#L(e,n,t){const{if:r,then:i,else:o,...s}=e;[{allOf:[s,i??{},r??{}]},{allOf:[s,o??{}]}].forEach((d,c)=>{n(d,{...t,linkPath:$(t.linkPath,`&oneof=${c}`),depth:t.depth+1})})}#D(e,n,t){const{isResponse:r,paramsMap:i,frame:o,visited:s}=t,a=e.required||[],d=this.#R(t.place),c=r?"response":"request",u=t.place===R?"payload":t.place===w?"headers":void 0,l={requiredList:a,responseCode:d,type:c,asyncSubsection:u,...t};for(const[p,m]of Object.entries(e.properties??{})){if(m[f])continue;const h=this.#j(m,s);if(!h)continue;const C=this.#V(h,s),g=this.#p(h);if(!this.#_(h,g,r))continue;const T=p===o.discriminatorPropertyName,L=[...o.path,p],b=this.#F(p,T,o),q=this.#M(p,h,g,b,l),A=this.#t(q);i[A]==null&&(i[A]=q,!C&&!T&&n(g,{path:L,linkPath:b,depth:o.depth+1}))}}#j(e,n){if(!e.$ref)return e;if(!n.has(e.$ref))return n.add(e.$ref),this.#e(e.$ref)}#V(e,n){if(!e.allOf)return!1;let t=!1;for(const r of e.allOf)r.$ref?n.has(r.$ref)||(n.add(r.$ref),t=!0):t=!0;return!t}#_(e,n,t){return!(e[f]||n[f]||n.readOnly&&!t||n.writeOnly&&t||e.additionalProperties!==void 0&&!e.properties)}#F(e,n,t){return[...n&&t.discriminatorLinkPath?t.discriminatorLinkPath:t.linkPath,e]}#M(e,n,t,r,i){const o=n.description??t.description,s=o?y(o):"",a=n.example??t.example,d=a!==void 0?F(typeof a=="string"?a:JSON.stringify(a)):void 0,c=Array.isArray(t.enum)&&t.enum.length?t.enum:void 0;return{name:e,description:s,place:i.place,mediaType:i.mediaType,path:i.frame.path,type:this.#f(t),required:i.requiredList.includes(e),deepLink:i.asyncSubsection?this.#P(i.slug,this.#o,i.asyncSubsection,r):this.#c(i.slug,i.type,void 0,i.deepLinkContentType,i.responseCode,r),example:d,enum:c}}#v(e,n,t,r){if(!e.items||typeof e.items!="object"||Array.isArray(e.items))return;if(e.items.$ref){if(r.has(e.items.$ref))return;r.add(e.items.$ref)}const i=e.items.$ref?this.#e(e.items.$ref):e.items;i&&n(i,{...t,linkPath:j(t.linkPath),depth:t.depth+1})}#W(e,n,t,r){const i=this.#G(e,n),o=s=>({...r,linkPath:$(r.linkPath,`&d=${s}`),inDiscriminatorVariant:!0,discriminatorPropertyName:n.propertyName,discriminatorLinkPath:r.linkPath});e.properties&&t({...e,discriminator:void 0,"x-discriminator":void 0,oneOf:void 0,anyOf:void 0},i.length?o(0):r),i.forEach((s,a)=>{t(s,{...o(a),depth:r.depth+1})})}#G(e,n){const t=e.oneOf??e.anyOf??[],r=Object.values(n.mapping??{});if(r.length===0)return t;const i=s=>t.find(a=>a.$ref===s||a["x-original-ref"]===s)??this.#e(s)??{},o=r.filter(s=>s!==n.defaultMapping).map(i);return n.defaultMapping&&o.push(i(n.defaultMapping)),o}getResult(){return this.#a}}export{H as ApiDocsSearchIndexer};
@@ -1,4 +1,5 @@
1
1
  import type { REDOCLY_TEAMS_RBAC } from '@redocly/config';
2
+ import type { AdmonitionProps } from '@redocly/theme/components/Admonition/Admonition';
2
3
  import type { Node } from '@markdoc/markdoc';
3
4
  import type { OpenAPIResponse } from './openapi.js';
4
5
  import type { OpenAPIOperation } from './openapi.js';
@@ -188,7 +189,7 @@ export type MarkdocNode = {
188
189
  };
189
190
  export type AdmonitionNode = {
190
191
  nodeType: typeof nodeTypes.ADMONITION;
191
- admonitionType: 'warning' | 'info' | 'danger' | 'success' | 'default';
192
+ admonitionType: NonNullable<AdmonitionProps['type']>;
192
193
  name?: string;
193
194
  nameTranslationKey?: string;
194
195
  content?: string | Node[] | Node;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/api-docs",
3
- "version": "0.2.0-next.7",
3
+ "version": "0.2.0-next.9",
4
4
  "description": "Redocly API Documentation Library",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE.md",
@@ -31,7 +31,12 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@markdoc/markdoc": "0.5.2",
34
- "@redocly/openapi-core": "2.47.0",
34
+ "@redocly/allof-merge": "0.6.9",
35
+ "@redocly/config": "0.56.0",
36
+ "@redocly/openapi-core": "2.51.2",
37
+ "@redocly/redoc-opentelemetry": "0.2.4",
38
+ "@redocly/replay": "0.28.0-next.8",
39
+ "@redocly/theme": "^0.69.0-next.8",
35
40
  "dompurify": "3.4.13",
36
41
  "fast-xml-parser": "5.7.3",
37
42
  "graphql": "16.14.2",
@@ -41,18 +46,13 @@
41
46
  "js-yaml": "4.3.1",
42
47
  "json-pointer": "^0.6.2",
43
48
  "linkedom": "^0.18.12",
44
- "openapi-sampler": "^1.7.2",
49
+ "openapi-sampler": "^1.7.5",
45
50
  "prismjs": "1.30.0",
46
51
  "react-router": "^8.3.0",
47
52
  "slugify": "^1.4.7",
48
53
  "swagger2openapi": "^7.0.8",
49
54
  "url-template": "^2.0.8",
50
- "web-vitals": "3.3.1",
51
- "@redocly/allof-merge": "0.6.9",
52
- "@redocly/config": "0.55.0",
53
- "@redocly/redoc-opentelemetry": "0.2.4",
54
- "@redocly/replay": "0.28.0-next.6",
55
- "@redocly/theme": "^0.69.0-next.6"
55
+ "web-vitals": "3.3.1"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@microsoft/api-extractor": "7.58.2",
@@ -68,8 +68,8 @@
68
68
  "@types/react-dom": "^19.2.3",
69
69
  "@types/swagger2openapi": "^7.0.4",
70
70
  "@vitejs/plugin-react": "6.0.1",
71
- "@vitest/browser-playwright": "4.1.10",
72
- "@vitest/coverage-v8": "4.1.10",
71
+ "@vitest/browser-playwright": "4.1.11",
72
+ "@vitest/coverage-v8": "4.1.11",
73
73
  "esbuild": "0.28.1",
74
74
  "flexsearch": "^0.8.2",
75
75
  "globals": "^16.5.0",
@@ -82,8 +82,8 @@
82
82
  "tsx": "^4.20.6",
83
83
  "typescript": "6.0.3",
84
84
  "url": "~0.11.0",
85
- "vite": "8.1.0",
86
- "vitest": "4.1.10",
85
+ "vite": "8.2.2",
86
+ "vitest": "4.1.11",
87
87
  "vitest-browser-react": "^2.0.2"
88
88
  },
89
89
  "nx": {