@redocly/openapi-docs 3.20.0-next.1 → 3.20.0-next.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import{jsx as e,Fragment as d,jsxs as s}from"react/jsx-runtime";import{memo as p,useCallback as f}from"react";import{getPathPrefix as x,combineUrls as g}from"@redocly/theme/core/openapi";import{DocumentIcon as w}from"@redocly/theme/icons/DocumentIcon/DocumentIcon";import{JsonIcon as b}from"@redocly/theme/icons/JsonIcon/JsonIcon";import{FileIcon as u}from"@redocly/theme/icons/FileIcon/FileIcon";import{DownloadButton as h}from"@redocly/theme/components/Buttons/DownloadButton";import{useTelemetry as y}from"../../hooks/index.js";import{styled as r}from"../../styled-components.js";function v({downloadObjects:t}){const l=y(),n=x(),c=f(o=>{switch(o){case"yaml":return e(w,{});case"json":return e(b,{});default:return e(u,{})}},[]);return t?e(D,{children:(t||[]).map(({title:o,url:a,iconType:m})=>{const i=n?g(n,a):a;return s(k,{onClick:()=>{l.sendDownloadDefinitionClickedMessage()},children:[s(j,{children:[c(m),e("a",{href:i,target:"_blank",download:!0,rel:"noreferrer",children:o})]}),e(h,{data:i})]},o)})}):e(d,{})}const J=p(v),k=r.div`
1
+ import{jsx as e,Fragment as m,jsxs as s}from"react/jsx-runtime";import{memo as p,useCallback as f}from"react";import{getPathPrefix as w,combineUrls as x}from"@redocly/theme/core/openapi";import{DocumentIcon as g}from"@redocly/theme/icons/DocumentIcon/DocumentIcon";import{JsonIcon as b}from"@redocly/theme/icons/JsonIcon/JsonIcon";import{FileIcon as h}from"@redocly/theme/icons/FileIcon/FileIcon";import{DownloadButton as u}from"@redocly/theme/components/Buttons/DownloadButton";import{transformStringToTelemetryId as y}from"../../utils/helpers.js";import{useTelemetry as v}from"../../hooks/index.js";import{styled as n}from"../../styled-components.js";function j({downloadObjects:t}){const c=v(),i=w(),l=f(o=>{switch(o){case"yaml":return e(g,{});case"json":return e(b,{});default:return e(h,{})}},[]);return t?e(C,{children:(t||[]).map(({title:o,url:a,iconType:d})=>{const r=i?x(i,a):a;return s(k,{onClick:()=>{c.sendDownloadDefinitionClickedMessage([{id:y("definition",window.location.hostname,o),object:"definition",uri:new URL(r,window.location.origin).href}])},children:[s(D,{children:[l(d),e("a",{href:r,target:"_blank",download:!0,rel:"noreferrer",children:o})]}),e(u,{data:r})]},o)})}):e(m,{})}const L=p(j),k=n.div`
2
2
  display: flex;
3
3
  align-items: baseline;
4
4
  justify-content: space-between;
@@ -10,7 +10,7 @@ import{jsx as e,Fragment as d,jsxs as s}from"react/jsx-runtime";import{memo as p
10
10
  padding-bottom: 0px;
11
11
  border-bottom: none;
12
12
  }
13
- `,j=r.span`
13
+ `,D=n.span`
14
14
  display: flex;
15
15
  width: calc(100% - 25px);
16
16
  gap: var(--spacing-xs);
@@ -28,7 +28,7 @@ import{jsx as e,Fragment as d,jsxs as s}from"react/jsx-runtime";import{memo as p
28
28
  overflow: hidden;
29
29
  white-space: nowrap;
30
30
  }
31
- `,D=r.div`
31
+ `,C=n.div`
32
32
  display: flex;
33
33
  align-items: center;
34
34
  align-self: flex-start;
@@ -36,4 +36,4 @@ import{jsx as e,Fragment as d,jsxs as s}from"react/jsx-runtime";import{memo as p
36
36
  flex-direction: column;
37
37
  gap: var(--spacing-sm);
38
38
  font-size: var(--font-size-base);
39
- `;export{J as DownloadSpecification};
39
+ `;export{L as DownloadSpecification};
@@ -1,3 +1,3 @@
1
- import{jsx as n}from"react/jsx-runtime";import{useAtom as d}from"jotai";import{MaximizeIcon as m}from"@redocly/theme/icons/MaximizeIcon/MaximizeIcon";import{Button as c}from"@redocly/theme/components/Button/Button";import{operationStore as x}from"../../jotai/operation.js";import{useTelemetry as u,useTranslate as f}from"../../hooks/index.js";import{styled as A}from"../../styled-components.js";const _=({operationPointer:a,type:e,onPanelToggle:s})=>{const l=f(),[t,r]=d(x(a)),i=u(),p=()=>{const o=!t[e].expandedAll;i.sendExpandCollapseAllClickedMessage([{id:`expand-collapse-${e}-panel`,object:"expand_collapse_all",uri:window.location.href,isExpanded:o}]),r({[e]:{expandedAll:o}}),s?.(o,e==="request"?"request":"responses")};return n(g,{icon:n(m,{}),iconPosition:"right",size:"small",variant:"ghost",onClick:p,children:t[e].expandedAll?l("openapi.collapseAll","Collapse all"):l("openapi.expandAll","Expand all")})},g=A(c)`
1
+ import{jsx as n}from"react/jsx-runtime";import{useAtom as d}from"jotai";import{MaximizeIcon as m}from"@redocly/theme/icons/MaximizeIcon/MaximizeIcon";import{Button as c}from"@redocly/theme/components/Button/Button";import{operationStore as x}from"../../jotai/operation.js";import{useTelemetry as u,useTranslate as f}from"../../hooks/index.js";import{styled as A}from"../../styled-components.js";const b=({operationPointer:a,type:o,onPanelToggle:r})=>{const t=f(),[l,s]=d(x(a)),i=u(),p=()=>{const e=!l[o].expandedAll;i.sendExpandCollapseAllClickedMessage([{object:"button",id:`expand-collapse-${o}-panel`,uri:window.location.href,isExpanded:e}]),s({[o]:{expandedAll:e}}),r?.(e,o==="request"?"request":"responses")};return n(g,{icon:n(m,{}),iconPosition:"right",size:"small",variant:"ghost",onClick:p,children:l[o].expandedAll?t("openapi.collapseAll","Collapse all"):t("openapi.expandAll","Expand all")})},g=A(c)`
2
2
  margin-left: auto;
3
- `;export{_ as ExpandAllButton};
3
+ `;export{b as ExpandAllButton};
@@ -1 +1 @@
1
- import{jsx as a,jsxs as I}from"react/jsx-runtime";import{useLayoutEffect as j,useRef as A,useState as w,useCallback as S,memo as V,useMemo as E}from"react";import{useAtomValue as H,useSetAtom as W}from"jotai";import{Button as _}from"@redocly/theme/components/Button/Button";import{OverflowMenuVerticalIcon as v}from"@redocly/theme/icons/OverflowMenuVerticalIcon/OverflowMenuVerticalIcon";import{Tooltip as D}from"@redocly/theme/components/Tooltip/Tooltip";import{LanguageDropdown as M}from"./LanguageDropdown.js";import{languageAtom as R,layoutAtom as O}from"../../jotai/app.js";import{LanguageListContainer as z,LanguageListItem as B,Container as G}from"./styled.js";import{LanguageItem as P}from"./LanguageItem.js";import{DROPDOWN_TRIGGER_WIDTH as N,ITEM_WIDTH as L}from"./constants.js";import{LanguageListSkeleton as $}from"../common/Skeleton/LanguageListSkeleton.js";import{useTelemetry as q}from"../../hooks/index.js";function F({languages:o,activeLanguage:t,translate:r}){const[n,l]=w([]),[s,u]=w([]),d=q(),g=A(null),k=H(O),h=W(R),p=e=>{d.sendSelectLanguageClickedMessage([{object:"select_language",language:e}])},b=e=>{h(e),p(e)},x=e=>{const m=s.findIndex(i=>i.key===e);if(m!==-1){const i=[...s],c=[...n];y(c,i,m),l(c),u(i),p(e),h(e)}},f=S(()=>{const e=g?.current?.offsetWidth;if(!e)return;const{newVisibleItems:m,newHiddenItems:i}=J(e,[...o]),c=i.findIndex(T=>T.key===t);c!==-1&&y(m,i,c),l(m),u(i)},[t,o]);j(()=>(f(),window.addEventListener("resize",f),()=>{window.removeEventListener("resize",f)}),[k,t]);const C=E(()=>n.length>=5||s.length?"space-between":"start",[s.length,n.length]);return I(G,{ref:g,children:[I(z,{$justifyContent:C,children:[!n.length&&a($,{}),n.map(e=>a(B,{onClick:()=>b(e.key),active:t===e.key,children:a(P,{item:e,withIcon:!0})},e.key))]}),s.length?a(M,{activeTab:t,samples:s,onChange:x,trigger:a(D,{tip:r("openapi.languages.moreButton.tooltipText","View more languages"),arrowPosition:"right",placement:"top",children:a(_,{icon:a(v,{}),"aria-label":"More languages",variant:"text",style:{height:"100%"}})}),withArrow:!1,withCheckmark:!1,width:156}):null]})}const ae=V(F);function J(o,t){let r=0;const n=[],l=[];return t.forEach((s,u)=>{const g=u===t.length-1&&l.length===0?0:N;o&&r+L+g<=o?(n.push(s),r+=L):l.push(s)}),{newVisibleItems:n,newHiddenItems:l}}function y(o,t,r){const n=o[o.length-1];n&&(o[o.length-1]=t[r],t[r]=n)}export{ae as LanguageList};
1
+ import{jsx as a,jsxs as w}from"react/jsx-runtime";import{useLayoutEffect as _,useRef as j,useState as I,useCallback as A,memo as S,useMemo as V}from"react";import{useAtomValue as E,useSetAtom as H}from"jotai";import{Button as W}from"@redocly/theme/components/Button/Button";import{OverflowMenuVerticalIcon as v}from"@redocly/theme/icons/OverflowMenuVerticalIcon/OverflowMenuVerticalIcon";import{Tooltip as D}from"@redocly/theme/components/Tooltip/Tooltip";import{LanguageDropdown as M}from"./LanguageDropdown.js";import{languageAtom as R,layoutAtom as O}from"../../jotai/app.js";import{LanguageListContainer as z,LanguageListItem as B,Container as G}from"./styled.js";import{LanguageItem as P}from"./LanguageItem.js";import{DROPDOWN_TRIGGER_WIDTH as $,ITEM_WIDTH as L}from"./constants.js";import{LanguageListSkeleton as N}from"../common/Skeleton/LanguageListSkeleton.js";import{useTelemetry as q}from"../../hooks/index.js";function F({languages:o,activeLanguage:e,translate:r}){const[n,l]=I([]),[s,c]=I([]),d=q(),g=j(null),b=E(O),h=H(R),p=t=>{d.sendSelectLanguageClickedMessage([{object:"button",id:`button_select_language_${t}`,uri:window.location.href,language:t}])},k=t=>{h(t),p(t)},x=t=>{const m=s.findIndex(i=>i.key===t);if(m!==-1){const i=[...s],u=[...n];y(u,i,m),l(u),c(i),p(t),h(t)}},f=A(()=>{const t=g?.current?.offsetWidth;if(!t)return;const{newVisibleItems:m,newHiddenItems:i}=J(t,[...o]),u=i.findIndex(T=>T.key===e);u!==-1&&y(m,i,u),l(m),c(i)},[e,o]);_(()=>(f(),window.addEventListener("resize",f),()=>{window.removeEventListener("resize",f)}),[b,e]);const C=V(()=>n.length>=5||s.length?"space-between":"start",[s.length,n.length]);return w(G,{ref:g,children:[w(z,{$justifyContent:C,children:[!n.length&&a(N,{}),n.map(t=>a(B,{onClick:()=>k(t.key),active:e===t.key,children:a(P,{item:t,withIcon:!0})},t.key))]}),s.length?a(M,{activeTab:e,samples:s,onChange:x,trigger:a(D,{tip:r("openapi.languages.moreButton.tooltipText","View more languages"),arrowPosition:"right",placement:"top",children:a(W,{icon:a(v,{}),"aria-label":"More languages",variant:"text",style:{height:"100%"}})}),withArrow:!1,withCheckmark:!1,width:156}):null]})}const at=S(F);function J(o,e){let r=0;const n=[],l=[];return e.forEach((s,c)=>{const g=c===e.length-1&&l.length===0?0:$;o&&r+L+g<=o?(n.push(s),r+=L):l.push(s)}),{newVisibleItems:n,newHiddenItems:l}}function y(o,e,r){const n=o[o.length-1];n&&(o[o.length-1]=e[r],e[r]=n)}export{at as LanguageList};
@@ -1,3 +1,3 @@
1
1
  import type { PropsWithChildren } from 'react';
2
2
  import type { RedoclyOpenAPIDocsProps } from './types.js';
3
- export declare function RedoclyOpenAPIDocs({ onLoaded, children, store, withCommonStyles, router, }: PropsWithChildren<Partial<RedoclyOpenAPIDocsProps>>): import("react/jsx-runtime").JSX.Element | null;
3
+ export declare function RedoclyOpenAPIDocs({ onLoaded, children, store, withCommonStyles, router, telemetryConfig, }: PropsWithChildren<Partial<RedoclyOpenAPIDocsProps>>): import("react/jsx-runtime").JSX.Element | null;
@@ -1 +1 @@
1
- import{jsx as t,jsxs as s,Fragment as x}from"react/jsx-runtime";import{memo as C,useRef as O,useEffect as T}from"react";import{LayoutVariant as d}from"@redocly/config";import{useSetAtom as j}from"jotai";import{ThreePanelLayout as A}from"@redocly/theme/layouts/ThreePanelLayout";import{SidebarLogo as I}from"@redocly/theme/components/SidebarLogo/SidebarLogo";import{GlobalStyle as M,useMount as _}from"@redocly/theme/core/openapi";import{StoreProvider as N}from"./Providers.js";import{Overlay as v}from"../Overlay.js";import{RedocWrap as D}from"./styled.js";import{StickyResponsiveSidebar as V}from"../StickySidebar/index.js";import{SideMenu as k}from"../SideMenu/index.js";import{Content as B}from"../Content/index.js";import{useContentItems as K,useUppercase2LowercaseRedirect as F,useTelemetry as H,usePerformanceMetrics as U}from"../../hooks/index.js";import{withRouter as Y}from"../../hoc/withRouter.js";import{withStore as G}from"../../hoc/withStore.js";import{compose as W}from"../../utils/index.js";import{useLicense as q}from"../../hooks/useLicense.js";import{allOperationsAtom as z}from"../../jotai/replay.js";const J=W(Y,G,C)(({licenseKey:m,onLoaded:a,children:e,options:o,layout:i,collapsedSidebar:u,parser:c,withCommonStyles:g})=>{const R=O(null),{isValid:l,licenseInfo:S}=q(m),h=j(z),y=H();F();const{contentItems:b,flatItems:f}=K({parser:c,options:o});U({sendTelemetry:p=>{const r=Object.fromEntries(Object.entries(p).map(([E,w])=>[E.toLowerCase(),w]));y.sendPerformanceMetricsMessage([{object:"metrics",cls:r.cls,lcp:r.lcp,fcp:r.fcp,ttfb:r.ttfb}])}}),T(()=>{if(!o.hideReplay&&f.length>0){const p=f.filter(r=>r.type==="operation");h(p)}},[f,o.hideReplay,h]),_(()=>{a?.(),y.sendViewedMessage([{object:"view_stats",layout:i}])});const{hideSidebar:P,scrollYOffset:L}=o||{},n=c.definition?.info?.["x-logo"];return s(x,{children:[g&&t(M,{}),s(D,{className:"redoc-wrap",ref:R,children:[!l&&t(v,{licenseInfo:S}),!P&&s(V,{scrollYOffset:L,className:"menu-content",collapsedSidebar:!u,children:[t(I,{imageUrl:n?.url,href:n?.href||c.definition?.info?.contact?.url,altText:n?.altText,backgroundColor:n?.backgroundColor}),t(k,{items:l?b:[]})]}),s(A,{className:"api-content",id:"api-content",layout:i===d.THREE_PANEL?d.THREE_PANEL:d.STACKED,collapsedSidebar:u,children:[t(B,{items:l?b:[],routingBasePath:o.routingBasePath}),e]})]})]})});function he({onLoaded:m,children:a,store:e,withCommonStyles:o,router:i}){return e?.definition?t(N,{...e,children:t(J,{onLoaded:m,basePath:e.options?.routingBasePath,licenseKey:e.options?.licenseKey,disableRouter:e.options?.disableRouter,withCommonStyles:o,router:i,children:a})}):null}export{he as RedoclyOpenAPIDocs};
1
+ import{jsx as e,jsxs as c,Fragment as x}from"react/jsx-runtime";import{memo as E,useRef as C,useEffect as O,useMemo as j}from"react";import{LayoutVariant as u}from"@redocly/config";import{useSetAtom as A}from"jotai";import{ThreePanelLayout as I}from"@redocly/theme/layouts/ThreePanelLayout";import{SidebarLogo as M}from"@redocly/theme/components/SidebarLogo/SidebarLogo";import{GlobalStyle as v,useMount as N}from"@redocly/theme/core/openapi";import{RedocTelemetry as _}from"../../telemetry/RedocTelemetry.js";import{StoreProvider as D}from"./Providers.js";import{Overlay as V}from"../Overlay.js";import{RedocWrap as k}from"./styled.js";import{StickyResponsiveSidebar as B}from"../StickySidebar/index.js";import{SideMenu as K}from"../SideMenu/index.js";import{Content as F}from"../Content/index.js";import{useContentItems as H,useUppercase2LowercaseRedirect as U,useTelemetry as Y,usePerformanceMetrics as G}from"../../hooks/index.js";import{withRouter as W}from"../../hoc/withRouter.js";import{withStore as q}from"../../hoc/withStore.js";import{compose as z}from"../../utils/index.js";import{useLicense as J}from"../../hooks/useLicense.js";import{allOperationsAtom as Q}from"../../jotai/replay.js";import{TelemetryContext as X}from"../../contexts/telemetry.js";const Z=z(W,q,E)(({licenseKey:a,onLoaded:l,children:o,options:t,layout:s,collapsedSidebar:i,parser:n,withCommonStyles:b})=>{const R=C(null),{isValid:f,licenseInfo:g}=J(a),h=A(Q),y=Y();U();const{contentItems:w,flatItems:p}=H({parser:n,options:t});G({sendTelemetry:d=>{const r=Object.fromEntries(Object.entries(d).map(([T,L])=>[T.toLowerCase(),L]));y.sendPerformanceMetricsMessage([{id:"metrics",object:"metrics",uri:typeof window<"u"?window.location.href:"",cls:r.cls,lcp:r.lcp,fcp:r.fcp,ttfb:r.ttfb}])}}),O(()=>{if(!t.hideReplay&&p.length>0){const d=p.filter(r=>r.type==="operation");h(d)}},[p,t.hideReplay,h]),N(()=>{l?.(),y.sendViewedMessage([{id:window.location.href,object:"page",uri:window.location.href,layout:s}])});const{hideSidebar:P,scrollYOffset:S}=t||{},m=n.definition?.info?.["x-logo"];return c(x,{children:[b&&e(v,{}),c(k,{className:"redoc-wrap",ref:R,children:[!f&&e(V,{licenseInfo:g}),!P&&c(B,{scrollYOffset:S,className:"menu-content",collapsedSidebar:!i,children:[e(M,{imageUrl:m?.url,href:m?.href||n.definition?.info?.contact?.url,altText:m?.altText,backgroundColor:m?.backgroundColor}),e(K,{items:f?w:[]})]}),c(I,{className:"api-content",id:"api-content",layout:s===u.THREE_PANEL?u.THREE_PANEL:u.STACKED,collapsedSidebar:i,children:[e(F,{items:f?w:[],routingBasePath:t.routingBasePath}),o]})]})]})});function ge({onLoaded:a,children:l,store:o,withCommonStyles:t,router:s,telemetryConfig:i}){const n=j(()=>new _({specType:"openapi",serviceName:"realm-ui",...i}),[i]);return o?.definition?e(X.Provider,{value:n,children:e(D,{...o,children:e(Z,{onLoaded:a,basePath:o.options?.routingBasePath,licenseKey:o.options?.licenseKey,disableRouter:o.options?.disableRouter,withCommonStyles:t,router:s,children:l})})}):null}export{ge as RedoclyOpenAPIDocs};
@@ -9,6 +9,11 @@ export interface RedoclyOpenAPIDocsProps extends RoutingProps, StoreProps {
9
9
  store?: StoreProviderProps;
10
10
  licenseKey?: string;
11
11
  withCommonStyles?: boolean;
12
+ telemetryConfig?: {
13
+ collectorUrl?: string;
14
+ disabled?: boolean;
15
+ serviceVersion?: string;
16
+ };
12
17
  }
13
18
  export interface StoreProviderProps {
14
19
  options?: RedocConfig;
@@ -1 +1 @@
1
- import{jsx as o,Fragment as M,jsxs as z}from"react/jsx-runtime";import{lazy as H,memo as J,Suspense as K,useCallback as m,useRef as W,useState as w}from"react";import{useAtom as u,useAtomValue as p}from"jotai";import Q from"deepmerge";const X=H(async()=>import("@redocly/replay").then(e=>({default:e.ReplayOverlay})));import{Button as Y}from"@redocly/theme/components/Button/Button";import{useFocusTrap as Z,useModalScrollLock as $}from"@redocly/theme/core/openapi";import{RocketIcon as ee}from"@redocly/theme/icons/RocketIcon/RocketIcon";import{CircleDashIcon as te}from"@redocly/theme/icons/CircleDashIcon/CircleDashIcon";import{Portal as oe}from"@redocly/theme/components/Portal/Portal";import{useConfigureReplay as re}from"@redocly/theme/ext/use-configure-replay";import{globalOptionsAtom as ne,globalStoreAtom as ae}from"../../jotai/store.js";import{allOperationsAtom as se,replayStateAtom as ie}from"../../jotai/replay.js";import{allOperations as le,getDefaultOperationStore as me}from"../../jotai/operation.js";import{LOADING_STATE as n}from"../../constants.js";import{environmentAtom as pe,userClaimsAtom as ce}from"../../jotai/app.js";import{convertOperationToReplayValueForRedoc as fe}from"./utils.js";import{useTranslate as ue,useTelemetry as de}from"../../hooks/index.js";import{JsonPointer as ye}from"../../utils/index.js";import{getDefaultCollectorUrl as he}from"../../utils/telemetry.js";import{createTryItOpenEvent as Oe,createTryItSentEvent as Ie}from"../../events/index.js";import{joinWithSeparator as Re}from"../../services/history/helpers.js";import{HTTPSnippet as ge}from"../../services/code-samples/httpsnippet/index.js";function ve({operation:e,corsProxyUrl:P,fullOpenApi:d}){const y=ue(),q=de(),h=W(null),O=p(ne),{oAuth2RedirectURI:E,routingBasePath:c}=O,I=p(se),{parser:R,options:{events:a}}=p(ae),g=p(ce),[s,N]=w(!1),[l,v]=u(ie),[A,S]=u(le),[[,V],T]=u(pe),{config:j,refresh:D}=re({userClaims:g,info:R?.definition.info,operation:{name:e.name,path:e.path,operationId:e.operationId||"",href:e.href,method:e.httpVerb},servers:e.servers},s);Z(h),$(s);const x=m(()=>D(),[D]),G=m(({operations:t,environment:i,environments:f})=>{const k=t.reduce((b,r)=>{r.requestValues.body=r.requestValues.body instanceof URLSearchParams?Object.fromEntries(r.requestValues.body.entries()):r.requestValues.body;const{path:F,method:B}=r.apiPath,L=ye.compile(["paths",F,B]);return b[L]=Q(me(L),r),b},{});S({...A,...k}),T({environment:i,environments:f})},[A,S,T]),C=()=>{if(l!==n.LOADING){if(!s&&(q.sendTryItOpenedMessage(),a?.tryItOpen&&e)){const t=Oe({operation:e});a.tryItOpen(t)}N(!s)}l===n.NOT_LOADED&&v(n.LOADING)},U=m(t=>{if(a?.tryItSent&&e){const i=Ie({operation:e,isSuccess:t});a.tryItSent(i)}},[a,e]),_=m(t=>{if(!t)return;const i=I.find(f=>f.operationId===t);return Re(c,i?.href)},[I,c]);return d?z(M,{children:[o(Y,{onClick:C,variant:"primary",iconPosition:"left",icon:l===n.LOADING?o(te,{}):o(ee,{}),children:l===n.LOADING?y("openapi.loading","Loading..."):y("openapi.tryIt","Try it")}),s&&o(K,{children:o(oe,{mountId:"api-content",children:o("div",{ref:h,children:o(X,{activeOperationId:e.operationId||e.pointer,api:d,onRequestChange:G,onClose:C,onLoad:()=>v(n.LOADED),settings:{corsProxyUrl:P,selectedEnvironment:V,apiId:R?.definition.info?.["x-metadata"]?.apiId,oAuth2RedirectURI:E,disableCollectionsTab:!0,storageKey:c,telemetry:{tracerName:"try-it",collectorUrl:he()},HTTPSnippet:ge,convertOperationToReplayValue:fe(g,j,O),getOperationUrl:_,onRequestReset:x},onRequestSent:U})})})})]}):null}const He=J(ve);export{He as Replay};
1
+ import{jsx as o,Fragment as B,jsxs as M}from"react/jsx-runtime";import{lazy as z,memo as H,Suspense as J,useCallback as m,useRef as K,useState as W}from"react";import{useAtom as d,useAtomValue as p}from"jotai";import Q from"deepmerge";const X=z(async()=>import("@redocly/replay").then(e=>({default:e.ReplayOverlay})));import{Button as Y}from"@redocly/theme/components/Button/Button";import{useFocusTrap as Z,useModalScrollLock as $}from"@redocly/theme/core/openapi";import{RocketIcon as ee}from"@redocly/theme/icons/RocketIcon/RocketIcon";import{CircleDashIcon as te}from"@redocly/theme/icons/CircleDashIcon/CircleDashIcon";import{Portal as oe}from"@redocly/theme/components/Portal/Portal";import{useConfigureReplay as re}from"@redocly/theme/ext/use-configure-replay";import{globalOptionsAtom as ne,globalStoreAtom as ae}from"../../jotai/store.js";import{allOperationsAtom as se,replayStateAtom as ie}from"../../jotai/replay.js";import{allOperations as le,getDefaultOperationStore as me}from"../../jotai/operation.js";import{LOADING_STATE as n}from"../../constants.js";import{environmentAtom as pe,userClaimsAtom as ce}from"../../jotai/app.js";import{convertOperationToReplayValueForRedoc as fe}from"./utils.js";import{useTranslate as de,useTelemetry as ue}from"../../hooks/index.js";import{JsonPointer as ye}from"../../utils/index.js";import{getDefaultCollectorUrl as he}from"../../utils/telemetry.js";import{createTryItOpenEvent as Oe,createTryItSentEvent as Ie}from"../../events/index.js";import{joinWithSeparator as Re}from"../../services/history/helpers.js";import{HTTPSnippet as ge}from"../../services/code-samples/httpsnippet/index.js";function ve({operation:e,corsProxyUrl:P,fullOpenApi:u}){const y=de(),q=ue(),h=K(null),O=p(ne),{oAuth2RedirectURI:E,routingBasePath:c}=O,I=p(se),{parser:R,options:{events:a}}=p(ae),g=p(ce),[s,N]=W(!1),[l,v]=d(ie),[A,S]=d(le),[[,V],T]=d(pe),{config:j,refresh:D}=re({userClaims:g,info:R?.definition.info,operation:{name:e.name,path:e.path,operationId:e.operationId||"",href:e.href,method:e.httpVerb},servers:e.servers},s);Z(h),$(s);const x=m(()=>D(),[D]),_=m(({operations:t,environment:i,environments:f})=>{const k=t.reduce((C,r)=>{r.requestValues.body=r.requestValues.body instanceof URLSearchParams?Object.fromEntries(r.requestValues.body.entries()):r.requestValues.body;const{path:w,method:F}=r.apiPath,L=ye.compile(["paths",w,F]);return C[L]=Q(me(L),r),C},{});S({...A,...k}),T({environment:i,environments:f})},[A,S,T]),b=()=>{if(l!==n.LOADING){if(!s&&(q.sendTryItOpenedMessage([{id:"try-it-opened",object:"try_it",uri:typeof window<"u"?window.location.href:""}]),a?.tryItOpen&&e)){const t=Oe({operation:e});a.tryItOpen(t)}N(!s)}l===n.NOT_LOADED&&v(n.LOADING)},G=m(t=>{if(a?.tryItSent&&e){const i=Ie({operation:e,isSuccess:t});a.tryItSent(i)}},[a,e]),U=m(t=>{if(!t)return;const i=I.find(f=>f.operationId===t);return Re(c,i?.href)},[I,c]);return u?M(B,{children:[o(Y,{onClick:b,variant:"primary",iconPosition:"left",icon:l===n.LOADING?o(te,{}):o(ee,{}),children:l===n.LOADING?y("openapi.loading","Loading..."):y("openapi.tryIt","Try it")}),s&&o(J,{children:o(oe,{mountId:"api-content",children:o("div",{ref:h,children:o(X,{activeOperationId:e.operationId||e.pointer,api:u,onRequestChange:_,onClose:b,onLoad:()=>v(n.LOADED),settings:{corsProxyUrl:P,selectedEnvironment:V,apiId:R?.definition.info?.["x-metadata"]?.apiId,oAuth2RedirectURI:E,disableCollectionsTab:!0,storageKey:c,telemetry:{tracerName:"try-it",collectorUrl:he()},HTTPSnippet:ge,convertOperationToReplayValue:fe(g,j,O),getOperationUrl:U,onRequestReset:x},onRequestSent:G})})})})]}):null}const ze=H(ve);export{ze as Replay};
@@ -1 +1 @@
1
- import{jsx as h,Fragment as u,jsxs as E}from"react/jsx-runtime";import{memo as O}from"react";import{useAtom as g}from"jotai";import{ExampleSwitch as v,useExampleKey as j}from"../Samples/index.js";import{useActivateExample as w,useTelemetry as K}from"../../hooks/index.js";import{operationStore as b}from"../../jotai/operation.js";function C({mediaType:e,mediaContent:l,renderSample:r}){const m=K(),p=e.operation.pointer,[n,i]=g(b(p)),s=e.examples||e.formExamples||{},t=Object.keys(s),x=w(l),{exampleKey:c}=j(e.operation,s),a=t[n.activeOneOf[e?.examplesPointer||e.operation.pointer]]||c;return!t.length||t.length===1?r():E(u,{children:[h(v,{examples:s,exampleKey:a,onChange:o=>{const f=e.examplesPointer&&e.examplesPointer.startsWith(e.operation.pointer)?e.examplesPointer:e.operation.pointer;m.sendExamplesSwitcherClickedMessage([{id:"examples-switcher-request-body",uri:window.location.href,object:"examples_switcher",exampleNumber:t.indexOf(o),totalExamples:t.length}]),i({...n,activeExampleName:o,activeOneOf:{...n.activeOneOf,[f]:t.indexOf(o)},requestValues:{body:null}}),x(o)}}),r(a)]})}const M=O(C);export{M as Example};
1
+ import{jsx as h,Fragment as u,jsxs as E}from"react/jsx-runtime";import{memo as O}from"react";import{useAtom as g}from"jotai";import{ExampleSwitch as v,useExampleKey as b}from"../Samples/index.js";import{useActivateExample as j,useTelemetry as K}from"../../hooks/index.js";import{operationStore as w}from"../../jotai/operation.js";function C({mediaType:e,mediaContent:l,renderSample:r}){const m=K(),p=e.operation.pointer,[n,i]=g(w(p)),s=e.examples||e.formExamples||{},t=Object.keys(s),x=j(l),{exampleKey:c}=b(e.operation,s),a=t[n.activeOneOf[e?.examplesPointer||e.operation.pointer]]||c;return!t.length||t.length===1?r():E(u,{children:[h(v,{examples:s,exampleKey:a,onChange:o=>{const f=e.examplesPointer&&e.examplesPointer.startsWith(e.operation.pointer)?e.examplesPointer:e.operation.pointer;m.sendExamplesSwitcherClickedMessage([{object:"button",id:"examples-switcher-request-body",uri:window.location.href,exampleNumber:t.indexOf(o),totalExamples:t.length}]),i({...n,activeExampleName:o,activeOneOf:{...n.activeOneOf,[f]:t.indexOf(o)},requestValues:{body:null}}),x(o)}}),r(a)]})}const M=O(C);export{M as Example};
@@ -1,4 +1,4 @@
1
- import{jsx as o,jsxs as D}from"react/jsx-runtime";import{memo as T,useCallback as L,useMemo as k}from"react";import{useAtomValue as y,useAtom as _}from"jotai";import{PanelHeader as U}from"@redocly/theme/components/Panel/PanelHeader";import{PayloadSamples as W}from"../PayloadSamples/index.js";import{CodeSample as B}from"./CodeSample.js";import{useCodeSamples as F}from"./useCodeSamples.js";import{isPayloadSample as H}from"../../models/index.js";import{createCodeSampleCopyEvent as O,createLanguageSwitchEvent as V}from"../../events/index.js";import{globalStoreAtom as $}from"../../jotai/store.js";import{ServerListDropdown as z}from"../ServerListDropdown/index.js";import{LanguageDropdown as G}from"../Language/index.js";import{activeMimeNameAtom as J,languageAtom as K}from"../../jotai/app.js";import{Replay as A}from"../Replay/index.js";import{CodeBlockPanel as w}from"../common/index.js";import{useActiveWithFallback as Q,useTelemetry as X}from"../../hooks/index.js";import{operationStore as Y}from"../../jotai/operation.js";import{styled as S}from"../../styled-components.js";function Z({operation:a,disableFooter:P,onPanelToggle:v,...p}){const m=X(),[{activeLanguage:q,languages:c},R]=_(K),{samples:n}=F(a),{parser:d,options:{events:l,corsProxyUrl:g,hideReplay:j}}=y($),i=!P&&!a.isWebhook&&!j&&!a.hideReplay,t=!!c?.length,u=Q(n,q),E=e=>{R(e),m.sendSelectLanguageClickedMessage([{object:"select_language",language:e}]);const r=c?.find(s=>s.key===e);if(l?.codeSamplesLanguageSwitch&&r){const s=V({operation:a,sample:{lang:r.lang,label:r.title}});l.codeSamplesLanguageSwitch(s)}},h=y(J),{activeExampleName:C}=y(Y(a.pointer)),f=L(({lang:e,title:r})=>()=>{const s=O({operation:a,label:r,lang:e,type:"request",activeMimeName:h,activeExampleName:C});m.sendCopyCodeSnippetClickedMessage([{object:"code_snippet",snippetType:"request",language:e}]),l?.codeSamplesCopy?.(s)},[a,m,l,h,C]),b=L(e=>{v?.(e,"request-samples")},[v]),x=()=>D(I,{isExpandable:!1,withReplay:!t&&i,children:[o(ee,{operation:a}),t&&o(G,{activeTab:u,samples:n,onChange:E}),!t&&i&&o(A,{operation:a,corsProxyUrl:g,fullOpenApi:d.definition})]}),M=k(()=>{if(i&&t)return o(ae,{children:o(A,{operation:a,corsProxyUrl:g,fullOpenApi:d.definition})})},[i,t,a,g,d.definition]),N=k(()=>n.map(e=>e.key===u?o("div",{children:H(e)?o(W,{content:e.requestBodyContent,onCopyClick:f(e),onPanelToggle:b,...p}):o(B,{lang:e.lang,source:e.source,externalSample:e,operation:a,onCopyClick:f(e),...p})},e.key+a.id):null),[u,f,b,a,p,n]);return c&&!n.length?o(w,{className:"panel-request-samples",header:x,isExpandable:!1,expanded:!1}):n.length?o(w,{className:"panel-request-samples",header:x,footer:M,isExpandable:!1,children:N}):null}const Ce=T(Z),I=S(U)`
1
+ import{jsx as o,jsxs as N}from"react/jsx-runtime";import{memo as D,useCallback as w,useMemo as L}from"react";import{useAtomValue as y,useAtom as T}from"jotai";import{PanelHeader as U}from"@redocly/theme/components/Panel/PanelHeader";import{PayloadSamples as W}from"../PayloadSamples/index.js";import{CodeSample as B}from"./CodeSample.js";import{useCodeSamples as F}from"./useCodeSamples.js";import{isPayloadSample as H}from"../../models/index.js";import{createCodeSampleCopyEvent as O,createLanguageSwitchEvent as $}from"../../events/index.js";import{globalStoreAtom as V}from"../../jotai/store.js";import{ServerListDropdown as z}from"../ServerListDropdown/index.js";import{LanguageDropdown as G}from"../Language/index.js";import{activeMimeNameAtom as J,languageAtom as K}from"../../jotai/app.js";import{Replay as k}from"../Replay/index.js";import{CodeBlockPanel as A}from"../common/index.js";import{useActiveWithFallback as Q,useTelemetry as X}from"../../hooks/index.js";import{operationStore as Y}from"../../jotai/operation.js";import{styled as S}from"../../styled-components.js";function Z({operation:a,disableFooter:P,onPanelToggle:v,...p}){const c=X(),[{activeLanguage:q,languages:m},R]=T(K),{samples:n}=F(a),{parser:d,options:{events:s,corsProxyUrl:g,hideReplay:j}}=y(V),i=!P&&!a.isWebhook&&!j&&!a.hideReplay,t=!!m?.length,u=Q(n,q),E=e=>{R(e),c.sendSelectLanguageClickedMessage([{id:`button_select_language_${e}`,object:"button",uri:window.location.href,language:e}]);const r=m?.find(l=>l.key===e);if(s?.codeSamplesLanguageSwitch&&r){const l=$({operation:a,sample:{lang:r.lang,label:r.title}});s.codeSamplesLanguageSwitch(l)}},h=y(J),{activeExampleName:b}=y(Y(a.pointer)),f=w(({lang:e,title:r})=>()=>{const l=O({operation:a,label:r,lang:e,type:"request",activeMimeName:h,activeExampleName:b});c.sendCopyCodeSnippetClickedMessage([{id:"copy-code-snippet",object:"code_snippet",uri:window.location.href,snippetType:"request",language:e}]),s?.codeSamplesCopy?.(l)},[a,c,s,h,b]),C=w(e=>{v?.(e,"request-samples")},[v]),x=()=>N(I,{isExpandable:!1,withReplay:!t&&i,children:[o(ee,{operation:a}),t&&o(G,{activeTab:u,samples:n,onChange:E}),!t&&i&&o(k,{operation:a,corsProxyUrl:g,fullOpenApi:d.definition})]}),_=L(()=>{if(i&&t)return o(ae,{children:o(k,{operation:a,corsProxyUrl:g,fullOpenApi:d.definition})})},[i,t,a,g,d.definition]),M=L(()=>n.map(e=>e.key===u?o("div",{children:H(e)?o(W,{content:e.requestBodyContent,onCopyClick:f(e),onPanelToggle:C,...p}):o(B,{lang:e.lang,source:e.source,externalSample:e,operation:a,onCopyClick:f(e),...p})},e.key+a.id):null),[u,f,C,a,p,n]);return m&&!n.length?o(A,{className:"panel-request-samples",header:x,isExpandable:!1,expanded:!1}):n.length?o(A,{className:"panel-request-samples",header:x,footer:_,isExpandable:!1,children:M}):null}const be=D(Z),I=S(U)`
2
2
  flex-wrap: nowrap;
3
3
  ${({withReplay:a})=>a&&"padding: var(--spacing-xs) var(--spacing-sm);"}
4
4
  `,ee=S(z)`
@@ -9,4 +9,4 @@ import{jsx as o,jsxs as D}from"react/jsx-runtime";import{memo as T,useCallback a
9
9
  justify-content: flex-end;
10
10
  border-top: var(--panel-border);
11
11
  padding: var(--spacing-base) var(--spacing-md) var(--spacing-md);
12
- `;export{Ce as RequestSamples};
12
+ `;export{be as RequestSamples};
@@ -1 +1 @@
1
- import{jsx as t}from"react/jsx-runtime";import{memo as b,useCallback as i}from"react";import{useAtomValue as n}from"jotai";import{PayloadSamples as h,StyledCodeBlock as v}from"../PayloadSamples/index.js";import{createCodeSampleCopyEvent as k}from"../../events/index.js";import{globalOptionsAtom as T}from"../../jotai/store.js";import{Summary as g}from"./Summary.js";import{Tabs as x}from"../Tabs/index.js";import{CodeBlockPanel as N}from"../common/index.js";import{useTelemetry as j,useTranslate as A}from"../../hooks/index.js";import{activeMimeNameAtom as E}from"../../jotai/app.js";import{operationStore as M}from"../../jotai/operation.js";function P({operation:o,activeResponseTab:d,onTabChange:f,onPanelToggle:a}){const m=j(),{events:p}=n(T),y=A(),C=o.responses.filter(e=>e.content?.hasSample??!1),s=o.responses.map(({code:e})=>({key:e,title:e})),r=s?.find(({key:e})=>e===d)||s?.[0],l=n(E),{activeExampleName:c}=n(M(o.pointer)),u=i(()=>{m.sendCopyCodeSnippetClickedMessage([{object:"code_snippet",snippetType:"response"}]);const e=k({operation:o,type:"response",activeMimeName:l,activeExampleName:c});p?.codeSamplesCopy?.(e)},[m,o,p,l,c]),S=i(e=>{a?.(e,"response-samples")},[a]);return C.length?t(N,{className:"panel-response-samples",header:()=>t(g,{tabs:t(x,{tabs:s,activeTab:r,onChange:e=>f(e.key)})}),isExpandable:!1,children:o.responses.map(e=>e.code===r.key?t("div",{"data-testid":"response-payload-sample",children:e?.content?.hasSample?t(h,{content:e.content,onCopyClick:u,onPanelToggle:S}):t(v,{source:y("openapi.noResponseContent","No content")})},e.code):null)}):null}const J=b(P);export{J as ResponseSamples};
1
+ import{jsx as t}from"react/jsx-runtime";import{memo as b,useCallback as i}from"react";import{useAtomValue as n}from"jotai";import{PayloadSamples as h,StyledCodeBlock as v}from"../PayloadSamples/index.js";import{createCodeSampleCopyEvent as k}from"../../events/index.js";import{globalOptionsAtom as T}from"../../jotai/store.js";import{Summary as g}from"./Summary.js";import{Tabs as x}from"../Tabs/index.js";import{CodeBlockPanel as N}from"../common/index.js";import{useTelemetry as j,useTranslate as A}from"../../hooks/index.js";import{activeMimeNameAtom as E}from"../../jotai/app.js";import{operationStore as M}from"../../jotai/operation.js";function P({operation:o,activeResponseTab:d,onTabChange:f,onPanelToggle:a}){const m=j(),{events:p}=n(T),y=A(),u=o.responses.filter(e=>e.content?.hasSample??!1),s=o.responses.map(({code:e})=>({key:e,title:e})),r=s?.find(({key:e})=>e===d)||s?.[0],l=n(E),{activeExampleName:c}=n(M(o.pointer)),C=i(()=>{m.sendCopyCodeSnippetClickedMessage([{id:"copy-code-snippet",object:"code_snippet",uri:window.location.href,snippetType:"response"}]);const e=k({operation:o,type:"response",activeMimeName:l,activeExampleName:c});p?.codeSamplesCopy?.(e)},[m,o,p,l,c]),S=i(e=>{a?.(e,"response-samples")},[a]);return u.length?t(N,{className:"panel-response-samples",header:()=>t(g,{tabs:t(x,{tabs:s,activeTab:r,onChange:e=>f(e.key)})}),isExpandable:!1,children:o.responses.map(e=>e.code===r.key?t("div",{"data-testid":"response-payload-sample",children:e?.content?.hasSample?t(h,{content:e.content,onCopyClick:C,onPanelToggle:S}):t(v,{source:y("openapi.noResponseContent","No content")})},e.code):null)}):null}const J=b(P);export{J as ResponseSamples};
@@ -1 +1 @@
1
- import{jsx as r,Fragment as f,jsxs as y}from"react/jsx-runtime";import{useState as h,useRef as C}from"react";import{Portal as b}from"@redocly/theme/components/Portal/Portal";import{useModalScrollLock as w}from"@redocly/theme/core/openapi";import{SecurityButton as M}from"./SecurityButton.js";import{SecurityModal as S}from"./SecurityModal.js";import{useTelemetry as g}from"../../hooks/index.js";function _({securities:t}){const[i,c]=h(!1),l=g(),e=C(null);if(w(i),!t.length)return null;const m=()=>{const o=t.flatMap(s=>s.schemes),n=[...new Set(o.map(s=>s.type))],u=o.length,a=n.length>1,p=Date.now();e.current={securityTypes:n,schemesCount:u,isCombined:a,modalOpenTime:p},l.sendViewSecurityDetailsClickedMessage([{id:"openapi-docs-security-button",object:"button",uri:window.location.href,securityTypes:n,schemesCount:u,isCombined:a}]),c(!0)},d=()=>{if(e.current){const o=Date.now()-e.current.modalOpenTime;l.sendViewSecurityDetailsClosedMessage([{id:"openapi-docs-security-button",object:"button",uri:window.location.href,securityTypes:e.current.securityTypes,schemesCount:e.current.schemesCount,isCombined:e.current.isCombined,timeInModalMs:o}]),e.current=null}c(!1)};return y(f,{children:[r(M,{securities:t,onClick:m}),i&&r(b,{mountId:"api-content",children:r(S,{securities:t,onClose:d})})]})}export{_ as Security};
1
+ import{jsx as r,Fragment as p,jsxs as y}from"react/jsx-runtime";import{useState as h,useRef as C}from"react";import{Portal as b}from"@redocly/theme/components/Portal/Portal";import{useModalScrollLock as w}from"@redocly/theme/core/openapi";import{SecurityButton as M}from"./SecurityButton.js";import{SecurityModal as S}from"./SecurityModal.js";import{useTelemetry as g}from"../../hooks/index.js";function _({securities:t}){const[i,c]=h(!1),l=g(),e=C(null);if(w(i),!t.length)return null;const m=()=>{const o=t.flatMap(s=>s.schemes),n=[...new Set(o.map(s=>s.type))],u=o.length,a=n.length>1,f=Date.now();e.current={securityTypes:n,schemesCount:u,isCombined:a,modalOpenTime:f},l.sendViewSecurityDetailsClickedMessage([{id:"redoc-security-button",object:"button",uri:window.location.href,securityTypes:n,schemesCount:u,isCombined:a}]),c(!0)},d=()=>{if(e.current){const o=Date.now()-e.current.modalOpenTime;l.sendViewSecurityDetailsClosedMessage([{id:"redoc-security-button",object:"button",uri:window.location.href,securityTypes:e.current.securityTypes,schemesCount:e.current.schemesCount,isCombined:e.current.isCombined,timeInModalMs:o}]),e.current=null}c(!1)};return y(p,{children:[r(M,{securities:t,onClick:m}),i&&r(b,{mountId:"api-content",children:r(S,{securities:t,onClose:d})})]})}export{_ as Security};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as f}from"react/jsx-runtime";import{useMemo as S,useCallback as c}from"react";import{useAtom as g,useAtomValue as w}from"jotai";import{DropdownMenu as y}from"@redocly/theme/components/Dropdown/DropdownMenu";import{Dropdown as A}from"@redocly/theme/components/Dropdown/Dropdown";import{getOperationColor as C}from"@redocly/theme/core/openapi";import{HttpVerb as b}from"../common/index.js";import{PathWrapper as k,Path as j,StyledCopyButton as P,StyledDropdownMenuItem as V}from"./styled.js";import{PanelItem as x}from"../PanelItem/index.js";import{joinWithSeparator as D}from"../../services/index.js";import{getServerDisplayName as M,replaceVariables as E}from"../../utils/index.js";import{environmentAtom as N}from"../../jotai/app.js";import{useActiveWithFallback as O,useTelemetry as W}from"../../hooks/index.js";import{getServerEnvName as p}from"../../utils/environments.js";import{createTargetServerSwitchEvent as _}from"../../events/index.js";import{globalStoreAtom as I}from"../../jotai/store.js";const $=({operation:r,className:h})=>{const n=W(),[[d],m]=g(N),{options:{events:i}}=w(I),s=O(r.servers.map(t=>({...t,key:t.url})),d.server),a=c(t=>{t.stopPropagation()},[]),l=c(t=>()=>{if(r.servers.length!==1&&(m({environment:p(t)}),n.sendSwitchServersClickedMessage([{object:"switch_servers",server:p(t)}]),i?.targetServerSwitch&&t)){const o=_({operation:r,serverUrl:t.url});i.targetServerSwitch(o)}},[r,m,n,i]),v=S(()=>r.servers.map(t=>{const o=D(E(t),r.path);return e(V,{onAction:l(t),children:e(x,{header:M(t),title:o,actions:[e(P,{data:o,toasterPlacement:"left",onCopyClick:a},o)],active:t.url===s,withCheckmark:!0})},o)}),[r.servers,r.path,l,a,s]),u=C({isAdditionalOperation:r.isAdditionalOperation,httpVerb:r.httpVerb});return e(A,{className:h,trigger:f(k,{variant:"ghost",children:[e(b,{color:u,children:r.httpVerb}),e(j,{children:r.path})]}),withArrow:!0,children:e(y,{children:v})})};export{$ as ServerListDropdown};
1
+ import{jsx as e,jsxs as v}from"react/jsx-runtime";import{useMemo as w,useCallback as c}from"react";import{useAtom as S,useAtomValue as g}from"jotai";import{DropdownMenu as b}from"@redocly/theme/components/Dropdown/DropdownMenu";import{Dropdown as y}from"@redocly/theme/components/Dropdown/Dropdown";import{getOperationColor as A}from"@redocly/theme/core/openapi";import{HttpVerb as C}from"../common/index.js";import{PathWrapper as k,Path as j,StyledCopyButton as P,StyledDropdownMenuItem as V}from"./styled.js";import{PanelItem as x}from"../PanelItem/index.js";import{joinWithSeparator as D}from"../../services/index.js";import{getServerDisplayName as M,replaceVariables as _}from"../../utils/index.js";import{environmentAtom as E}from"../../jotai/app.js";import{useActiveWithFallback as N,useTelemetry as O}from"../../hooks/index.js";import{getServerEnvName as p}from"../../utils/environments.js";import{createTargetServerSwitchEvent as W}from"../../events/index.js";import{globalStoreAtom as I}from"../../jotai/store.js";const $=({operation:r,className:h})=>{const n=O(),[[d],m]=S(E),{options:{events:i}}=g(I),s=N(r.servers.map(t=>({...t,key:t.url})),d.server),a=c(t=>{t.stopPropagation()},[]),l=c(t=>()=>{if(r.servers.length!==1&&(m({environment:p(t)}),n.sendSwitchServersClickedMessage([{id:"button_switch_servers",object:"button",uri:typeof window<"u"?window.location.href:"",server:p(t)}]),i?.targetServerSwitch&&t)){const o=W({operation:r,serverUrl:t.url});i.targetServerSwitch(o)}},[r,m,n,i]),u=w(()=>r.servers.map(t=>{const o=D(_(t),r.path);return e(V,{onAction:l(t),children:e(x,{header:M(t),title:o,actions:[e(P,{data:o,toasterPlacement:"left",onCopyClick:a},o)],active:t.url===s,withCheckmark:!0})},o)}),[r.servers,r.path,l,a,s]),f=A({isAdditionalOperation:r.isAdditionalOperation,httpVerb:r.httpVerb});return e(y,{className:h,trigger:v(k,{variant:"ghost",children:[e(C,{color:f,children:r.httpVerb}),e(j,{children:r.path})]}),withArrow:!0,children:e(b,{children:u})})};export{$ as ServerListDropdown};
@@ -0,0 +1,3 @@
1
+ import { RedocTelemetry } from '../telemetry/RedocTelemetry.js';
2
+ export declare const TelemetryContext: import("react").Context<RedocTelemetry>;
3
+ export declare function useRedocTelemetry(): RedocTelemetry;
@@ -0,0 +1 @@
1
+ import{createContext as e,useContext as t}from"react";import{RedocTelemetry as o}from"../telemetry/RedocTelemetry.js";const r=new o({specType:"openapi",disabled:!0}),n=e(r);function c(){return t(n)}export{n as TelemetryContext,c as useRedocTelemetry};
@@ -1,2 +1,2 @@
1
- import { useThemeHooks } from '@redocly/theme/core/openapi';
2
- export declare function useTelemetry(): ReturnType<ReturnType<typeof useThemeHooks>['useTelemetry']>;
1
+ import type { RedocTelemetry } from '../telemetry/RedocTelemetry.js';
2
+ export declare function useTelemetry(): RedocTelemetry;
@@ -1 +1 @@
1
- import{useThemeHooks as e}from"@redocly/theme/core/openapi";function o(){return e().useTelemetry()}export{o as useTelemetry};
1
+ import{useRedocTelemetry as e}from"../contexts/telemetry.js";function t(){return e()}export{t as useTelemetry};
package/lib/index.d.ts CHANGED
@@ -53,3 +53,5 @@ export { CustomBadges } from './components/common/Badges.js';
53
53
  export { Metadata } from './components/ApiInfo/Metadata.js';
54
54
  export { useDownloadInfo } from './components/Download/useDownloadInfo.js';
55
55
  export { SECTION_ATTR } from './constants.js';
56
+ export { RedocTelemetry } from './telemetry/RedocTelemetry.js';
57
+ export type { RedocTelemetryConfig, SpecType } from './telemetry/RedocTelemetry.js';
package/lib/index.js CHANGED
@@ -1 +1 @@
1
- import{useAtomValue as e}from"jotai";import{globalOptionsAtom as o}from"./jotai/store.js";import{simplifyAstStructure as n}from"./utils/simplifyAstStructure.js";import{getOperation as x}from"./models/operation.js";import{getServerEnvName as l}from"./utils/environments.js";import{getTagOrGroup as d}from"./models/group.js";import{generateDeepLink as c}from"./components/common/LinkToField.js";import{RequestSamples as g}from"./components/RequestSamples/RequestSamples.js";import{ResponseSamples as P}from"./components/ResponseSamples/ResponseSamples.js";import{RedocSchema as I}from"./components/pluggable/RedocSchema.js";import{RedocExample as w}from"./components/pluggable/RedocExample.js";import{RedoclyOpenAPIDocs as v}from"./components/RedoclyOpenAPIDocs/RedoclyOpenAPIDocs.js";import{StoreProvider as E}from"./components/RedoclyOpenAPIDocs/Providers.js";import{getMarkdownHeaderId as A}from"./components/RedoclyOpenAPIDocs/utils.js";import{safeSlugify as T}from"./utils/string.js";import{JsonPointer as h}from"./utils/JsonPointer.js";import{isOperationName as V}from"./utils/openapi.js";import{pathIncludesLink as F,normalizePath as H}from"./utils/path.js";import{saveTextBeforeHeading as z}from"./utils/saveTextBeforeHeading.js";import{OpenAPIParser as G}from"./services/OpenAPIParser.js";import{buildContentItems as _}from"./services/menu/builder.js";import{normalizeOptions as K}from"./services/config-options/normalizeOptions.js";import{makeDeepLink as U}from"./services/history/helpers.js";function p(){return e(o)}import{EmbeddedReplay as X}from"./components/Replay/EmbeddedReplay.js";import{convertOperationToReplayValue as Z}from"./components/Replay/utils.js";import{SectionContainer as ee}from"./components/SectionContent/index.js";import{Row as re}from"./components/common/panels.js";import{RightPanelContainer as pe}from"./components/SectionContent/index.js";import{Overview as ae}from"./components/Overview/index.js";import{SamplesMiddlePanel as fe,Section as xe,SamplesPanel as ie}from"./components/common/panels.js";import{Heading as se}from"./components/common/OperationItemTitle.js";import{Dropdown as ue}from"./components/common/Dropdown/index.js";import{Markdown as Se}from"./components/Markdown/index.js";import{FieldValueLabel as Oe,FieldLabel as Pe}from"./components/common/Fields/index.js";import{CodeBlockPanel as Ie}from"./components/common/index.js";import{OperationSamplesPanel as we}from"./components/OperationItem/OperationItem.js";import{ExternalDocumentation as ve}from"./components/ExternalDocumentation/index.js";import{PropertyDetails as Ee}from"./components/PropertyDetails/PropertyDetails.js";import{addMarkdownItems as Ae}from"./services/menu/markdown.js";import{getValueFromMdParsedExtension as Te}from"./utils/helpers.js";import{ContentItem as he}from"./components/ContentItem/index.js";import{ExampleSwitch as Ve}from"./components/Samples/ExampleSwitch.js";import{CustomBadges as Fe}from"./components/common/Badges.js";import{Metadata as Ne}from"./components/ApiInfo/Metadata.js";import{useDownloadInfo as qe}from"./components/Download/useDownloadInfo.js";import{SECTION_ATTR as Je}from"./constants.js";export{Ie as CodeBlockPanel,he as ContentItem,Fe as CustomBadges,ue as Dropdown,X as EmbeddedReplay,Ve as ExampleSwitch,ve as ExternalDocumentation,Pe as FieldLabel,Oe as FieldValueLabel,se as Heading,h as JsonPointer,Se as Markdown,Ne as Metadata,G as OpenAPIParser,we as OperationSamplesPanel,ae as Overview,Ee as PropertyDetails,w as RedocExample,I as RedocSchema,v as RedoclyOpenAPIDocs,g as RequestSamples,P as ResponseSamples,pe as RightPanelContainer,re as Row,Je as SECTION_ATTR,fe as SamplesMiddlePanel,ie as SamplesPanel,xe as Section,ee as SectionContainer,E as StoreProvider,Ae as addMarkdownItems,_ as buildContentItems,Z as convertOperationToReplayValue,c as generateDeepLink,A as getMarkdownHeaderId,x as getOperation,l as getServerEnvName,d as getTagOrGroup,Te as getValueFromMdParsedExtension,V as isOperationName,U as makeDeepLink,K as normalizeOptions,H as normalizePath,F as pathIncludesLink,T as safeSlugify,z as saveTextBeforeHeading,n as simplifyAstStructure,qe as useDownloadInfo,p as useOpenapiDocsOptions};
1
+ import{useAtomValue as e}from"jotai";import{globalOptionsAtom as o}from"./jotai/store.js";import{simplifyAstStructure as f}from"./utils/simplifyAstStructure.js";import{getOperation as x}from"./models/operation.js";import{getServerEnvName as l}from"./utils/environments.js";import{getTagOrGroup as d}from"./models/group.js";import{generateDeepLink as c}from"./components/common/LinkToField.js";import{RequestSamples as g}from"./components/RequestSamples/RequestSamples.js";import{ResponseSamples as P}from"./components/ResponseSamples/ResponseSamples.js";import{RedocSchema as I}from"./components/pluggable/RedocSchema.js";import{RedocExample as w}from"./components/pluggable/RedocExample.js";import{RedoclyOpenAPIDocs as v}from"./components/RedoclyOpenAPIDocs/RedoclyOpenAPIDocs.js";import{StoreProvider as C}from"./components/RedoclyOpenAPIDocs/Providers.js";import{getMarkdownHeaderId as T}from"./components/RedoclyOpenAPIDocs/utils.js";import{safeSlugify as M}from"./utils/string.js";import{JsonPointer as h}from"./utils/JsonPointer.js";import{isOperationName as V}from"./utils/openapi.js";import{pathIncludesLink as F,normalizePath as H}from"./utils/path.js";import{saveTextBeforeHeading as z}from"./utils/saveTextBeforeHeading.js";import{OpenAPIParser as G}from"./services/OpenAPIParser.js";import{buildContentItems as _}from"./services/menu/builder.js";import{normalizeOptions as K}from"./services/config-options/normalizeOptions.js";import{makeDeepLink as U}from"./services/history/helpers.js";function p(){return e(o)}import{EmbeddedReplay as X}from"./components/Replay/EmbeddedReplay.js";import{convertOperationToReplayValue as Z}from"./components/Replay/utils.js";import{SectionContainer as ee}from"./components/SectionContent/index.js";import{Row as re}from"./components/common/panels.js";import{RightPanelContainer as pe}from"./components/SectionContent/index.js";import{Overview as ae}from"./components/Overview/index.js";import{SamplesMiddlePanel as ne,Section as xe,SamplesPanel as ie}from"./components/common/panels.js";import{Heading as se}from"./components/common/OperationItemTitle.js";import{Dropdown as ue}from"./components/common/Dropdown/index.js";import{Markdown as Se}from"./components/Markdown/index.js";import{FieldValueLabel as Oe,FieldLabel as Pe}from"./components/common/Fields/index.js";import{CodeBlockPanel as Ie}from"./components/common/index.js";import{OperationSamplesPanel as we}from"./components/OperationItem/OperationItem.js";import{ExternalDocumentation as ve}from"./components/ExternalDocumentation/index.js";import{PropertyDetails as Ce}from"./components/PropertyDetails/PropertyDetails.js";import{addMarkdownItems as Te}from"./services/menu/markdown.js";import{getValueFromMdParsedExtension as Me}from"./utils/helpers.js";import{ContentItem as he}from"./components/ContentItem/index.js";import{ExampleSwitch as Ve}from"./components/Samples/ExampleSwitch.js";import{CustomBadges as Fe}from"./components/common/Badges.js";import{Metadata as Ne}from"./components/ApiInfo/Metadata.js";import{useDownloadInfo as qe}from"./components/Download/useDownloadInfo.js";import{SECTION_ATTR as Je}from"./constants.js";import{RedocTelemetry as je}from"./telemetry/RedocTelemetry.js";export{Ie as CodeBlockPanel,he as ContentItem,Fe as CustomBadges,ue as Dropdown,X as EmbeddedReplay,Ve as ExampleSwitch,ve as ExternalDocumentation,Pe as FieldLabel,Oe as FieldValueLabel,se as Heading,h as JsonPointer,Se as Markdown,Ne as Metadata,G as OpenAPIParser,we as OperationSamplesPanel,ae as Overview,Ce as PropertyDetails,w as RedocExample,I as RedocSchema,je as RedocTelemetry,v as RedoclyOpenAPIDocs,g as RequestSamples,P as ResponseSamples,pe as RightPanelContainer,re as Row,Je as SECTION_ATTR,ne as SamplesMiddlePanel,ie as SamplesPanel,xe as Section,ee as SectionContainer,C as StoreProvider,Te as addMarkdownItems,_ as buildContentItems,Z as convertOperationToReplayValue,c as generateDeepLink,T as getMarkdownHeaderId,x as getOperation,l as getServerEnvName,d as getTagOrGroup,Me as getValueFromMdParsedExtension,V as isOperationName,U as makeDeepLink,K as normalizeOptions,H as normalizePath,F as pathIncludesLink,M as safeSlugify,z as saveTextBeforeHeading,f as simplifyAstStructure,qe as useDownloadInfo,p as useOpenapiDocsOptions};
@@ -17,6 +17,7 @@ export type CustomHAR = HAR.Request & {
17
17
  allResponseCodes?: string[];
18
18
  };
19
19
  export declare function safeSample(schema: JSONSchema7, options: Sampler.Options, document: object): any;
20
+ export declare function objectToHarParams(obj: GenericObject, parentKey?: string): HAR.Param[];
20
21
  export declare function getCodeSample({ lang, operation, exampleName, pathParams, properties, options, environment, translate, }: {
21
22
  lang: Languages;
22
23
  operation: OperationModel;
@@ -34,7 +35,6 @@ type OAuth2ExtraCall = HAR.Request & {
34
35
  clientId?: string;
35
36
  };
36
37
  export declare function getDataRequest(exampleValue: any, properties: any): boolean | any;
37
- export declare function objectToHarParams(obj: GenericObject, parentKey?: string): HAR.Param[];
38
38
  export declare function isDefined<T>(arg?: T): arg is T;
39
39
  export declare function capitalizeFirst(str: string): string;
40
40
  export {};
@@ -1 +1 @@
1
- import*as ce from"openapi-sampler";import $ from"deepmerge";import{isObject as ue}from"@redocly/theme/core/openapi";import{areArraysEqual as le,serializeParameterValue as P,getSecurityDetails as pe,getParameterValue as M,queryString as I,isArrayOfObjects as me,deleteEmptyArrayItem as de}from"../../utils/index.js";import{normalizeMimeType as fe,arrayMergeStrategy as J}from"../utils.js";import{MediaTypes as d}from"../../constants.js";import{HTTPSnippet as ye}from"./httpsnippet/index.js";import{getActiveMediaType as he}from"../../models/mediaContent.js";import Y from"./httpsnippet/helpers/string-utility.js";function C(e,a,o){try{return ce.sample(e,a,o)}catch(n){return console.error(`Error sampling schema: ${n.message}`),null}}function Se(e,a){return e.find(o=>{const n=o.schemes.map(s=>s.id);return le(n,a||[])})}function _e(e,{exampleName:a="",skipOptionalParameters:o=!1,withOAuth2Call:n=!1,spec:s,generatedPayloadSamplesMaxDepth:r=8,pathParams:c={},properties:u={},activeMimeName:i=""},{environment:h,requestValues:k,activeSecuritySchemeIds:_}){const p=h.server,b=e.servers.find(t=>t.url===p)||e.servers[0],w=Se(e.security,_),{securityHeaders:R,securityCookies:Q,securityQueries:F,securityOAuth2ExtraCalls:X,basicAuth:K}=Te(w||e.security?.[0],n,h),m=e?.requestBody?.content&&he(e.requestBody.content,i),v={skipNonRequired:o,skipReadOnly:!0,maxSampleDepth:r,quiet:!0},S=k;let H=!1;const N=e.parameters.filter(t=>t.in==="header").filter(t=>!(o&&!t.required)).map(t=>({name:t.name,value:S.header?.[t.name]||M("header",t.name)||t.serverValues?.[p]?.example||t.example||P(t,C(t.schema.rawSchema,v,s))})).map(t=>(m?.name&&t.name.toLowerCase()==="content-type"&&(H=!0,t.value=m.name),t)).concat(R);!H&&m?.name&&N.unshift({name:"Content-Type",value:m?.name});const G=e.parameters.filter(t=>t.in==="cookie").filter(t=>!(o&&!t.required)).map(t=>I.parse(P(t,t.serverValues?.[p]?.example||t.example||C(t.schema.rawSchema,v,s)))).reduce((t,l)=>{for(const[O,y]of Object.entries(l))t.push({name:O,value:String(S.cookie?.[O]||y)});return t},[]).concat(Q);function q(t){return e.parameters.filter(l=>l.in===t).filter(l=>!(o&&!l.required)).map(l=>I.parse(P(l,l.serverValues?.[p]?.example||l.example||C(l.schema.rawSchema,v,s)))).reduce((l,O)=>{for(const[y,ie]of Object.entries(O))l.push({name:y,value:me(S[t]?.[y])&&JSON.stringify(de(S[t]?.[y]))||String(S[t]?.[y]||ie)});return l},[]).concat(F)}const W=e.parameters.some(t=>t.in==="querystring"),Z=q(W?"querystring":"query"),ee=b?.url.replace(/\/$/,""),te=e.path.replace(/^\//,""),re=`${ee}/${te}`,ae=e.parameters.filter(t=>t.in==="path").reduce((t,l)=>{const{in:O,name:y}=l;return t[y]=S.path?.[y]||l.serverValues?.[p]?.example||l.example||c[y]||M(O,y),t},{}),z=m?.name.toLowerCase(),E=m?.examples?.[a]||m?.formExamples?.[a],se={...m?.formExamples||{},...m?.examples||{}},[x]=Object.values(se),U=E?.serverValues?.[p]?.value||x?.serverValues?.[p]?.value,D=t=>!t||typeof t!="object"||!m?.schema?.rawSchema?null:C(ke(m.schema.rawSchema,t),{...v,format:"xml"},s),T=(()=>{if(S?.body)return S.body;if(z===d.XML){const t=U||E?.value||x?.value;if(typeof t=="string")return t;const l=D(U)||D(E?.value)||D(x?.value);if(l)return l;if(m?.schema)return C(m.schema.rawSchema,{...v,format:"xml"},s)}else{const t=m?.schema&&C(m.schema.rawSchema,{...v,format:"json"},s);return U||E?.value||x?.value||t}return""})();let g="",L=[];switch(fe(z)){case d.JSON:g=JSON.stringify(j(T,u));break;case d.XML:g=T;break;case d.MULTIPART:case d.URL_ENCODED:typeof T=="string"?g=T:(g=I.stringify(j(T,u)),L=B(j(T,u)));break;default:g=String(T||"")}const ne=g?{mimeType:m?.name||d.OCTET_STREAM,text:g,params:L}:void 0,oe=e.responses.map(t=>t.code);return{method:e.httpVerb,url:re,httpVersion:"HTTP/1.1",cookies:G,headers:N,queryString:Z,postData:ne,headersSize:-1,bodySize:-1,securityOAuth2ExtraCalls:X,basicAuth:K,pathParameters:ae,serverVariables:h,allResponseCodes:oe}}const f={withImports:!0,withComments:!1},A={curl:{code:"shell",defaultTarget:"curl",defaultOptions:{...f,short:!0}},JavaScript:{code:"javascript",defaultTarget:"fetch",defaultOptions:{...f,withImports:!1}},"Node.js":{code:"node",defaultTarget:"fetch",defaultOptions:{...f}},Python:{code:"python",defaultTarget:"requests",defaultOptions:{...f}},"Java8+Apache":{code:"java8",defaultTarget:"apachehttp",defaultOptions:{...f}},Java:{code:"java",defaultTarget:"httpclient",defaultOptions:{...f}},"C#":{code:"csharp",defaultTarget:"httpclient",defaultOptions:{...f}},"C#+Newtonsoft":{code:"csharpNewtonsoft",defaultTarget:"httpclient",defaultOptions:{...f}},Go:{code:"go",defaultTarget:"http.DefaultClient",defaultOptions:{...f}},PHP:{code:"php",defaultTarget:"curl",defaultOptions:{...f}},Ruby:{code:"ruby",defaultTarget:"net::http",defaultOptions:{...f}},R:{code:"r",defaultTarget:"httr",defaultOptions:{...f}}};function Ie({lang:e,operation:a,exampleName:o,pathParams:n,properties:s,options:r={},environment:c,translate:u}){try{const{skipOptionalParameters:i,withOAuth2Call:h,spec:k,generatedPayloadSamplesMaxDepth:_,store:p,activeMimeName:b}=r,w=_e(a,{exampleName:o,pathParams:n,properties:s,skipOptionalParameters:i,withOAuth2Call:h,spec:k,generatedPayloadSamplesMaxDepth:_,activeMimeName:b},{environment:c,requestValues:p.requestValues,activeSecuritySchemeIds:p.activeSecuritySchemeIds}),R=new ye(w);return A[e]?R.convert(A[e].code,A[e].defaultTarget,{...A[e].defaultOptions,...r}):u("openapi.unsupportedLanguage","Language is not supported.")}catch(i){return console.error(i),u("openapi.failedToGenerateCodeSample","Failed to generate code sample.")}}function Te(e,a,o){const n={securityHeaders:[],securityCookies:[],securityQueries:[],securityOAuth2ExtraCalls:[],basicAuth:void 0},s=o?.server;for(const r of e?.schemes||[]){const c=pe(r.id,o),u=s&&r.serverValues&&r.serverValues[s],i={access_token:u?.["x-defaultAccessToken"]||r["x-defaultAccessToken"],token_type:u?.["x-defaultTokenType"]||r["x-defaultTokenType"],client_id:u?.["x-defaultClientId"]||r["x-defaultClientId"],client_secret:u?.["x-defaultClientSecret"]||r["x-defaultClientSecret"]},h=u?.["x-defaultUsername"]||r["x-defaultUsername"],k=u?.["x-defaultPassword"]||r["x-defaultPassword"],_=u&&"scopes"in u?u.scopes||[]:r.scopes||[];switch(r.type){case"openIdConnect":n.securityHeaders?.push({name:"Authorization",value:i.access_token?`${i.token_type||"Bearer"} ${i.access_token}`:c.token?`${i.token_type||c.token.token_type||"Bearer"} ${c.token.access_token}`:"Bearer <YOUR_TOKEN_HERE>"});break;case"oauth2":{const p=i.access_token?`${i.token_type||"Bearer"} ${i.access_token}`:c.token?`${c.token.token_type||"Bearer"} ${c.token.access_token}`:"Bearer <YOUR_TOKEN_HERE>";r.flows.deviceAuthorization&&a?n.securityOAuth2ExtraCalls.push(ge(r.flows.deviceAuthorization,_)):r.flows.clientCredentials&&a?n.securityOAuth2ExtraCalls.push(Oe(r.flows.clientCredentials,_,{...c,client_id:i.client_id||c.client_id,client_secret:i.client_secret||c.client_secret})):r.flows.password&&a&&n.securityOAuth2ExtraCalls.push(ve(r.flows.password,_,{...c,client_id:i.client_id||c.client_id,client_secret:i.client_secret||c.client_secret})),n.securityHeaders?.push({name:"Authorization",value:p});break}case"apiKey":{const p=i.access_token||c.raw||"YOUR_API_KEY_HERE";r.in==="header"&&n.securityHeaders?.push({name:r.name,value:p}),r.in==="cookie"&&n.securityCookies.push({name:r.name,value:p}),(r.in==="query"||r.in==="querystring")&&n.securityQueries.push({name:r.name,value:p});break}case"http":if(r.scheme==="basic")n.basicAuth={username:h||c.username||`<${Y.toSnakeCase("Username")}>`,password:k||c.password||`<${Y.toSnakeCase("Password")}>`};else{const p=i?.access_token||c.token?.access_token||`<YOUR_${r.bearerFormat||"TOKEN"}_HERE>`;n.securityHeaders?.push({name:"Authorization",value:`${Ce(r.scheme||"bearer")} ${p}`})}break}}return n}function ge(e,a){const o=e["x-defaultClientId"]??"YOUR_CLIENT_ID",{tokenUrl:n,deviceAuthorizationUrl:s}=e;return{method:"POST",url:s,httpVersion:"HTTP/1.1",headers:[{name:"Content-Type",value:d.URL_ENCODED},{name:"Accept",value:d.JSON}],queryString:[],postData:{mimeType:d.URL_ENCODED,text:"",params:[{name:"client_id",value:o},a.length?{name:"scope",value:a.join(" ")}:void 0].filter(V)},cookies:[],headersSize:-1,bodySize:-1,securityOAuth2ExtraCalls:[],flowType:"deviceAuthorization",tokenUrl:n,clientId:o}}function ve(e,a,o){const{tokenUrl:n}=e,s=o.client_id??"YOUR_CLIENT_ID";return{method:"POST",url:e.tokenUrl,httpVersion:"HTTP/1.1",headers:[{name:"Content-Type",value:d.URL_ENCODED},{name:"Accept",value:d.JSON}],queryString:[],postData:{mimeType:d.URL_ENCODED,text:"",params:[{name:"grant_type",value:"password"},{name:"client_id",value:s},{name:"client_secret",value:o.client_secret||"YOUR_CLIENT_SECRET"},{name:"username",value:o.username||"<username>"},{name:"password",value:o.password||"<password>"},a.length?{name:"scope",value:a.join(" ")}:void 0].filter(V)},cookies:[],headersSize:-1,bodySize:-1,securityOAuth2ExtraCalls:[],flowType:"password",tokenUrl:n,clientId:s}}function Oe(e,a,o){const{tokenUrl:n}=e,s=o.client_id??"YOUR_CLIENT_ID";return{method:"POST",url:e.tokenUrl,httpVersion:"HTTP/1.1",headers:[{name:"Content-Type",value:d.URL_ENCODED},{name:"Accept",value:d.JSON}],queryString:[],postData:{mimeType:d.URL_ENCODED,text:"",params:[{name:"grant_type",value:"client_credentials"},{name:"client_id",value:s},{name:"client_secret",value:o.client_secret||"YOUR_CLIENT_SECRET"},a.length?{name:"scope",value:a.join(" ")}:void 0].filter(V)},cookies:[],headersSize:-1,bodySize:-1,securityOAuth2ExtraCalls:[],flowType:"clientCredentials",tokenUrl:n,clientId:s}}function j(e,a){if(e){if(ue(e))return Object.keys(e).length>0&&Object.keys(a).length===0?e:$(e,a,{arrayMerge:J});try{return $(JSON.parse(e),a,{arrayMerge:J})}catch{return!1}}return!1}function B(e,a=""){const o=[];for(const[n,s]of Object.entries(e)){const r=a?`${a}[${n}]`:n;if(typeof s=="object"&&s!==null)o.push(...B(s,r));else{const c=Array.isArray(e)&&typeof s=="string"&&a?a:r;o.push({name:c,value:String(s)})}}return o}function V(e){return e!==void 0}function Ce(e){return e.charAt(0).toUpperCase()+e.slice(1)}function ke(e,a){if(!e||typeof e!="object"||!a||typeof a!="object")return e;const o=JSON.parse(JSON.stringify(e));function n(s,r){if(!(!s||!r||typeof s!="object"||typeof r!="object")&&s.properties){for(const c in s.properties)if(r[c]!==void 0){const u=s.properties[c],i=r[c];if(u.type==="object"&&typeof i=="object"&&!Array.isArray(i))n(u,i);else if(u.type==="array"&&Array.isArray(i)&&i.length>0){const h=i[0];u.items&&u.items.properties&&n(u.items,h)}else u.example=i}}}return n(o,a),o}export{Ce as capitalizeFirst,Ie as getCodeSample,j as getDataRequest,V as isDefined,B as objectToHarParams,C as safeSample};
1
+ import*as ce from"openapi-sampler";import $ from"deepmerge";import{isObject as ue}from"@redocly/theme/core/openapi";import{areArraysEqual as le,serializeParameterValue as P,getSecurityDetails as pe,getParameterValue as M,queryString as I,isArrayOfObjects as me,deleteEmptyArrayItem as de}from"../../utils/index.js";import{normalizeMimeType as fe,arrayMergeStrategy as J}from"../utils.js";import{MediaTypes as d}from"../../constants.js";import{HTTPSnippet as ye}from"./httpsnippet/index.js";import{getActiveMediaType as he}from"../../models/mediaContent.js";import Y from"./httpsnippet/helpers/string-utility.js";function C(e,a,o){try{return ce.sample(e,a,o)}catch(n){return console.error(`Error sampling schema: ${n.message}`),null}}function B(e,a=""){const o=[];for(const[n,s]of Object.entries(e)){const r=a?`${a}[${n}]`:n;if(typeof s=="object"&&s!==null)o.push(...B(s,r));else{const c=Array.isArray(e)&&typeof s=="string"&&a?a:r;o.push({name:c,value:String(s)})}}return o}function Se(e,a){return e.find(o=>{const n=o.schemes.map(s=>s.id);return le(n,a||[])})}function _e(e,{exampleName:a="",skipOptionalParameters:o=!1,withOAuth2Call:n=!1,spec:s,generatedPayloadSamplesMaxDepth:r=8,pathParams:c={},properties:u={},activeMimeName:i=""},{environment:h,requestValues:k,activeSecuritySchemeIds:_}){const p=h.server,b=e.servers.find(t=>t.url===p)||e.servers[0],w=Se(e.security,_),{securityHeaders:R,securityCookies:Q,securityQueries:F,securityOAuth2ExtraCalls:X,basicAuth:K}=Te(w||e.security?.[0],n,h),m=e?.requestBody?.content&&he(e.requestBody.content,i),v={skipNonRequired:o,skipReadOnly:!0,maxSampleDepth:r,quiet:!0},S=k;let H=!1;const N=e.parameters.filter(t=>t.in==="header").filter(t=>!(o&&!t.required)).map(t=>({name:t.name,value:S.header?.[t.name]||M("header",t.name)||t.serverValues?.[p]?.example||t.example||P(t,C(t.schema.rawSchema,v,s))})).map(t=>(m?.name&&t.name.toLowerCase()==="content-type"&&(H=!0,t.value=m.name),t)).concat(R);!H&&m?.name&&N.unshift({name:"Content-Type",value:m?.name});const G=e.parameters.filter(t=>t.in==="cookie").filter(t=>!(o&&!t.required)).map(t=>I.parse(P(t,t.serverValues?.[p]?.example||t.example||C(t.schema.rawSchema,v,s)))).reduce((t,l)=>{for(const[O,y]of Object.entries(l))t.push({name:O,value:String(S.cookie?.[O]||y)});return t},[]).concat(Q);function q(t){return e.parameters.filter(l=>l.in===t).filter(l=>!(o&&!l.required)).map(l=>I.parse(P(l,l.serverValues?.[p]?.example||l.example||C(l.schema.rawSchema,v,s)))).reduce((l,O)=>{for(const[y,ie]of Object.entries(O))l.push({name:y,value:me(S[t]?.[y])&&JSON.stringify(de(S[t]?.[y]))||String(S[t]?.[y]||ie)});return l},[]).concat(F)}const W=e.parameters.some(t=>t.in==="querystring"),Z=q(W?"querystring":"query"),ee=b?.url.replace(/\/$/,""),te=e.path.replace(/^\//,""),re=`${ee}/${te}`,ae=e.parameters.filter(t=>t.in==="path").reduce((t,l)=>{const{in:O,name:y}=l;return t[y]=S.path?.[y]||l.serverValues?.[p]?.example||l.example||c[y]||M(O,y),t},{}),z=m?.name.toLowerCase(),E=m?.examples?.[a]||m?.formExamples?.[a],se={...m?.formExamples||{},...m?.examples||{}},[x]=Object.values(se),U=E?.serverValues?.[p]?.value||x?.serverValues?.[p]?.value,D=t=>!t||typeof t!="object"||!m?.schema?.rawSchema?null:C(ke(m.schema.rawSchema,t),{...v,format:"xml"},s),T=(()=>{if(S?.body)return S.body;if(z===d.XML){const t=U||E?.value||x?.value;if(typeof t=="string")return t;const l=D(U)||D(E?.value)||D(x?.value);if(l)return l;if(m?.schema)return C(m.schema.rawSchema,{...v,format:"xml"},s)}else{const t=m?.schema&&C(m.schema.rawSchema,{...v,format:"json"},s);return U||E?.value||x?.value||t}return""})();let g="",L=[];switch(fe(z)){case d.JSON:g=JSON.stringify(j(T,u));break;case d.XML:g=T;break;case d.MULTIPART:case d.URL_ENCODED:typeof T=="string"?g=T:(g=I.stringify(j(T,u)),L=B(j(T,u)));break;default:g=String(T||"")}const ne=g?{mimeType:m?.name||d.OCTET_STREAM,text:g,params:L}:void 0,oe=e.responses.map(t=>t.code);return{method:e.httpVerb,url:re,httpVersion:"HTTP/1.1",cookies:G,headers:N,queryString:Z,postData:ne,headersSize:-1,bodySize:-1,securityOAuth2ExtraCalls:X,basicAuth:K,pathParameters:ae,serverVariables:h,allResponseCodes:oe}}const f={withImports:!0,withComments:!1},A={curl:{code:"shell",defaultTarget:"curl",defaultOptions:{...f,short:!0}},JavaScript:{code:"javascript",defaultTarget:"fetch",defaultOptions:{...f,withImports:!1}},"Node.js":{code:"node",defaultTarget:"fetch",defaultOptions:{...f}},Python:{code:"python",defaultTarget:"requests",defaultOptions:{...f}},"Java8+Apache":{code:"java8",defaultTarget:"apachehttp",defaultOptions:{...f}},Java:{code:"java",defaultTarget:"httpclient",defaultOptions:{...f}},"C#":{code:"csharp",defaultTarget:"httpclient",defaultOptions:{...f}},"C#+Newtonsoft":{code:"csharpNewtonsoft",defaultTarget:"httpclient",defaultOptions:{...f}},Go:{code:"go",defaultTarget:"http.DefaultClient",defaultOptions:{...f}},PHP:{code:"php",defaultTarget:"curl",defaultOptions:{...f}},Ruby:{code:"ruby",defaultTarget:"net::http",defaultOptions:{...f}},R:{code:"r",defaultTarget:"httr",defaultOptions:{...f}}};function Ie({lang:e,operation:a,exampleName:o,pathParams:n,properties:s,options:r={},environment:c,translate:u}){try{const{skipOptionalParameters:i,withOAuth2Call:h,spec:k,generatedPayloadSamplesMaxDepth:_,store:p,activeMimeName:b}=r,w=_e(a,{exampleName:o,pathParams:n,properties:s,skipOptionalParameters:i,withOAuth2Call:h,spec:k,generatedPayloadSamplesMaxDepth:_,activeMimeName:b},{environment:c,requestValues:p.requestValues,activeSecuritySchemeIds:p.activeSecuritySchemeIds}),R=new ye(w);return A[e]?R.convert(A[e].code,A[e].defaultTarget,{...A[e].defaultOptions,...r}):u("openapi.unsupportedLanguage","Language is not supported.")}catch(i){return console.error(i),u("openapi.failedToGenerateCodeSample","Failed to generate code sample.")}}function Te(e,a,o){const n={securityHeaders:[],securityCookies:[],securityQueries:[],securityOAuth2ExtraCalls:[],basicAuth:void 0},s=o?.server;for(const r of e?.schemes||[]){const c=pe(r.id,o),u=s&&r.serverValues&&r.serverValues[s],i={access_token:u?.["x-defaultAccessToken"]||r["x-defaultAccessToken"],token_type:u?.["x-defaultTokenType"]||r["x-defaultTokenType"],client_id:u?.["x-defaultClientId"]||r["x-defaultClientId"],client_secret:u?.["x-defaultClientSecret"]||r["x-defaultClientSecret"]},h=u?.["x-defaultUsername"]||r["x-defaultUsername"],k=u?.["x-defaultPassword"]||r["x-defaultPassword"],_=u&&"scopes"in u?u.scopes||[]:r.scopes||[];switch(r.type){case"openIdConnect":n.securityHeaders?.push({name:"Authorization",value:i.access_token?`${i.token_type||"Bearer"} ${i.access_token}`:c.token?`${i.token_type||c.token.token_type||"Bearer"} ${c.token.access_token}`:"Bearer <YOUR_TOKEN_HERE>"});break;case"oauth2":{const p=i.access_token?`${i.token_type||"Bearer"} ${i.access_token}`:c.token?`${c.token.token_type||"Bearer"} ${c.token.access_token}`:"Bearer <YOUR_TOKEN_HERE>";r.flows.deviceAuthorization&&a?n.securityOAuth2ExtraCalls.push(ge(r.flows.deviceAuthorization,_)):r.flows.clientCredentials&&a?n.securityOAuth2ExtraCalls.push(Oe(r.flows.clientCredentials,_,{...c,client_id:i.client_id||c.client_id,client_secret:i.client_secret||c.client_secret})):r.flows.password&&a&&n.securityOAuth2ExtraCalls.push(ve(r.flows.password,_,{...c,client_id:i.client_id||c.client_id,client_secret:i.client_secret||c.client_secret})),n.securityHeaders?.push({name:"Authorization",value:p});break}case"apiKey":{const p=i.access_token||c.raw||"YOUR_API_KEY_HERE";r.in==="header"&&n.securityHeaders?.push({name:r.name,value:p}),r.in==="cookie"&&n.securityCookies.push({name:r.name,value:p}),(r.in==="query"||r.in==="querystring")&&n.securityQueries.push({name:r.name,value:p});break}case"http":if(r.scheme==="basic")n.basicAuth={username:h||c.username||`<${Y.toSnakeCase("Username")}>`,password:k||c.password||`<${Y.toSnakeCase("Password")}>`};else{const p=i?.access_token||c.token?.access_token||`<YOUR_${r.bearerFormat||"TOKEN"}_HERE>`;n.securityHeaders?.push({name:"Authorization",value:`${Ce(r.scheme||"bearer")} ${p}`})}break}}return n}function ge(e,a){const o=e["x-defaultClientId"]??"YOUR_CLIENT_ID",{tokenUrl:n,deviceAuthorizationUrl:s}=e;return{method:"POST",url:s,httpVersion:"HTTP/1.1",headers:[{name:"Content-Type",value:d.URL_ENCODED},{name:"Accept",value:d.JSON}],queryString:[],postData:{mimeType:d.URL_ENCODED,text:"",params:[{name:"client_id",value:o},a.length?{name:"scope",value:a.join(" ")}:void 0].filter(V)},cookies:[],headersSize:-1,bodySize:-1,securityOAuth2ExtraCalls:[],flowType:"deviceAuthorization",tokenUrl:n,clientId:o}}function ve(e,a,o){const{tokenUrl:n}=e,s=o.client_id??"YOUR_CLIENT_ID";return{method:"POST",url:e.tokenUrl,httpVersion:"HTTP/1.1",headers:[{name:"Content-Type",value:d.URL_ENCODED},{name:"Accept",value:d.JSON}],queryString:[],postData:{mimeType:d.URL_ENCODED,text:"",params:[{name:"grant_type",value:"password"},{name:"client_id",value:s},{name:"client_secret",value:o.client_secret||"YOUR_CLIENT_SECRET"},{name:"username",value:o.username||"<username>"},{name:"password",value:o.password||"<password>"},a.length?{name:"scope",value:a.join(" ")}:void 0].filter(V)},cookies:[],headersSize:-1,bodySize:-1,securityOAuth2ExtraCalls:[],flowType:"password",tokenUrl:n,clientId:s}}function Oe(e,a,o){const{tokenUrl:n}=e,s=o.client_id??"YOUR_CLIENT_ID";return{method:"POST",url:e.tokenUrl,httpVersion:"HTTP/1.1",headers:[{name:"Content-Type",value:d.URL_ENCODED},{name:"Accept",value:d.JSON}],queryString:[],postData:{mimeType:d.URL_ENCODED,text:"",params:[{name:"grant_type",value:"client_credentials"},{name:"client_id",value:s},{name:"client_secret",value:o.client_secret||"YOUR_CLIENT_SECRET"},a.length?{name:"scope",value:a.join(" ")}:void 0].filter(V)},cookies:[],headersSize:-1,bodySize:-1,securityOAuth2ExtraCalls:[],flowType:"clientCredentials",tokenUrl:n,clientId:s}}function j(e,a){if(e){if(ue(e))return Object.keys(e).length>0&&Object.keys(a).length===0?e:$(e,a,{arrayMerge:J});try{return $(JSON.parse(e),a,{arrayMerge:J})}catch{return!1}}return!1}function V(e){return e!==void 0}function Ce(e){return e.charAt(0).toUpperCase()+e.slice(1)}function ke(e,a){if(!e||typeof e!="object"||!a||typeof a!="object")return e;const o=JSON.parse(JSON.stringify(e));function n(s,r){if(!(!s||!r||typeof s!="object"||typeof r!="object")&&s.properties){for(const c in s.properties)if(r[c]!==void 0){const u=s.properties[c],i=r[c];if(u.type==="object"&&typeof i=="object"&&!Array.isArray(i))n(u,i);else if(u.type==="array"&&Array.isArray(i)&&i.length>0){const h=i[0];u.items&&u.items.properties&&n(u.items,h)}else u.example=i}}}return n(o,a),o}export{Ce as capitalizeFirst,Ie as getCodeSample,j as getDataRequest,V as isDefined,B as objectToHarParams,C as safeSample};
@@ -0,0 +1,15 @@
1
+ import { Telemetry } from '@redocly/redoc-opentelemetry';
2
+ import type { EventType, EventPayload } from '@redocly/redoc-opentelemetry';
3
+ export type SpecType = 'openapi' | 'asyncapi' | 'graphql';
4
+ export interface RedocTelemetryConfig {
5
+ specType: SpecType;
6
+ collectorUrl?: string;
7
+ serviceName?: string;
8
+ disabled?: boolean;
9
+ serviceVersion?: string;
10
+ }
11
+ export declare class RedocTelemetry extends Telemetry {
12
+ private specType;
13
+ constructor(config: RedocTelemetryConfig);
14
+ send<T extends EventType>(event: T, data?: EventPayload<T>): void;
15
+ }
@@ -0,0 +1 @@
1
+ import{Telemetry as o}from"@redocly/redoc-opentelemetry";import c from"../../package.json"with{type:"json"};const p="https://otel.cloud.redocly.com/v1/traces";class n extends o{specType;constructor(e){super(),this.specType=e.specType,this.init({otel:{isProd:process.env.NODE_ENV==="production"||process.env.ENABLE_LOCAL_TELEMETRY==="true",serviceVersion:e.serviceVersion||`${c.name}@${c.version}`,version:"1.0.0",collectorTraceUrl:e.collectorUrl||p,serviceName:e.serviceName||"redoc-ce",tracerName:"client-telemetry"},disabled:e.disabled||!1})}send(e,r){r&&Array.isArray(r)&&r.length>0&&(r=r.map(s=>s&&typeof s=="object"?{...s,specType:this.specType}:s)),super.send(e,r)}}export{n as RedocTelemetry};
@@ -25,6 +25,7 @@ export declare const isArrayOfObjects: (items: unknown) => items is [];
25
25
  export declare const deleteEmptyArrayItem: (items: unknown[]) => unknown[];
26
26
  export declare const isMergeableObject: (item: unknown) => boolean;
27
27
  export declare function isAbsoluteUrl(url: string): boolean;
28
+ export declare function transformStringToTelemetryId(...args: string[]): string;
28
29
  /**
29
30
  * simple resolve URL which doesn't break on strings with url fragments
30
31
  * e.g. resolveUrl('http://test.com:{port}', 'path') results in http://test.com:{port}/path
@@ -1,4 +1,4 @@
1
- import{isObject as i,isString as p}from"@redocly/theme/core/openapi";import{isNamedDefinition as a}from"./openapi.js";import{JsonPointer as f}from"./JsonPointer.js";import{urlParse as u}from"./url.js";import{IS_BROWSER as l}from"./dom.js";function w(r,e){const t=[];for(let n=0;n<r.length-1;n++)t.push(e(r[n],!1));return r.length!==0&&t.push(e(r[r.length-1],!0)),t}function A(r,e){const t={};for(const n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=e(r[n],n,r));return t}function R(r,e){const t=[],n=o=>{for(const s of o)t.push(s),s[e]&&n(s[e])};return n(r),t}function c(r){return r.endsWith("/")?r.substring(0,r.length-1):r}function b(r){return!isNaN(parseFloat(r))&&isFinite(r)}function E(r,e,t){const n=new RegExp(`(^|\\n)#\\s?${e}\\s*\\n`,"i"),o=new RegExp(`((\\n|^)#\\s*${e}\\s*(\\n|$)(?:.|\\n)*?)(\\n#|$)`,"i");if(n.test(r))return r.replace(o,`$1
1
+ import{isObject as i,isString as p}from"@redocly/theme/core/openapi";import{isNamedDefinition as a}from"./openapi.js";import{JsonPointer as l}from"./JsonPointer.js";import{urlParse as u}from"./url.js";import{IS_BROWSER as f}from"./dom.js";function w(r,e){const t=[];for(let n=0;n<r.length-1;n++)t.push(e(r[n],!1));return r.length!==0&&t.push(e(r[r.length-1],!0)),t}function A(r,e){const t={};for(const n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=e(r[n],n,r));return t}function R(r,e){const t=[],n=o=>{for(const s of o)t.push(s),s[e]&&n(s[e])};return n(r),t}function c(r){return r.endsWith("/")?r.substring(0,r.length-1):r}function b(r){return!isNaN(parseFloat(r))&&isFinite(r)}function y(r,e,t){const n=new RegExp(`(^|\\n)#\\s?${e}\\s*\\n`,"i"),o=new RegExp(`((\\n|^)#\\s*${e}\\s*(\\n|$)(?:.|\\n)*?)(\\n#|$)`,"i");if(n.test(r))return r.replace(o,`$1
2
2
 
3
3
  ${t}
4
4
  $4`);{const s=r===""||r.endsWith(`
@@ -9,4 +9,4 @@ $4`);{const s=r===""||r.endsWith(`
9
9
 
10
10
  `;return`${r}${s}# ${e}
11
11
 
12
- ${t}`}}const W=r=>Array.isArray(r)&&r.some(e=>i(e)),y=r=>r.filter(e=>!!e),C=r=>i(r)&&!Array.isArray(r);function x(r){return/(?:^[a-z][a-z0-9+.-]*:|\/\/)/i.test(r)}function N(r,e){let t;if(e.startsWith("//"))t=`${u(r,!0)?.protocol||"https:"}${e}`;else if(x(e))t=e;else if(!e.startsWith("/"))t=c(r)+"/"+e;else{const n=u(r);n?(n.pathname=e,t=n.toString()):t=e}return c(t)}function I(r){return r.charAt(0).toUpperCase()+r.slice(1)}function L(r){try{if(!r)return"";const e=new URL(r);return e.search="",e.hash="",e.toString()}catch{return r}}function P(r){return r.replace(/["\\]/g,"\\$&")}function T(r){return r.replace(/&#(\d+);/g,(e,t)=>String.fromCharCode(parseInt(t,10))).replace(/&quot;/g,'"').replace(/&amp;/g,"&")}function j(r){return r&&r.replace(/#/g,"_").toLowerCase()}function z(r,e){return e||a(r)&&f.baseName(r)||""}function M(r={},e,t){return typeof e=="string"&&(e=e.split(".")),e.reduce((n,o)=>n&&n[o]?n[o]:t,r)}function g(r){return(...e)=>e.filter(Boolean).join(r)}const D=g(".");function F(r){return l?window?.REFERENCE_DOCS_OPTIONS?.[r]:null}const _=r=>p(r)?r:r?.raw,H=(r,e)=>{const t=r?.[`x-parsed-md-${e}`]||r?.[e];if(!t)return;if(!r?.[`x-parsed-md-${e}`]&&e!=="x-enumDescriptions")return r?.[e];if(e!=="x-enumDescriptions")return d(r,e);let n={};for(const o in t)o.startsWith("x-parsed-md")||(n[o]=t?.[`x-parsed-md-${o}`]||t?.[o]);return Object.keys(n).length?n:t};function B(r){return r.name||r.description}function d(r,e){const t=r?.[`x-parsed-md-${e}`]||r?.[e];return t?.raw?t:{result:t?.result||r?.[e]?.result||r?.[e],raw:r?.[e]}}function U(r,e){return e===r.length-1}function V(r,e){const t=Object.keys(r);return t.indexOf(e)===t.length-1}export{E as appendToMdHeading,y as deleteEmptyArrayItem,D as dottedString,P as escapeHTMLAttrChars,R as flattenByProp,M as get,B as getServerDisplayName,H as getValueFromMdParsedExtension,F as getWindowReferenceOptions,x as isAbsoluteUrl,W as isArrayOfObjects,U as isLastInArray,V as isLastProperty,C as isMergeableObject,b as isNumeric,g as joinStringFactory,A as mapValues,w as mapWithLast,_ as normalizeText,L as removeQueryStringAndHash,N as resolveUrl,j as sanitizeItemId,c as stripTrailingSlash,I as titleize,T as unescapeHTMLChars,z as useSchemaTitle};
12
+ ${t}`}}const C=r=>Array.isArray(r)&&r.some(e=>i(e)),E=r=>r.filter(e=>!!e),T=r=>i(r)&&!Array.isArray(r);function x(r){return/(?:^[a-z][a-z0-9+.-]*:|\/\/)/i.test(r)}function W(...r){return r.join("_").replaceAll(" ","_").replaceAll(".","_").toLowerCase()}function I(r,e){let t;if(e.startsWith("//"))t=`${u(r,!0)?.protocol||"https:"}${e}`;else if(x(e))t=e;else if(!e.startsWith("/"))t=c(r)+"/"+e;else{const n=u(r);n?(n.pathname=e,t=n.toString()):t=e}return c(t)}function L(r){return r.charAt(0).toUpperCase()+r.slice(1)}function N(r){try{if(!r)return"";const e=new URL(r);return e.search="",e.hash="",e.toString()}catch{return r}}function _(r){return r.replace(/["\\]/g,"\\$&")}function j(r){return r.replace(/&#(\d+);/g,(e,t)=>String.fromCharCode(parseInt(t,10))).replace(/&quot;/g,'"').replace(/&amp;/g,"&")}function P(r){return r&&r.replace(/#/g,"_").toLowerCase()}function z(r,e){return e||a(r)&&l.baseName(r)||""}function M(r={},e,t){return typeof e=="string"&&(e=e.split(".")),e.reduce((n,o)=>n&&n[o]?n[o]:t,r)}function g(r){return(...e)=>e.filter(Boolean).join(r)}const D=g(".");function F(r){return f?window?.REFERENCE_DOCS_OPTIONS?.[r]:null}const H=r=>p(r)?r:r?.raw,B=(r,e)=>{const t=r?.[`x-parsed-md-${e}`]||r?.[e];if(!t)return;if(!r?.[`x-parsed-md-${e}`]&&e!=="x-enumDescriptions")return r?.[e];if(e!=="x-enumDescriptions")return d(r,e);let n={};for(const o in t)o.startsWith("x-parsed-md")||(n[o]=t?.[`x-parsed-md-${o}`]||t?.[o]);return Object.keys(n).length?n:t};function U(r){return r.name||r.description}function d(r,e){const t=r?.[`x-parsed-md-${e}`]||r?.[e];return t?.raw?t:{result:t?.result||r?.[e]?.result||r?.[e],raw:r?.[e]}}function V(r,e){return e===r.length-1}function q(r,e){const t=Object.keys(r);return t.indexOf(e)===t.length-1}export{y as appendToMdHeading,E as deleteEmptyArrayItem,D as dottedString,_ as escapeHTMLAttrChars,R as flattenByProp,M as get,U as getServerDisplayName,B as getValueFromMdParsedExtension,F as getWindowReferenceOptions,x as isAbsoluteUrl,C as isArrayOfObjects,V as isLastInArray,q as isLastProperty,T as isMergeableObject,b as isNumeric,g as joinStringFactory,A as mapValues,w as mapWithLast,H as normalizeText,N as removeQueryStringAndHash,I as resolveUrl,P as sanitizeItemId,c as stripTrailingSlash,L as titleize,W as transformStringToTelemetryId,j as unescapeHTMLChars,z as useSchemaTitle};
@@ -1 +1 @@
1
- import{dirname as b}from"path";import m from"url-template";import{deleteEmptyArrayItem as S,isArrayOfObjects as w,isNumeric as E,removeQueryStringAndHash as T,resolveUrl as N,sanitizeItemId as l,normalizeText as j,getValueFromMdParsedExtension as $,isAbsoluteUrl as z}from"./helpers.js";import{DEFAULT_TAG_SLUG as D,MediaTypes as a}from"../constants.js";import{JsonPointer as _}from"./JsonPointer.js";import{joinWithSeparator as P,objectToHarParams as R}from"../services/index.js";import{tryDecodeURIComponent as q}from"./string.js";import{getUrlDirname as U}from"./url.js";import{IS_BROWSER as L}from"./dom.js";function I(e){return typeof e=="string"&&/\dxx/i.test(e)}function se(e){return e==="default"||E(e)||I(e)}function ae(e,r=!1){if(e==="default")return r?"error":"success";let t=typeof e=="string"?parseInt(e,10):e;if(I(e)&&(t*=100),t<100||t>599)throw new Error("invalid HTTP code");let n="success";return t>=300&&t<400?n="redirect":t>=400?n="error":t<200&&(n="info"),n}const F={get:!0,post:!0,put:!0,head:!0,patch:!0,delete:!0,options:!0,$ref:!0,"x-query":!0,query:!0};function ce(e){return e in F}function pe(e){const{operationId:r,pathName:t}=e,n=j($(e,"description"));return j($(e,"summary"))||r||n&&n.substring(0,50)||t||"<no summary>"}function fe(e,r){return r?.id?P(r.id,l(e.operationId?e.operationId:d(e.pointer))).toLowerCase():e.tags?.length?l(e.operationId?e.operationId:d(e.pointer)):l(e.operationId?P(D,e.operationId):d(e.pointer))}function d(e){return e?.startsWith("/")?e.slice(1,e.length):e}const O={multipleOf:"number",maximum:"number",exclusiveMaximum:"number",minimum:"number",exclusiveMinimum:"number",maxLength:"string",minLength:"string",pattern:"string",contentEncoding:"string",contentMediaType:"string",items:"array",maxItems:"array",minItems:"array",uniqueItems:"array",maxProperties:"object",minProperties:"object",required:"object",additionalProperties:"object",unevaluatedProperties:"object",patternProperties:"object",properties:"object"};function me(e){if(e.type!==void 0&&!Array.isArray(e.type))return e.type;const r=Object.keys(O);for(const t of r){const n=O[t];if(e[t]!==void 0)return n}return"any"}function k(e,r=e.type){if(e["x-circular-ref"]||e["x-complex"])return!0;if(e.oneOf!==void 0||e.anyOf!==void 0||e.if&&e.then||e.if&&e.else)return!1;let t=!0;const n=Array.isArray(r);return(r==="object"||n&&r?.includes("object"))&&(t=e.properties!==void 0?Object.keys(e.properties).length===0:e.additionalProperties===void 0&&e.unevaluatedProperties===void 0&&e.patternProperties===void 0),Array.isArray(e.items)||Array.isArray(e.prefixItems)?!1:(e.items!==void 0&&typeof e.items!="boolean"&&(r==="array"||n&&r?.includes("array"))&&(t=k(e.items,e.items.type)),t)}function W(e){return e.search(/json/i)!==-1}function le(e){return e?.search(/xml/i)!==-1}function C(e){return e===a.URL_ENCODED}function de(e){return e===a.MULTIPART}function xe(e){return[a.JSONL,a.NDJSON,a.JSON_SEQ,a.EVENT_STREAM,a.MULTIPART_MIXED].includes(e)}function p(e,r,t){return Array.isArray(e)?e.map(n=>n.toString()).join(t):typeof e=="object"?Object.keys(e).map(n=>`${n}${t}${e[n]}`).join(t):r+"="+e.toString()}function M(e,r){return Array.isArray(e)?(console.warn("deepObject style cannot be used with array value:"+e.toString()),""):typeof e=="object"?Object.keys(e).map(t=>e[t]?`${r}[${t}]=${e[t]}`:void 0).filter(Boolean).join("&"):(console.warn("deepObject style cannot be used with non-object value:"+e.toString()),"")}function c(e,r,t){const n="__redoc_param_name__",i=r?"*":"";return m.parse(`{?${n}${i}}`).expand({[n]:t}).substring(1).replace(/__redoc_param_name__/g,e)}function h(e,r){const t=e?"*":"",n="__redoc_param_name__",i=m.parse(`{${n}${t}}`);return q(i.expand({[n]:r}))}function ye(e,r={}){if(Array.isArray(e))throw new Error("Payload must have fields: "+e.toString());return Object.keys(e).map(t=>{const n=e[t],{style:i="form",explode:o=!0}=r[t]||{};switch(i){case"form":return c(t,o,n);case"spaceDelimited":return p(n,t,"%20");case"pipeDelimited":return p(n,t,"|");case"deepObject":return M(n,t);default:return console.warn("Incorrect or unsupported encoding style: "+i),""}}).join("&")}function H(e,r,t,n){const i=t?"*":"";let o="";r==="label"?o=".":r==="matrix"&&(o=";");const s="__redoc_param_name__";return m.parse(`{${o}${s}${i}}`).expand({[s]:n}).replace(/__redoc_param_name__/g,e)}function J(e,r,t,n){const i=o=>{switch(r){case"form":return c(e,t,o);case"spaceDelimited":return!Array.isArray(o)&&typeof o!="object"?(console.warn("The style spaceDelimited is applicable to arrays or objects"),""):t?c(e,t,o):p(n,e,"%20");case"pipeDelimited":return!Array.isArray(o)&&typeof o!="object"?(console.warn("The style pipeDelimited is applicable to arrays or objects"),""):t?c(e,t,o):p(n,e,"|");case"deepObject":return!t||Array.isArray(o)||typeof o!="object"?(console.warn("The style deepObject is only applicable for objects with explode=true"),""):M(o,e);case"simple":return h(t,n);default:return console.warn("Unexpected style for query: "+r),""}};return w(n)&&(n=S(n).map(o=>i(o))),i(n)}function B(e,r,t){switch(e){case"simple":return h(r,t);default:return console.warn("Unexpected style for header: "+e),""}}function G(e,r,t,n){switch(r){case"form":return c(e,t,n);default:return console.warn("Unexpected style for cookie: "+r),""}}function x(e,r){return W(r)?JSON.stringify(e):(console.warn(`Parameter serialization as ${r} is not supported`),"")}function Q(e,r,t){return C(r)&&typeof e=="object"&&e!==null?R(e).map(n=>`${encodeURIComponent(n.name)}=${encodeURIComponent(n.value||"")}`).join("&"):`${t}=${x(e,r)}`}function ge(e,r){const{name:t,style:n,explode:i=!1,serializationMime:o}=e;if(o)switch(e.in){case"path":case"header":return x(r,o);case"cookie":case"query":return`${t}=${x(r,o)}`;case"querystring":return Q(r,o,t);default:return console.warn("Unexpected parameter location: "+e.in),""}if(!n)return console.warn(`Missing style attribute or content for parameter ${t}`),"";switch(e.in){case"path":return H(t,n,i,r);case"query":case"querystring":return J(t,n,i,r);case"header":return B(n,i,r);case"cookie":return G(t,n,i,r);default:return console.warn("Unexpected parameter location: "+e.in),""}}function be(e){return e.search(/xml/i)!==-1?"xml":e.includes("application/json-seq")?"json-seq":e.includes("application/jsonl")?"jsonl":e.includes("json")?"json":e.includes("multipart/mixed")?"multipart-mixed":e.includes("text/event-stream")?"yaml":"clike"}const A=/^#\/components\/(schemas|pathItems)\/([^/]+)$/;function je(e){return A.test(e||"")}function $e(e){return e?.match(A)?.pop()}function X(e){if(e===void 0)return;const r=e.toString(10);return/^0\.0*1$/.test(r)?`decimal places <= ${r.split(".")[1].length}`:`multiple of ${r}`}function y(e,r,t){let n;return r!==void 0&&t!==void 0?r===t?n=`= ${r} ${e}`:n=`[ ${r} .. ${t} ] ${e}`:t!==void 0?n=`<= ${t} ${e}`:r!==void 0&&(r===1?n="non-empty":n=`>= ${r} ${e}`),n}function K(e){const r=typeof e.exclusiveMinimum=="number"?Math.min(e.exclusiveMinimum,e.minimum??1/0):e.minimum,t=typeof e.exclusiveMaximum=="number"?Math.max(e.exclusiveMaximum,e.maximum??-1/0):e.maximum,n=typeof e.exclusiveMinimum=="number"||e.exclusiveMinimum,i=typeof e.exclusiveMaximum=="number"||e.exclusiveMaximum;if(r!==void 0&&t!==void 0)return`${n?"( ":"[ "}${r} .. ${t}${i?" )":" ]"}`;if(t!==void 0)return`${i?"< ":"<= "}${t}`;if(r!==void 0)return`${n?"> ":">= "}${r}`}function _e(e){const r=[],t=y("characters",e.minLength,e.maxLength);t!==void 0&&r.push(t);const n=y("items",e.minItems,e.maxItems);n!==void 0&&r.push(n);const i=y(e.minProperties===1&&e.maxProperties===1?"property":"properties",e.minProperties,e.maxProperties);i!==void 0&&r.push(i);const o=X(e.multipleOf);o!==void 0&&r.push(o);const s=K(e);return s!==void 0&&r.push(s),e.uniqueItems&&r.push("unique"),r}function Pe(e,r=[]){const t=[],n=[],i=[];return e.forEach(o=>{o.required?r.includes(o.name)?n.push(o):i.push(o):t.push(o)}),n.sort((o,s)=>r.indexOf(o.name)-r.indexOf(s.name)),[...n,...i,...t]}function Ie(e){return e.sort((r,t)=>Number(r.deprecated)-Number(t.deprecated))}function Oe(e,r=[],t=[],{pathPointer:n,operationPointer:i}){const o={};t.forEach(u=>{({resolved:u}=e.deref(u)),o[u.name+"_"+u.in]=!0});const s=r.map((u,f)=>({paramOrRef:u,pointer:_.join(n,["parameters",String(f)])})).filter(({paramOrRef:u})=>({resolved:u}=e.deref(u),!o[u.name+"_"+u.in])),g=t.map((u,f)=>({paramOrRef:u,pointer:_.join(i,["parameters",String(f)])}));return[...s,...g]}function Me(e,r){const n=e===void 0?T((()=>{if(!L)return globalThis.SSR_HOSTNAME||"";const i=window.location.href;return i.endsWith(".html")?b(i):i})()):z(e)?U(e):b(e);return r.length===0&&(r=[{url:"/"}]),r.map(i=>({...i,url:n?N(n,i.url):i.url,description:i.description||""}))}const he=e=>({delete:"del",options:"opts"})[e]||e;function Y(e){return e in{"x-circular-ref":!0,"x-complex":!0,"x-parentRefs":!0,"x-refsStack":!0,"x-codeSamples":!0,"x-displayName":!0,"x-examples":!0,"x-logo":!0,"x-nullable":!0,"x-servers":!0,"x-tagGroups":!0,"x-traitTag":!0,"x-additionalPropertiesName":!0,"x-explicitMappingOnly":!0,"x-enumDescriptions":!0,"x-badges":!0,"x-hideReplay":!0,"x-feedback":!0,"x-assertionType":!0,"x-rbac":!0}||e.startsWith("x-parsed-md-")}function Ae(e,r){return Object.keys(e).filter(t=>r===!0?t.startsWith("x-")&&!Y(t):t.startsWith("x-")&&r.indexOf(t)>-1).reduce((t,n)=>(t[n]=e[n],t),{})}function Se(e){return e.split(" or ").map(r=>r.replace(/^(string|object|number|integer|array|boolean)s?( ?.*)/,"$1s$2")).join(" or ")}function we(e,r){const{resolved:t}=e.deref(r.content);return Z({...r,content:t})}function Z(e){let r=e.content;const t=e["x-examples"],n=e["x-example"];if(t){r={...r};for(const i of Object.keys(t)){const o=t[i];r[i]={...r[i],examples:o}}}else if(n){r={...r};for(const i of Object.keys(n)){const o=n[i];r[i]={...r[i],example:o}}}return r}export{me as detectType,Ae as extractExtensions,we as getContent,Z as getContentWithLegacyExamples,$e as getDefinitionName,fe as getOperationId,pe as getOperationName,ae as getStatusCodeType,_e as humanizeConstraints,K as humanizeNumberRange,C as isFormUrlEncoded,W as isJsonLike,de as isMultipartFormData,je as isNamedDefinition,ce as isOperationName,k as isPrimitiveType,Y as isRedocExtension,xe as isSequentialMediaType,se as isStatusCode,le as isXmlLike,be as langFromMime,Oe as mergeParams,Me as normalizeServers,Se as pluralizeType,ge as serializeParameterValue,x as serializeParameterValueWithMime,J as serializeQueryParameter,Q as serializeQueryStringParameterValueWithMime,he as shortenHTTPVerb,Ie as sortByDeprecated,Pe as sortByRequired,ye as urlFormEncodePayload};
1
+ import{dirname as b}from"path";import m from"url-template";import{deleteEmptyArrayItem as S,isArrayOfObjects as w,isNumeric as E,removeQueryStringAndHash as T,resolveUrl as N,sanitizeItemId as l,normalizeText as j,getValueFromMdParsedExtension as $,isAbsoluteUrl as z}from"./helpers.js";import{DEFAULT_TAG_SLUG as D,MediaTypes as a}from"../constants.js";import{JsonPointer as _}from"./JsonPointer.js";import{joinWithSeparator as P}from"../services/index.js";import{objectToHarParams as R}from"../services/index.js";import{tryDecodeURIComponent as q}from"./string.js";import{getUrlDirname as U}from"./url.js";import{IS_BROWSER as L}from"./dom.js";function I(e){return typeof e=="string"&&/\dxx/i.test(e)}function ae(e){return e==="default"||E(e)||I(e)}function ce(e,r=!1){if(e==="default")return r?"error":"success";let t=typeof e=="string"?parseInt(e,10):e;if(I(e)&&(t*=100),t<100||t>599)throw new Error("invalid HTTP code");let n="success";return t>=300&&t<400?n="redirect":t>=400?n="error":t<200&&(n="info"),n}const F={get:!0,post:!0,put:!0,head:!0,patch:!0,delete:!0,options:!0,$ref:!0,"x-query":!0,query:!0};function pe(e){return e in F}function fe(e){const{operationId:r,pathName:t}=e,n=j($(e,"description"));return j($(e,"summary"))||r||n&&n.substring(0,50)||t||"<no summary>"}function me(e,r){return r?.id?P(r.id,l(e.operationId?e.operationId:d(e.pointer))).toLowerCase():e.tags?.length?l(e.operationId?e.operationId:d(e.pointer)):l(e.operationId?P(D,e.operationId):d(e.pointer))}function d(e){return e?.startsWith("/")?e.slice(1,e.length):e}const O={multipleOf:"number",maximum:"number",exclusiveMaximum:"number",minimum:"number",exclusiveMinimum:"number",maxLength:"string",minLength:"string",pattern:"string",contentEncoding:"string",contentMediaType:"string",items:"array",maxItems:"array",minItems:"array",uniqueItems:"array",maxProperties:"object",minProperties:"object",required:"object",additionalProperties:"object",unevaluatedProperties:"object",patternProperties:"object",properties:"object"};function le(e){if(e.type!==void 0&&!Array.isArray(e.type))return e.type;const r=Object.keys(O);for(const t of r){const n=O[t];if(e[t]!==void 0)return n}return"any"}function k(e,r=e.type){if(e["x-circular-ref"]||e["x-complex"])return!0;if(e.oneOf!==void 0||e.anyOf!==void 0||e.if&&e.then||e.if&&e.else)return!1;let t=!0;const n=Array.isArray(r);return(r==="object"||n&&r?.includes("object"))&&(t=e.properties!==void 0?Object.keys(e.properties).length===0:e.additionalProperties===void 0&&e.unevaluatedProperties===void 0&&e.patternProperties===void 0),Array.isArray(e.items)||Array.isArray(e.prefixItems)?!1:(e.items!==void 0&&typeof e.items!="boolean"&&(r==="array"||n&&r?.includes("array"))&&(t=k(e.items,e.items.type)),t)}function W(e){return e.search(/json/i)!==-1}function de(e){return e?.search(/xml/i)!==-1}function C(e){return e===a.URL_ENCODED}function xe(e){return e===a.MULTIPART}function ye(e){return[a.JSONL,a.NDJSON,a.JSON_SEQ,a.EVENT_STREAM,a.MULTIPART_MIXED].includes(e)}function p(e,r,t){return Array.isArray(e)?e.map(n=>n.toString()).join(t):typeof e=="object"?Object.keys(e).map(n=>`${n}${t}${e[n]}`).join(t):r+"="+e.toString()}function M(e,r){return Array.isArray(e)?(console.warn("deepObject style cannot be used with array value:"+e.toString()),""):typeof e=="object"?Object.keys(e).map(t=>e[t]?`${r}[${t}]=${e[t]}`:void 0).filter(Boolean).join("&"):(console.warn("deepObject style cannot be used with non-object value:"+e.toString()),"")}function c(e,r,t){const n="__redoc_param_name__",i=r?"*":"";return m.parse(`{?${n}${i}}`).expand({[n]:t}).substring(1).replace(/__redoc_param_name__/g,e)}function h(e,r){const t=e?"*":"",n="__redoc_param_name__",i=m.parse(`{${n}${t}}`);return q(i.expand({[n]:r}))}function ge(e,r={}){if(Array.isArray(e))throw new Error("Payload must have fields: "+e.toString());return Object.keys(e).map(t=>{const n=e[t],{style:i="form",explode:o=!0}=r[t]||{};switch(i){case"form":return c(t,o,n);case"spaceDelimited":return p(n,t,"%20");case"pipeDelimited":return p(n,t,"|");case"deepObject":return M(n,t);default:return console.warn("Incorrect or unsupported encoding style: "+i),""}}).join("&")}function H(e,r,t,n){const i=t?"*":"";let o="";r==="label"?o=".":r==="matrix"&&(o=";");const s="__redoc_param_name__";return m.parse(`{${o}${s}${i}}`).expand({[s]:n}).replace(/__redoc_param_name__/g,e)}function J(e,r,t,n){const i=o=>{switch(r){case"form":return c(e,t,o);case"spaceDelimited":return!Array.isArray(o)&&typeof o!="object"?(console.warn("The style spaceDelimited is applicable to arrays or objects"),""):t?c(e,t,o):p(n,e,"%20");case"pipeDelimited":return!Array.isArray(o)&&typeof o!="object"?(console.warn("The style pipeDelimited is applicable to arrays or objects"),""):t?c(e,t,o):p(n,e,"|");case"deepObject":return!t||Array.isArray(o)||typeof o!="object"?(console.warn("The style deepObject is only applicable for objects with explode=true"),""):M(o,e);case"simple":return h(t,n);default:return console.warn("Unexpected style for query: "+r),""}};return w(n)&&(n=S(n).map(o=>i(o))),i(n)}function B(e,r,t){switch(e){case"simple":return h(r,t);default:return console.warn("Unexpected style for header: "+e),""}}function G(e,r,t,n){switch(r){case"form":return c(e,t,n);default:return console.warn("Unexpected style for cookie: "+r),""}}function x(e,r){return W(r)?JSON.stringify(e):(console.warn(`Parameter serialization as ${r} is not supported`),"")}function Q(e,r,t){return C(r)&&typeof e=="object"&&e!==null?R(e).map(n=>`${encodeURIComponent(n.name)}=${encodeURIComponent(n.value||"")}`).join("&"):`${t}=${x(e,r)}`}function be(e,r){const{name:t,style:n,explode:i=!1,serializationMime:o}=e;if(o)switch(e.in){case"path":case"header":return x(r,o);case"cookie":case"query":return`${t}=${x(r,o)}`;case"querystring":return Q(r,o,t);default:return console.warn("Unexpected parameter location: "+e.in),""}if(!n)return console.warn(`Missing style attribute or content for parameter ${t}`),"";switch(e.in){case"path":return H(t,n,i,r);case"query":case"querystring":return J(t,n,i,r);case"header":return B(n,i,r);case"cookie":return G(t,n,i,r);default:return console.warn("Unexpected parameter location: "+e.in),""}}function je(e){return e.search(/xml/i)!==-1?"xml":e.includes("application/json-seq")?"json-seq":e.includes("application/jsonl")?"jsonl":e.includes("json")?"json":e.includes("multipart/mixed")?"multipart-mixed":e.includes("text/event-stream")?"yaml":"clike"}const A=/^#\/components\/(schemas|pathItems)\/([^/]+)$/;function $e(e){return A.test(e||"")}function _e(e){return e?.match(A)?.pop()}function X(e){if(e===void 0)return;const r=e.toString(10);return/^0\.0*1$/.test(r)?`decimal places <= ${r.split(".")[1].length}`:`multiple of ${r}`}function y(e,r,t){let n;return r!==void 0&&t!==void 0?r===t?n=`= ${r} ${e}`:n=`[ ${r} .. ${t} ] ${e}`:t!==void 0?n=`<= ${t} ${e}`:r!==void 0&&(r===1?n="non-empty":n=`>= ${r} ${e}`),n}function K(e){const r=typeof e.exclusiveMinimum=="number"?Math.min(e.exclusiveMinimum,e.minimum??1/0):e.minimum,t=typeof e.exclusiveMaximum=="number"?Math.max(e.exclusiveMaximum,e.maximum??-1/0):e.maximum,n=typeof e.exclusiveMinimum=="number"||e.exclusiveMinimum,i=typeof e.exclusiveMaximum=="number"||e.exclusiveMaximum;if(r!==void 0&&t!==void 0)return`${n?"( ":"[ "}${r} .. ${t}${i?" )":" ]"}`;if(t!==void 0)return`${i?"< ":"<= "}${t}`;if(r!==void 0)return`${n?"> ":">= "}${r}`}function Pe(e){const r=[],t=y("characters",e.minLength,e.maxLength);t!==void 0&&r.push(t);const n=y("items",e.minItems,e.maxItems);n!==void 0&&r.push(n);const i=y(e.minProperties===1&&e.maxProperties===1?"property":"properties",e.minProperties,e.maxProperties);i!==void 0&&r.push(i);const o=X(e.multipleOf);o!==void 0&&r.push(o);const s=K(e);return s!==void 0&&r.push(s),e.uniqueItems&&r.push("unique"),r}function Ie(e,r=[]){const t=[],n=[],i=[];return e.forEach(o=>{o.required?r.includes(o.name)?n.push(o):i.push(o):t.push(o)}),n.sort((o,s)=>r.indexOf(o.name)-r.indexOf(s.name)),[...n,...i,...t]}function Oe(e){return e.sort((r,t)=>Number(r.deprecated)-Number(t.deprecated))}function Me(e,r=[],t=[],{pathPointer:n,operationPointer:i}){const o={};t.forEach(u=>{({resolved:u}=e.deref(u)),o[u.name+"_"+u.in]=!0});const s=r.map((u,f)=>({paramOrRef:u,pointer:_.join(n,["parameters",String(f)])})).filter(({paramOrRef:u})=>({resolved:u}=e.deref(u),!o[u.name+"_"+u.in])),g=t.map((u,f)=>({paramOrRef:u,pointer:_.join(i,["parameters",String(f)])}));return[...s,...g]}function he(e,r){const n=e===void 0?T((()=>{if(!L)return globalThis.SSR_HOSTNAME||"";const i=window.location.href;return i.endsWith(".html")?b(i):i})()):z(e)?U(e):b(e);return r.length===0&&(r=[{url:"/"}]),r.map(i=>({...i,url:n?N(n,i.url):i.url,description:i.description||""}))}const Ae=e=>({delete:"del",options:"opts"})[e]||e;function Y(e){return e in{"x-circular-ref":!0,"x-complex":!0,"x-parentRefs":!0,"x-refsStack":!0,"x-codeSamples":!0,"x-displayName":!0,"x-examples":!0,"x-logo":!0,"x-nullable":!0,"x-servers":!0,"x-tagGroups":!0,"x-traitTag":!0,"x-additionalPropertiesName":!0,"x-explicitMappingOnly":!0,"x-enumDescriptions":!0,"x-badges":!0,"x-hideReplay":!0,"x-feedback":!0,"x-assertionType":!0,"x-rbac":!0}||e.startsWith("x-parsed-md-")}function Se(e,r){return Object.keys(e).filter(t=>r===!0?t.startsWith("x-")&&!Y(t):t.startsWith("x-")&&r.indexOf(t)>-1).reduce((t,n)=>(t[n]=e[n],t),{})}function we(e){return e.split(" or ").map(r=>r.replace(/^(string|object|number|integer|array|boolean)s?( ?.*)/,"$1s$2")).join(" or ")}function Ee(e,r){const{resolved:t}=e.deref(r.content);return Z({...r,content:t})}function Z(e){let r=e.content;const t=e["x-examples"],n=e["x-example"];if(t){r={...r};for(const i of Object.keys(t)){const o=t[i];r[i]={...r[i],examples:o}}}else if(n){r={...r};for(const i of Object.keys(n)){const o=n[i];r[i]={...r[i],example:o}}}return r}export{le as detectType,Se as extractExtensions,Ee as getContent,Z as getContentWithLegacyExamples,_e as getDefinitionName,me as getOperationId,fe as getOperationName,ce as getStatusCodeType,Pe as humanizeConstraints,K as humanizeNumberRange,C as isFormUrlEncoded,W as isJsonLike,xe as isMultipartFormData,$e as isNamedDefinition,pe as isOperationName,k as isPrimitiveType,Y as isRedocExtension,ye as isSequentialMediaType,ae as isStatusCode,de as isXmlLike,je as langFromMime,Me as mergeParams,he as normalizeServers,we as pluralizeType,be as serializeParameterValue,x as serializeParameterValueWithMime,J as serializeQueryParameter,Q as serializeQueryStringParameterValueWithMime,Ae as shortenHTTPVerb,Oe as sortByDeprecated,Ie as sortByRequired,ge as urlFormEncodePayload};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/openapi-docs",
3
- "version": "3.20.0-next.1",
3
+ "version": "3.20.0-next.3",
4
4
  "description": "Redocly OpenAPI Docs",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -21,9 +21,9 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "@markdoc/markdoc": "0.5.2",
24
- "@redocly/openapi-core": "2.20.5",
24
+ "@redocly/openapi-core": "2.24.0",
25
25
  "deepmerge": "^4.2.2",
26
- "dompurify": "3.2.7",
26
+ "dompurify": "3.3.3",
27
27
  "fast-deep-equal": "^3.1.3",
28
28
  "fast-xml-parser": "5.4.1",
29
29
  "jotai": "^2.12.5",
@@ -38,8 +38,9 @@
38
38
  "url-template": "^2.0.8",
39
39
  "util": "~0.12.5",
40
40
  "web-vitals": "3.3.1",
41
- "@redocly/config": "0.44.1",
42
- "@redocly/replay": "0.23.0-next.1"
41
+ "@redocly/config": "0.44.2",
42
+ "@redocly/redoc-opentelemetry": "0.0.7",
43
+ "@redocly/replay": "0.23.0-next.2"
43
44
  },
44
45
  "devDependencies": {
45
46
  "@shikijs/transformers": "3.21.0",
@@ -71,7 +72,7 @@
71
72
  "url": "~0.11.0",
72
73
  "vite": "7.2.6",
73
74
  "vitest": "4.0.10",
74
- "@redocly/theme": "0.64.0-next.1"
75
+ "@redocly/theme": "0.64.0-next.2"
75
76
  },
76
77
  "scripts": {
77
78
  "start": "pnpm run copy-highlight-hook && vite",