@redocly/openapi-docs 3.14.0-next.0 → 3.14.0-next.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/redocly-openapi-docs.min.js +1947 -1868
- package/lib/components/ContentItems/ContentItems.js +1 -1
- package/lib/components/OperationItem/OperationItem.js +4 -4
- package/lib/components/PropertyDetails/FieldDetails.js +6 -6
- package/lib/components/RedoclyOpenAPIDocs/RedoclyOpenAPIDocsStandalone.js +1 -1
- package/lib/components/Replay/Replay.js +1 -1
- package/lib/components/Replay/utils.d.ts +3 -2
- package/lib/components/Replay/utils.js +1 -1
- package/lib/components/Request/RequestDetails.js +2 -2
- package/lib/components/Responses/OperationResponseList.js +1 -1
- package/lib/components/SchemaCatalogLink/SchemaCatalogLink.d.ts +5 -0
- package/lib/components/SchemaCatalogLink/SchemaCatalogLink.js +36 -0
- package/lib/components/SchemaCatalogLink/tests/SchemaCatalogLink.test.d.ts +1 -0
- package/lib/components/SchemaCatalogLink/tests/SchemaCatalogLink.test.js +1 -0
- package/lib/components/SchemaDefinition/SchemaDefinition.js +4 -2
- package/lib/components/TagItem/TagItem.js +6 -6
- package/lib/components/common/linkify.js +4 -4
- package/lib/constants.d.ts +4 -0
- package/lib/constants.js +1 -1
- package/lib/models/operation.d.ts +2 -1
- package/lib/models/operation.js +1 -1
- package/lib/services/code-samples/httpsnippet/targets/php/utils.js +2 -2
- package/lib/services/history/helpers.js +1 -1
- package/lib/types/open-api.d.ts +2 -1
- package/lib/utils/configure-helpers.d.ts +1 -0
- package/lib/utils/configure-helpers.js +1 -1
- package/lib/utils/hasNestedFields.d.ts +2 -0
- package/lib/utils/hasNestedFields.js +1 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +1 -1
- package/lib/utils/loadAndBundleSpec.d.ts +2 -659
- package/lib/utils/loadAndBundleSpec.js +1 -1
- package/lib/utils/path.js +1 -1
- package/package.json +9 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as t,jsxs as l,Fragment as f}from"react/jsx-runtime";import{memo as u,useMemo as p}from"react";import{Navigate as c,Route as n,Routes as m}from"react-router-dom";import{getFirstPageLink as d,getItemsByType as g}from"./helpers.js";import{SectionContent as s}from"../SectionContent/index.js";function h({items:e,root:r=!1}){const{rootItem:o}=g(e),a=!r||o?"/":d(e,"/"),i=p(()=>l(m,{children:[o&&t(n,{path:`${o.href||"/"}*`,element:t(s,{items:e})}),t(n,{path:"*",element:t(c,{to:a,replace:!0})})]}),[o,"/",e,a]);return r&&!e.length?t(m,{children:t(n,{path:"*",element:t(s,{items:e})})}):e.length?t(f,{children:i}):null}const I=u(h);export{I as ContentItems};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t,Fragment as V}from"react/jsx-runtime";import{memo as K,useState as F,useCallback as
|
|
1
|
+
import{jsx as e,jsxs as t,Fragment as V}from"react/jsx-runtime";import{memo as K,useState as F,useCallback as L,useMemo as j}from"react";import{useAtomValue as g}from"jotai";import{LayoutVariant as $}from"@redocly/config";import{AfterOpenApiOperation as z}from"@redocly/theme/components/OpenApiDocs/hooks/AfterOpenApiOperation";import{BeforeOpenApiOperation as G}from"@redocly/theme/components/OpenApiDocs/hooks/BeforeOpenApiOperation";import{PageActions as J}from"@redocly/theme/components/PageActions/PageActions";import{Feedback as Q}from"@redocly/theme/components/Feedback/Feedback";import{SamplesMiddlePanel as s,SamplesPanel as U,ShareLink as X,Row as W,CustomBadges as Y}from"../common/index.js";import{CallbacksList as Z}from"../Callbacks/index.js";import{CallbackSamples as ee}from"../CallbackSamples/index.js";import{RequestSamples as ae}from"../RequestSamples/index.js";import{OperationResponseList as te}from"../Responses/index.js";import{ResponseSamples as oe}from"../ResponseSamples/index.js";import{makeDeepLink as ne,joinWithSeparator as se}from"../../services/index.js";import{layoutAtom as re,userClaimsAtom as ie}from"../../jotai/app.js";import{globalOptionsAtom as le,globalStoreAtom as ce}from"../../jotai/store.js";import{getOperation as pe}from"../../models/operation.js";import{RenderHook as B}from"../RenderHook/index.js";import{Heading as de,HeadingWrapper as me,Title as ge}from"../common/OperationItemTitle.js";import{LinkToField as ke}from"../common/LinkToField.js";import{RequestDetails as he}from"../Request/RequestDetails.js";import{StyledBadge as H}from"../common/Badges.js";import{useTranslate as ue}from"../../hooks/index.js";import{styled as k}from"../../styled-components.js";import{createPanelToggleEvent as be}from"../../events/index.js";import{SchemaCatalogLink as fe}from"../SchemaCatalogLink/SchemaCatalogLink.js";function Se({item:{operationDefinition:S,parent:v,href:h}}){const r=ue(),{parser:y,options:l}=g(ce),{events:x}=g(le),T=g(ie),n=g(re),[c,I]=F(),{unstable_hooks:C,feedback:p}=l,a=j(()=>pe(y,S,v,l,h,void 0,T),[h,S,l,v,y,T]),{name:O,deprecated:_,isWebhook:q,badges:D}=a||{},o=n===$.STACKED,R=p?.type||"sentiment",A=p?.hide!==!0,u=se(l.routingBasePath,a.href),[b,E]=F(null),P=L(m=>{c!==m&&I(m)},[c]),d=L((m,w)=>{if(!w)return;const N=be({operation:a,isExpanded:m,panelType:w});x?.panelToggle?.(N)},[x,a]),M=j(()=>A?e(ve,{children:e(Q,{type:R,settings:p.settings,path:u})}):null,[A,R,p.settings,u]);return t(ye,{layout:n,children:[e(i,{layout:n,children:t(s,{isStacked:o,children:[e(B,{Hook:G||C?.BeforeOperation,props:{operation:a}}),t(me,{children:[t(de,{"data-testid":"operation-item-header",children:[e(X,{to:h,"aria-label":`link to ${O}`}),e(Y,{badges:D,children:O}),_&&e(H,{deprecated:!0,children:r("openapi.badges.deprecated","Deprecated")}),q&&e(H,{children:r("openapi.badges.webhook","Webhook")})]}),e(J,{pageSlug:u})]})]})}),e(s,{isStacked:o,children:e(fe,{schemaRef:"#"+a.pointer})}),t(i,{layout:n,children:[e(s,{isStacked:o,children:e(he,{operation:a,translate:r,onPanelToggle:d})}),e(f,{isStacked:o,"data-testid":"samples-block",className:"panel-container-request-samples",children:e(ae,{operation:a,onPanelToggle:d})})]}),t(i,{layout:n,children:[e(s,{isStacked:o,children:a.responses?.length?e(te,{responses:a.responses,operationId:a.id,operationPointer:a.pointer,callbackId:a.callbackId,activeResponseTab:c,onTabChange:P,onPanelToggle:d}):null}),e(f,{isStacked:o,"data-testid":"samples-block",className:"panel-container-response-samples",children:e(oe,{operation:a,activeResponseTab:c,onTabChange:P,onPanelToggle:d})})]}),t(i,{layout:n,children:[t(s,{isStacked:o,children:[a.callbacks?.length?t(V,{children:[t(ge,{children:[e(ke,{to:ne(a.id,"callbacks")}),r("openapi.callbacks","Callbacks")]}),e(Z,{callbacks:a.callbacks,onExpand:E,selectedCallback:b})]}):null,e(B,{Hook:z||C?.AfterOperation,props:{operation:a}})]}),b?e(f,{isStacked:o,"data-testid":"samples-block",children:e(ee,{callback:b,translate:r})}):null]}),e(i,{layout:n,children:e(s,{isStacked:o,fullWidth:!0,children:M})})]})}const Qe=K(Se),f=k(U)`
|
|
2
2
|
margin-left: auto;
|
|
3
3
|
--code-block-padding: var(--spacing-xs) 0 var(--spacing-xs) 20px;
|
|
4
|
-
`,
|
|
4
|
+
`,ve=k.div`
|
|
5
5
|
& > div {
|
|
6
6
|
flex: 1 1 auto;
|
|
7
7
|
display: flex;
|
|
@@ -12,10 +12,10 @@ import{jsx as e,jsxs as t,Fragment as V}from"react/jsx-runtime";import{memo as K
|
|
|
12
12
|
width: 100%;
|
|
13
13
|
max-width: var(--feedback-width);
|
|
14
14
|
}
|
|
15
|
-
`,
|
|
15
|
+
`,ye=k(W)`
|
|
16
16
|
flex-direction: column;
|
|
17
17
|
align-items: flex-start;
|
|
18
18
|
padding: var(--spacing-base) 0 calc(var(--spacing-xl) + var(--spacing-xs));
|
|
19
19
|
`,i=k(W)`
|
|
20
20
|
margin: calc(var(--spacing-unit) * 2) 0;
|
|
21
|
-
`;export{
|
|
21
|
+
`;export{Qe as OperationItem,f as OperationSamplesPanel};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import{jsx as e,jsxs as p,Fragment as E}from"react/jsx-runtime";import{memo as
|
|
1
|
+
import{jsx as e,jsxs as p,Fragment as E}from"react/jsx-runtime";import{memo as S,useMemo as k}from"react";import{useAtomValue as L}from"jotai";import{LinkIcon as j}from"@redocly/theme/icons/LinkIcon/LinkIcon";import{RecursiveLabel as h,Tag as x,AccessLabel as q,RequiredLabel as A,StyledBadge as C}from"../common/index.js";import{ExternalDocumentation as M}from"../ExternalDocumentation/index.js";import{Markdown as R}from"../Markdown/index.js";import{FieldDetail as l}from"./FieldDetail.js";import{Extensions as V}from"./Extensions.js";import{EnumValues as $}from"./EnumValues.js";import{Examples as N,getSerializedValue as O}from"./Examples.js";import{globalOptionsAtom as _}from"../../jotai/store.js";import{SchemaTypeInfo as i}from"./SchemaTypeInfo.js";import{LinkToField as B}from"../common/LinkToField.js";import{Pattern as I}from"./Pattern.js";import{getAccessModeLabelText as H}from"../RenderHook/index.js";import{useTranslate as G}from"../../hooks/index.js";import{styled as n}from"../../styled-components.js";function J({field:t,renderDiscriminatorSwitch:y,deepLink:m,fieldParentsName:v=[]}){const a=G(),{hidePropertiesPrefix:g,hideSchemaTitles:b}=L(_),{schema:r,description:w,example:c,deprecated:D,examples:s,kind:d,required:F,name:f}=t,P=t.in==="header",T=r.oneOfType||r.rawSchema?.allOf?.[0],z=k(()=>{if(c!==void 0||s!==void 0){if(s!==void 0)return e(N,{field:t});{const o=!!t.in;return e(l,{label:`${a("openapi.example","Example")}:`,value:O(t,t.example),raw:o})}}else return null},[c,s,t,a]),u=H(t.schema);return p(E,{children:[p(K,{children:[f&&p(U,{children:[m&&e(B,{to:m}),!g&&v.map(o=>o+".\u200B"),e(W,{className:"schema-name",children:f})]}),e(i,{type:r.typePrefix+r.displayType}),e(i,{type:r.displayFormat&&`(${r.displayFormat})`}),e(i,{type:r.contentEncoding}),e(i,{type:r.title&&!b?`(${r.title})`:""}),r.constraints?.map(o=>e(i,{type:o},o)),D&&e(C,{deprecated:!0,children:a("openapi.badges.deprecated","Deprecated")}),e(I,{pattern:r.pattern}),d==="additionalProperties"&&e(x,{children:a("openapi.additionalProperties","additional property")}),d==="patternProperties"&&e(x,{children:a("openapi.patternProperties","pattern property")}),u&&e(q,{children:u}),F&&e(A,{children:a("openapi.required","required")}),r.isCircular&&e(h,{children:a("openapi.recursive","Recursive")})]}),r.isComplex&&e(h,{children:a("openapi.complex","Complex")}),!T&&e(Q,{source:w}),e(l,{raw:P,type:"default",label:a("openapi.default","Default"),value:r.default}),e($,{type:r.type,values:r["x-enumDescriptions"]||r.enum}),z,e(V,{extensions:{...t.extensions,...r.extensions}}),r.externalDocs&&e(M,{externalDocs:r.externalDocs,compact:!0}),y?.(),e(l,{label:a("openapi.value","Value"),value:t.const||void 0})]})}const he=S(J),K=n.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
align-items: center;
|
|
4
4
|
gap: calc(var(--spacing-xxs) / 4) var(--spacing-xxs);
|
|
5
5
|
flex-wrap: wrap;
|
|
6
6
|
margin-bottom: 2px;
|
|
7
7
|
position: relative;
|
|
8
|
-
`,
|
|
8
|
+
`,Q=n(R)`
|
|
9
9
|
font-size: var(--font-size-base);
|
|
10
10
|
line-height: var(--line-height-base);
|
|
11
11
|
|
|
12
12
|
article p:last-child {
|
|
13
13
|
margin-bottom: 0;
|
|
14
14
|
}
|
|
15
|
-
`,
|
|
15
|
+
`,U=n.span`
|
|
16
16
|
position: relative;
|
|
17
17
|
font-family: var(--font-family-monospaced);
|
|
18
18
|
line-height: var(--line-height-base);
|
|
@@ -24,16 +24,16 @@ import{jsx as e,jsxs as p,Fragment as E}from"react/jsx-runtime";import{memo as T
|
|
|
24
24
|
white-space: pre-wrap;
|
|
25
25
|
|
|
26
26
|
:hover {
|
|
27
|
-
${
|
|
27
|
+
${j} {
|
|
28
28
|
opacity: 1;
|
|
29
29
|
visibility: visible;
|
|
30
30
|
background-color: var(--bg-color);
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
`,
|
|
33
|
+
`,W=n.span`
|
|
34
34
|
font-family: var(--font-family-monospaced);
|
|
35
35
|
font-weight: var(--font-weight-semibold);
|
|
36
36
|
font-size: var(--schemas-property-name-font-size);
|
|
37
37
|
line-height: var(--schemas-property-name-line-height);
|
|
38
38
|
color: var(--text-color-primary);
|
|
39
|
-
`;export{
|
|
39
|
+
`;export{he as FieldDetails};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as p}from"react/jsx-runtime";import{cloneElement as w,isValidElement as v,useEffect as g,useMemo as x,useState as a}from"react";import{Loading as A}from"@redocly/theme/components/Loaders/Loading";import{useDeepCompareMemoize as D,fixSpec as L}from"./utils.js";import{argValueToBoolean as O}from"../../utils/index.js";import{RedoclyOpenAPIDocs as B}from"./RedoclyOpenAPIDocs.js";import{loadAndBundleDefinition as u,loadOpenapiConfig as E}from"../../utils/loadAndBundleSpec.js";async function C(e,o,t){let n;if(t?.skipBundle){if(!e)throw new Error('spec must be specified when using "skipBundleAndConvert"');n=e}else n=await u(e||o);try{L(n)}catch{}return n}function z(e,o){return e.endsWith(".md")?u({openapi:"3.0.0",info:{title:o||"",version:"1.0",description:{$ref:e}},paths:{}}):u(e)}const I=({options:e,definitionUrl:o,definition:t,activeSampleLanguage:n,children:r})=>{const[,l]=a(),[s,f]=a(!0),[d,h]=a(null),[m,y]=a(e||{});g(()=>{async function S(){f(!0);try{const c=await E();y({...e,...c}),h(await C(t,o,e))}catch(c){l(()=>{throw c})}}S()},[t,o,e]);const i=x(()=>{if(d)return{definition:d,options:m,definitionUrl:o,activeSampleLanguage:n}},D([d,o,m]));return g(()=>{i&&f(!1)},[i]),i?s?O(e?.hideLoading,!1)?null:p(A,{color:"--loading-spinner-color"}):v(r)?w(r,{store:i}):null:null};function T({definition:e,definitionUrl:o,options:t={},activeItemId:n,activeSampleLanguage:r,activeDeepLink:l,router:s}){return p(I,{definition:e,definitionUrl:o,options:t,activeItemId:n,activeSampleLanguage:r,activeDeepLink:l,children:p(B,{withCommonStyles:!0,router:s})})}export{I as AppProvider,T as RedoclyOpenAPIDocsStandalone,z as loadAndBundleSpecOrMd,C as loadSingle};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as o,Fragment as M,jsxs as z}from"react/jsx-runtime";import{lazy as J,memo as K,Suspense as W,useCallback as m,useRef as w,useState as H}from"react";import{useAtom as u,useAtomValue as p}from"jotai";import Q from"deepmerge";const X=J(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/useConfigureReplay";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";function ge({operation:e,corsProxyUrl:L,fullOpenApi:d}){const y=ue(),P=de(),h=w(null),{mockServer:q,oAuth2RedirectURI:E,routingBasePath:c}=p(ne),O=p(se),{parser:I,options:{events:a}}=p(ae),R=p(ce),[s,N]=H(!1),[l,g]=u(ie),[v,A]=u(le),[[,V],S]=u(pe),{config:j,refresh:T}=re({userClaims:R,info:I?.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(()=>T(),[T]),k=m(({operations:t,environment:i,environments:f})=>{const _=t.reduce((C,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,b=ye.compile(["paths",F,B]);return C[b]=Q(me(b),r),C},{});A({...v,..._}),S({environment:i,environments:f})},[v,A,S]),D=()=>{if(l!==n.LOADING){if(!s&&(P.sendOpenapiDocsTryItOpenedMessage(),a?.tryItOpen&&e)){const t=Oe({operation:e});a.tryItOpen(t)}N(!s)}l===n.NOT_LOADED&&g(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=O.find(f=>f.operationId===t);return Re(c,i?.href)},[O,c]);return d?z(M,{children:[o(Y,{onClick:D,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(W,{children:o(oe,{mountId:"api-content",children:o("div",{ref:h,children:o(X,{activeOperationId:e.operationId||e.pointer,api:d,onRequestChange:k,onClose:D,onLoad:()=>g(n.LOADED),settings:{corsProxyUrl:L,mockServer:q,selectedEnvironment:V,apiId:I?.definition.info?.["x-metadata"]?.apiId,oAuth2RedirectURI:E,disableCollectionsTab:!0,storageKey:c,telemetry:{tracerName:"try-it",collectorUrl:he()},convertOperationToReplayValue:fe(R,j),getOperationUrl:U,onRequestReset:x},onRequestSent:G})})})})]}):null}const Me=K(ge);export{Me as Replay};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { OpenAPIDefinition } from '../../types/index.js';
|
|
2
2
|
import type { OperationStore } from '../../jotai/operation.js';
|
|
3
3
|
import type { AppStore } from '../../jotai/app.js';
|
|
4
|
+
import type { ConfigureRequestValues, ConfigureServerRequestValues } from '@redocly/theme/ext/configure';
|
|
4
5
|
import { type UserClaims } from '@redocly/theme/core/openapi';
|
|
5
6
|
import { type SecurityRequirement } from '../../models/index.js';
|
|
6
|
-
export declare function convertOperationToReplayValue(path: string, method: string, openAPI: OpenAPIDefinition, userClaims?: UserClaims, operationState?: OperationStore, appState?: AppStore): {
|
|
7
|
+
export declare function convertOperationToReplayValue(path: string, method: string, openAPI: OpenAPIDefinition, userClaims?: UserClaims, operationState?: OperationStore, appState?: AppStore, dynamicReplayValues?: ConfigureRequestValues | ConfigureServerRequestValues | null): {
|
|
7
8
|
id: string;
|
|
8
9
|
name: string;
|
|
9
10
|
method: string;
|
|
@@ -22,7 +23,7 @@ export declare function convertOperationToReplayValue(path: string, method: stri
|
|
|
22
23
|
};
|
|
23
24
|
};
|
|
24
25
|
} | undefined;
|
|
25
|
-
export declare function convertOperationToReplayValueForRedoc(userClaims?: UserClaims): (path: string, method: string, openAPI: OpenAPIDefinition) => {
|
|
26
|
+
export declare function convertOperationToReplayValueForRedoc(userClaims?: UserClaims, dynamicReplayValues?: ConfigureRequestValues | ConfigureServerRequestValues | null): (path: string, method: string, openAPI: OpenAPIDefinition) => {
|
|
26
27
|
operationId: string;
|
|
27
28
|
id: string;
|
|
28
29
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isPrimitive as
|
|
1
|
+
import{isPrimitive as h}from"@redocly/theme/core/openapi";import{getOperation as v}from"../../models/index.js";import{normalizeOptions as b,OpenAPIParser as E}from"../../services/index.js";import{JsonPointer as V}from"../../utils/index.js";function y(t,a,n,r,e,m,s){if(!n)return;const u=new E(n),o=u.definition.paths?.[t],f=o?.[a],i=v(u,{...f,pathName:t,httpVerb:a,pathParameters:o.parameters||[],pathServers:o.servers||[]},void 0,b({}),"",{isCallback:!1},r,s);if(!i)return;const x=m?.activeMimeName||i.requestBody?.content?.mediaTypes[0]?.name||"application/json";return{id:i.id,name:i.name,method:i.httpVerb,operationId:i.operationId,parameters:O(i.parameters,e?.requestValues),body:w(i.requestBody,n,e?.requestValues?.body?{activeExampleName:e?.activeExampleName,[x]:e?.requestValues?.body}:e?.activeExampleName?{activeExampleName:e?.activeExampleName}:void 0),path:i.path,href:i.href,servers:i.servers,security:q(i.security),responses:Object.fromEntries(i.responses.map(c=>[c.code,{code:c.code,description:c.description,mediaTypes:c.content?.mediaTypes.reduce((d,l)=>(d[l.name]={name:l.name,schema:p(l.schema?.rawSchema,n)},d),{})}]))}}function T(t,a){return function(n,r,e){const m=y(n,r,e,t,void 0,void 0,a);if(m)return{...m,operationId:m.operationId||V.compile(["paths",m.path,m.method])}}}function O(t,a){const n=new Set,r=t.map(e=>(n.add(e.in+":"+e.name),{name:e.name,in:e.in,required:e.required,description:e.description,example:a?.[String(e.in)]?.[e.name]||e.example,schema:e.schema}));for(const[e,m]of Object.entries(a||{}))for(const[s,u]of Object.entries(m||{}))n.has(e+":"+s)||r.push({name:s,in:e,required:!1,description:"",example:String(u),schema:void 0});return r}function N({type:t,format:a,enum:n}){return t==="string"&&(a==="binary"||a==="base64")?"file":t==="object"?"multiline":n.length>0?"select":"text"}function g(t,a){const n=t[0]?.example||t[0]?.examples;if(n)return n;if(t.schema?.example)return t.schema.example;const r=a?.default?.value||a?.default?.rawValue;return r?.[t.name]?h(r?.[t.name])?String(r?.[t.name]):JSON.stringify(r?.[t.name]):""}function w(t,a,n){if(!t||!t.content?.mediaTypes){if(!n)return;const{activeExampleName:r,...e}=n;return{activeExampleName:r,mediaTypes:Object.fromEntries(Object.entries(e).map(([m,s])=>[m,{name:m,examples:{default:{value:s}},schema:{},parameters:[]}]))}}return{required:t.required,activeExampleName:n?.activeExampleName,mediaTypes:t.content.mediaTypes.reduce((r,e)=>{const m=e.schema,s=n?.[e.name]?{default:{value:n?.[e.name],rawValue:n?.[e.name],mime:e.name}}:e.examples||e.formExamples;return r[e.name]={name:e.name,examples:s,schema:p(e.schema?.rawSchema,a),parameters:m?.fields?.map(u=>({inputType:N(u.schema),name:u.name,example:g(u,s)}))},r},{})}}function p(t,a){if(!(!t||!a))return{...t,components:a?.components||{}}}function q(t){if(t)return t.map(({schemes:a})=>a.map(n=>{const r={id:n.id,type:n.type,in:n.in,openIdConnectUrl:n.openIdConnectUrl,scopes:n.scopes,scheme:n.scheme,name:n.name,flows:n.flows,serverValues:n.serverValues,"x-defaultAccessToken":n["x-defaultAccessToken"],"x-defaultTokenType":n["x-defaultTokenType"],"x-defaultClientId":n["x-defaultClientId"],"x-defaultClientSecret":n["x-defaultClientSecret"],"x-defaultUsername":n["x-defaultUsername"],"x-defaultPassword":n["x-defaultPassword"]};return Object.keys(r).forEach(e=>r[e]===void 0&&delete r[e]),r}))}export{y as convertOperationToReplayValue,T as convertOperationToReplayValueForRedoc,q as convertRequestSecurity};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{jsx as e,jsxs as
|
|
1
|
+
import{jsx as e,jsxs as i,Fragment as v}from"react/jsx-runtime";import{memo as A,useMemo as P}from"react";import{useAtomValue as R}from"jotai";import{Row as q}from"../common/index.js";import{Title as D}from"../common/OperationItemTitle.js";import{LinkToField as E}from"../common/LinkToField.js";import{makeDeepLink as F}from"../../services/index.js";import{Description as M}from"../OperationItem/Description.js";import{Security as N}from"../Security/index.js";import{hasNestedFields as T}from"../../utils/index.js";import{ExpandAllButton as b}from"../ExpandAllButton/index.js";import{RequestParameters as w}from"../RequestParameters/index.js";import{activeMimeNameAtom as y}from"../../jotai/app.js";import{getActiveMediaType as C}from"../../models/mediaContent.js";import{styled as _}from"../../styled-components.js";import{Extensions as I}from"../common/Extensions.js";function L({operation:{id:o,description:m,externalDocs:n,parameters:r,requestBody:t,pointer:l,security:f,extensions:s,callbackId:u},title:d,translate:h,onPanelToggle:x}){const a=R(y),g=P(()=>{const p=r.some(({schema:c})=>!c.isPrimitive&&!c.isCircular);if(!t?.content||p)return p;const{schema:k}=C(t.content,a)||{};return T(k)},[a,r,t?.content]),j=Object.keys(s||{}).length>0;return i(v,{children:[e(q,{children:i(H,{children:[i(D,{children:[o&&e(E,{to:F(o,"request")}),d||h?.("openapi.request","Request"),g&&e(b,{operationPointer:l,type:"request",onPanelToggle:x})]}),e(M,{description:m||n?m:void 0,externalDocs:n}),j&&e(I,{extensions:s}),e(N,{securities:f})]})}),e(w,{parameters:r,body:t,operationId:o,callbackId:u})]})}const H=_.div`
|
|
2
2
|
width: 100%;
|
|
3
|
-
`,
|
|
3
|
+
`,te=A(L);export{te as RequestDetails};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{jsx as n,jsxs as a,Fragment as
|
|
1
|
+
import{jsx as n,jsxs as a,Fragment as v}from"react/jsx-runtime";import{memo as A,useMemo as L}from"react";import{useLocation as j}from"react-router-dom";import{useAtomValue as w}from"jotai";import{Tabs as F,useTabsState as M}from"../Tabs/index.js";import{ResponseDetails as C}from"./ResponseDetails.js";import{makeDeepLink as N}from"../../services/index.js";import{Row as R,StyledTitle as _}from"./styled.js";import{LinkToField as B}from"../common/LinkToField.js";import{pathIncludesLink as c,hasNestedFields as D}from"../../utils/index.js";import{ExpandAllButton as E}from"../ExpandAllButton/index.js";import{useTranslate as P}from"../../hooks/index.js";import{getActiveMediaType as S}from"../../models/index.js";import{activeMimeNameAtom as $}from"../../jotai/app.js";import{styled as I}from"../../styled-components.js";const oe=A(({responses:i,renderTitle:f,operationId:s,operationPointer:d,activeResponseTab:m,onTabChange:u,callbackId:h,onPanelToggle:T})=>{const p=j(),b=P(),l=w($),r=i.map(({code:e})=>({key:e,title:e})),g=r.find(({key:e})=>e===m||c(p,s)&&c(p,`c=${e}`)),{activeTab:k,handleTabChange:x}=M({tabs:r,defaultTab:g?.key,onChange:u}),o=r.find(e=>e.key===(m||k)),t=i.find(e=>e.code===o?.key),y=L(()=>{if(!t?.content)return!1;const{schema:e}=S(t?.content,l)||{};return D(e)},[l,t?.content]);return o?a(v,{children:[a(O,{children:[f?.(o)||a(_,{children:[n(B,{to:N(s,`response&c=${o.key}`)}),b("openapi.responses","Responses")]}),n(F,{tabs:r,activeTab:o,onChange:x}),y&&n(E,{type:"response",operationPointer:d,onPanelToggle:T})]}),t?n("div",{children:n(C,{response:t,operationId:s,callbackId:h})},t.code):null]}):null}),O=I(R)`
|
|
2
2
|
flex-wrap: wrap;
|
|
3
3
|
gap: var(--spacing-unit);
|
|
4
4
|
`;export{oe as OperationResponseList};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import{jsx as o,jsxs as p}from"react/jsx-runtime";import{useAtomValue as b}from"jotai";import{useState as d}from"react";import{Button as C}from"@redocly/theme/components/Button/Button";import{CopyLinkIcon as T}from"@redocly/theme/icons/CopyLinkIcon/CopyLinkIcon";import{ShareIcon as w}from"@redocly/theme/icons/ShareIcon/ShareIcon";import{ClipboardService as S}from"@redocly/theme/core/openapi";import{Tooltip as r}from"@redocly/theme/components/Tooltip/Tooltip";import{styled as t}from"../../styled-components.js";import{IS_BROWSER as L}from"../../utils/dom.js";import{globalStoreAtom as y}from"../../jotai/store.js";import{useTranslate as O}from"../../hooks/index.js";function J({schemaRef:m}){const{parser:h}=b(y),[n,l]=d("idle"),[g,c]=d(void 0),i=O(),s=h.definition["x-schema-catalog-link"];if(!s)return null;const e=L?window.location.origin:globalThis.SSR_HOSTNAME||"http://127.0.0.1:4000",a=s+m,k=e+a,u=n==="copied"?i("openapi.schemaCatalogLink.copiedTooltip","Copied!"):i("openapi.schemaCatalogLink.copyButtonTooltip","Copy to clipboard"),f=n==="copied"?!0:void 0,v=()=>{S.copyCustom(k),l("copied"),clearTimeout(g);const x=setTimeout(()=>{l("idle"),c(void 0)},1e3);c(x)};return p(j,{children:[o(r,{tip:i("openapi.schemaCatalogLink.title","Shared schema"),placement:"bottom",children:o(I,{children:o(w,{})})}),o(B,{children:p(E,{tip:e+a,placement:"bottom",width:"380px",children:[o(_,{children:e}),o(W,{children:o(A,{dir:"ltr",children:a})})]})}),o(r,{tip:u,isOpen:f,placement:"bottom",children:o(C,{icon:o(T,{}),onClick:v})})]})}const j=t.div`
|
|
2
|
+
display: flex;
|
|
3
|
+
gap: var(--spacing-xs);
|
|
4
|
+
align-items: center;
|
|
5
|
+
margin-bottom: var(--schema-catalog-link-margin-bottom);
|
|
6
|
+
padding: var(--schema-catalog-link-padding);
|
|
7
|
+
border-radius: var(--schema-catalog-link-border-radius);
|
|
8
|
+
background-color: var(--schema-catalog-link-background-color);
|
|
9
|
+
`,I=t.div`
|
|
10
|
+
width: var(--schema-catalog-link-share-icon-wrapper-size);
|
|
11
|
+
height: var(--schema-catalog-link-share-icon-wrapper-size);
|
|
12
|
+
display: flex;
|
|
13
|
+
align-items: center;
|
|
14
|
+
justify-content: center;
|
|
15
|
+
background-color: var(--schema-catalog-link-share-icon-background-color);
|
|
16
|
+
color: var(--schema-catalog-link-share-icon-color);
|
|
17
|
+
border-radius: var(--schema-catalog-link-share-icon-border-radius);
|
|
18
|
+
`,_=t.span`
|
|
19
|
+
flex-shrink: 0;
|
|
20
|
+
`,W=t.span`
|
|
21
|
+
white-space: nowrap;
|
|
22
|
+
overflow: hidden;
|
|
23
|
+
text-overflow: ellipsis;
|
|
24
|
+
direction: rtl;
|
|
25
|
+
`,A=t.span`
|
|
26
|
+
/* Override direction so that characters like '/ or '_' do no change order in the pathname */
|
|
27
|
+
direction: ltr;
|
|
28
|
+
`,B=t.div`
|
|
29
|
+
color: var(--schema-catalog-link-text-color);
|
|
30
|
+
text-overflow: ellipsis;
|
|
31
|
+
overflow: hidden;
|
|
32
|
+
display: flex;
|
|
33
|
+
flex-grow: 1;
|
|
34
|
+
`,E=t(r)`
|
|
35
|
+
max-width: 100%;
|
|
36
|
+
`;export{J as SchemaCatalogLink};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as t}from"react/jsx-runtime";import{render as s}from"@testing-library/react";import*as o from"jotai";import{SchemaCatalogLink as a}from"../SchemaCatalogLink";jest.mock("jotai",()=>({...jest.requireActual("jotai"),useAtomValue:jest.fn()})),describe("SchemaCatalogLink",()=>{it("should render correctly",()=>{jest.spyOn(o,"useAtomValue").mockReturnValue({parser:{definition:{"x-schema-catalog-link":"/_bundle/test.yaml"}}});const e=s(t(a,{schemaRef:"#/components/schemas/test"}));expect(e.baseElement).toMatchSnapshot()}),it("should not render if x-schema-catalog-link is not defined",()=>{jest.spyOn(o,"useAtomValue").mockReturnValue({parser:{definition:{}}});const e=s(t(a,{schemaRef:"#/components/schemas/test"}));expect(e.baseElement).toMatchSnapshot()})});
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import{jsx as o,jsxs as S}from"react/jsx-runtime";import{memo as
|
|
1
|
+
import{jsx as o,jsxs as S}from"react/jsx-runtime";import{memo as C,useCallback as k,useMemo as A}from"react";import{LayoutVariant as j}from"@redocly/config";import{useAtom as D,useAtomValue as x}from"jotai";import{useWriteAtom as T}from"../../jotai/use-write-atom.js";import{SamplesMiddlePanel as E,SamplesPanel as N,Row as P,Section as b,CodeBlockPanel as w}from"../common/index.js";import{getMediaType as I}from"../../models/index.js";import{MediaTypeSamples as L}from"../PayloadSamples/index.js";import{Schema as V}from"../Schema/index.js";import{Markdown as W}from"../Markdown/index.js";import{layoutAtom as _}from"../../jotai/app.js";import{globalStoreAtom as $}from"../../jotai/store.js";import{operationStore as O}from"../../jotai/operation.js";import{styled as v}from"../../styled-components.js";import{SchemaCatalogLink as B}from"../SchemaCatalogLink/SchemaCatalogLink.js";const K=(t,i)=>{if(!t)return{};const a={schema:{$ref:t}};return i&&(a.examples={example:{$ref:i}}),a};function q({schemaRef:t,exampleRef:i,showReadOnly:a=!0,showWriteOnly:y=!1}){const s=x(_),{parser:c,options:p}=x($),l=T(),e=A(()=>I(c,"json",!1,K(t,i),p,{operation:{pointer:"SchemaDefinitionComponent"}}),[i,p,c,t]),[d,f]=D(O(e.operation?.pointer)),g=k(r=>{if(!e.schema)return;const n=e.schema,u=n.oneOf;if(u&&e?.examples&&Object.keys(e?.examples).includes(r)){const m=u.findIndex(M=>M.title===r);m!==-1&&n&&l(O(n.operationPointer),{activeExampleName:n.oneOf?.[m]?.title,activeOneOf:{[n.pointer]:m}})}d.activeExampleName!==r&&f({activeExampleName:r})},[e?.examples,e.schema,d.activeExampleName,f,l]),h=s===j.STACKED;return o(b,{children:S(P,{layout:s,children:[S(F,{isStacked:h,children:[t&&o(B,{schemaRef:t}),e.schema?.description&&o(z,{children:o(W,{source:e.schema?.description})}),o(V,{skipWriteOnly:!y,skipReadOnly:!a,schema:e.schema,level:1})]}),o(N,{isStacked:h,children:o(w,{className:"panel-response-samples",children:o(L,{mediaType:e,onChange:g})})})]})})}const re=C(q),z=v.div`
|
|
2
2
|
margin-bottom: var(--spacing-vertical);
|
|
3
|
-
|
|
3
|
+
`,F=v(E)`
|
|
4
|
+
padding-left: 0;
|
|
5
|
+
`;export{re as SchemaDefinition};
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import{jsx as a,jsxs as o}from"react/jsx-runtime";import{memo as h,useCallback as v}from"react";import{useNavigate as x}from"react-router-dom";import{useAtomValue as b}from"jotai";import{LayoutVariant as k}from"@redocly/config";import{breakpoints as
|
|
1
|
+
import{jsx as a,jsxs as o}from"react/jsx-runtime";import{memo as h,useCallback as v}from"react";import{useNavigate as x}from"react-router-dom";import{useAtomValue as b}from"jotai";import{LayoutVariant as k}from"@redocly/config";import{breakpoints as S}from"@redocly/theme/core/openapi";import{Button as y}from"@redocly/theme/components/Button/Button";import{PageActions as w}from"@redocly/theme/components/PageActions/PageActions";import{H2 as j}from"@redocly/theme/components/Typography/H2";import{LinkIcon as C}from"@redocly/theme/icons/LinkIcon/LinkIcon";import{joinWithSeparator as A}from"../../services/history/helpers.js";import{Row as I,SamplesMiddlePanel as T,ShareLink as $}from"../common/index.js";import{Markdown as B}from"../Markdown/index.js";import{OperationsNavigation as L}from"./OperationsNavigation.js";import{layoutAtom as W}from"../../jotai/app.js";import{useTranslate as H}from"../../hooks/index.js";import{styled as n}from"../../styled-components.js";function M({item:t,routingBasePath:m="",isExpanded:e}){const l=H(),{description:d,name:s,href:g}=t,p=x(),c=b(W),i=A(m,t.href),u=v(()=>{p(i)},[p,i]),r=!!t.items.length,f=c===k.STACKED;return o(N,{expanded:e,children:[o(I,{layout:c,children:[o(T,{fullWidth:!r,isStacked:f,children:[o(V,{children:[a($,{to:g,"aria-label":`link to ${s}`}),s,a(w,{pageSlug:i})]}),a(B,{source:d})]}),r&&a(L,{items:t.items,routingBasePath:m})]}),r&&!e&&o(P,{type:"button",variant:"text",size:"medium",onClick:u,children:["+ ",l("openapi.actions.show","Show")]})]})}const ot=h(M),N=n.div`
|
|
2
2
|
padding-top: var(--spacing-lg);
|
|
3
3
|
padding-bottom: ${({expanded:t})=>t?"var(--spacing-xxl)":""};
|
|
4
|
-
`,P=n(
|
|
4
|
+
`,P=n(y)`
|
|
5
5
|
margin: var(--spacing-md) var(--spacing-xl) var(--spacing-xxs);
|
|
6
6
|
width: calc(100% - var(--spacing-xl) * 2);
|
|
7
7
|
|
|
8
|
-
@media screen and (min-width: ${
|
|
8
|
+
@media screen and (min-width: ${S.medium}) {
|
|
9
9
|
--button-margin-md: calc(var(--spacing-xl) * 2);
|
|
10
10
|
|
|
11
11
|
margin-left: var(--button-margin-md);
|
|
12
12
|
margin-right: var(--button-margin-md);
|
|
13
13
|
width: calc(100% - var(--button-margin-md) * 2);
|
|
14
14
|
}
|
|
15
|
-
`,V=n(
|
|
15
|
+
`,V=n(j)`
|
|
16
16
|
display: flex;
|
|
17
17
|
:hover {
|
|
18
|
-
${
|
|
18
|
+
${C} {
|
|
19
19
|
opacity: 1;
|
|
20
20
|
visibility: visible;
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
`;export{
|
|
23
|
+
`;export{ot as TagItem,M as TagItemComponent};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as n,jsxs as c}from"react/jsx-runtime";import{useAtomValue as m}from"jotai";import{Link as h}from"react-router-dom";import{LinkIcon as o}from"@redocly/theme/icons/LinkIcon/LinkIcon";import{globalOptionsAtom as d}from"../../jotai/store.js";import{tryDecodeURIComponent as f}from"../../utils/index.js";import{styled as k}from"../../styled-components.js";import{joinWithSeparator as r}from"../../services/history/helpers.js";function u(i){const{routingBasePath:a,onDeepLinkClick:e}=m(d),t=i.to,l=e&&{onClick:s=>{s.preventDefault(),e(r(a||"",t))}};return t?n(h,{"aria-label":i["aria-label"]||`link to ${t}`,id:f(i.id||""),className:i.className||"",to:t?.startsWith("#")?t:r(a||"",t),...l,children:i.children}):i.children?c("span",{"aria-label":i["aria-label"]||`link to ${t}`,className:i.className,children:[" ",i.children," "]}):null}const b=k(u)`
|
|
2
2
|
position: absolute;
|
|
3
3
|
top: 50%;
|
|
4
4
|
left: 0;
|
|
@@ -6,15 +6,15 @@ import{jsx as a,jsxs as s}from"react/jsx-runtime";import{useAtomValue as c}from"
|
|
|
6
6
|
padding-right: var(--heading-anchor-offset-right);
|
|
7
7
|
z-index: 1;
|
|
8
8
|
|
|
9
|
-
${
|
|
9
|
+
${o} {
|
|
10
10
|
opacity: 0;
|
|
11
11
|
transition:
|
|
12
12
|
visibility 0.3s linear,
|
|
13
13
|
opacity 0.3s linear;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
:hover ${
|
|
16
|
+
:hover ${o}, :focus ${o} {
|
|
17
17
|
visibility: visible;
|
|
18
18
|
opacity: 1;
|
|
19
19
|
}
|
|
20
|
-
`;function
|
|
20
|
+
`;function N(i){return n(b,{...i,children:n(o,{size:"13px",color:"--heading-anchor-color"})})}export{u as Link,N as ShareLink,b as StyledShareLink};
|
package/lib/constants.d.ts
CHANGED
|
@@ -23,3 +23,7 @@ export declare const LOADING_STATE: {
|
|
|
23
23
|
LOADED: string;
|
|
24
24
|
};
|
|
25
25
|
export declare const REDOCLY_CONFIG_FILE = "redocly.yaml";
|
|
26
|
+
export declare const DISABLE_DEEP_LINK_IF_FIELDS_EXIST: string[];
|
|
27
|
+
export declare const SEARCH_LIMIT = 100;
|
|
28
|
+
export declare const HIGHLIGHTED_TEXT_MAX_LENGTH = 150;
|
|
29
|
+
export declare const SEARCH_INDEX_FIELDS: string[];
|
package/lib/constants.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var o;(function(t){t.ON_DEEP_LINK_CLICK="onDeepLinkClick",t.HOOKS="hooks"})(o||(o={}));var E;(function(t){t.OCTET_STREAM="application/octet-stream",t.MULTIPART="multipart/form-data",t.URL_ENCODED="application/x-www-form-urlencoded",t.JSON="application/json",t.XML="application/xml"})(E||(E={}));const p="data-section-id",r="data-field-id",_=0,e="^ {0,3}<!-- ReDoc-Inject:\\s+?<({component}).*?/?>\\s+?-->\\s*$",n="(?:^ {0,3}<({component})([\\s\\S]*?)>([\\s\\S]*?)</\\2>|^ {0,3}<({component})([\\s\\S]*?)(?:/>|\\n{2,}))",c="(?:"+e+"|"+n+")",a="other",D="webhooks",s={NOT_LOADED:"NOT_LOADED",LOADING:"LOADING",LOADED:"LOADED"},L="redocly.yaml",O=["title"],T=100,A=150,I=["text","title","path","httpPath","parameters[]:name","parameters[]:description","parameters[]:place","parameters[]:path"];export{c as COMPONENT_REGEXP,a as DEFAULT_TAG_SLUG,D as DEFAULT_WEBHOOKS_TAG_NAME,O as DISABLE_DEEP_LINK_IF_FIELDS_EXIST,r as FIELD_ATTR,_ as GROUP_DEPTH,A as HIGHLIGHTED_TEXT_MAX_LENGTH,e as LEGACY_REGEXP,s as LOADING_STATE,n as MDX_COMPONENT_REGEXP,E as MediaTypes,L as REDOCLY_CONFIG_FILE,I as SEARCH_INDEX_FIELDS,T as SEARCH_LIMIT,p as SECTION_ATTR,o as WindowReferenceOptions};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ExtendedOpenAPIOperation, Unstable_ExternalCodeSample, OpenAPIParser, Options } from '../services/index.js';
|
|
2
2
|
import type { OpenAPIServer, OpenAPIXCodeSample } from '../types/index.js';
|
|
3
3
|
import type { MediaContentModel, OperationModel, GroupModel } from './types.js';
|
|
4
|
+
import type { ConfigureRequestValues, ConfigureServerRequestValues } from '@redocly/theme/ext/configure';
|
|
4
5
|
import { type UserClaims } from '@redocly/theme/core/openapi';
|
|
5
6
|
export interface Sample {
|
|
6
7
|
lang: string;
|
|
@@ -16,5 +17,5 @@ export interface Callback {
|
|
|
16
17
|
id?: string;
|
|
17
18
|
}
|
|
18
19
|
export declare function isPayloadSample(sample: XPayloadSample | OpenAPIXCodeSample | Unstable_ExternalCodeSample): sample is XPayloadSample;
|
|
19
|
-
export declare function getOperation(parser: OpenAPIParser, operationDefinition: ExtendedOpenAPIOperation, parent: GroupModel | undefined, options: Options, href: string, callback?: Callback, userClaims?: UserClaims): OperationModel;
|
|
20
|
+
export declare function getOperation(parser: OpenAPIParser, operationDefinition: ExtendedOpenAPIOperation, parent: GroupModel | undefined, options: Options, href: string, callback?: Callback, userClaims?: UserClaims, dynamicRequestValues?: ConfigureRequestValues | ConfigureServerRequestValues | null): OperationModel;
|
|
20
21
|
export declare function mergeInMockServer(servers: OpenAPIServer[], mockServerOptions: Options['mockServer']): OpenAPIServer[];
|
package/lib/models/operation.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{REDOCLY_TEAMS_RBAC as
|
|
1
|
+
import{REDOCLY_TEAMS_RBAC as g}from"@redocly/config";import{removeLeadingSlash as x}from"@redocly/theme/core/openapi";import{configure as q}from"@redocly/theme/ext/configure";import{extractExtensions as R,getOperationId as P,getOperationName as B,getStatusCodeType as E,getValueFromMdParsedExtension as C,isStatusCode as k,JsonPointer as V,mergeParams as I,normalizeServers as f,sortByDeprecated as O,sortByRequired as N,updateOperationWithRequestValues as W,updateParametersWithUserValues as w}from"../utils/index.js";import{getCallback as A}from"./callback.js";import{getField as F}from"./field.js";import{getRequestBody as M}from"./request.js";import{getSecurity as n}from"./security.js";import{getResponse as j}from"./response.js";import{getHref as L}from"../services/menu/operation.js";function $(s){return s.lang==="Payload"&&"requestBodyContent"in s}function i(s,e,t,a,m,d,h,p){const c=e.isWebhook,r={operationDefinition:e,parent:t,pointer:e.pointer,description:C(e,"description"),externalDocs:e.externalDocs,deprecated:!!e.deprecated,httpVerb:e.httpVerb,operationId:e.operationId,path:e.pathName,isWebhook:c,isCallback:!!d?.isCallback,isEvent:d?.isCallback||c,name:B(e),defaultExampleName:e.defaultSampleName,[g]:e[g]||t?.[g],type:"operation",callbackId:d?.id,href:m,get callbacks(){return Object.keys(e.callbacks||[]).map(u=>A(s,u,e.callbacks?.[u],r.pointer,a,m,t,h))},get responses(){let u=!1;return Object.keys(e.responses||[]).filter(l=>l==="default"?!0:(E(l)==="success"&&(u=!0),k(l))).map(l=>j({parser:s,code:l,defaultAsError:u,infoOrRef:e.responses[l],options:a,isEvent:r.isEvent,operation:r}))},get parameters(){return T(s,e,r,a,o)}};if(d?.isCallback)r.security=n(e.security,s),r.servers=f("",e.servers||e.pathServers||[]),r.id=x(m);else{r.id=P(e,t),r.href=r.href||L(r),r.security=n(e.security||s.definition.security,s);const u=e.servers||(e.pathServers?.length?e.pathServers:null)||s.definition.servers||[];r.servers=f(s.definitionUrl,U(u,a.mockServer))}a.showExtensions&&(r.extensions=R(e,a.showExtensions)),r.requestBody=e.requestBody?M({parser:s,infoOrRef:e.requestBody,options:a,operation:r,isEvent:r.isEvent}):void 0;const y=r.requestBody?.content;r.payload={lang:"Payload",source:"",requestBodyContent:y?.hasSample?y:void 0},r.definitionSamples=e["x-codeSamples"]||[],r.badges=e["x-badges"]?.map(({name:u,color:l,position:v})=>({name:u,color:l||"var(--color-info-base)",position:v||"after"}))||[],r.hasSamples=y?.hasSample||r.definitionSamples.length>0,r.hideReplay=e["x-hideReplay"]===!0;const S={userClaims:h,info:s.definition.info||{},operation:{operationId:r.operationId,name:r.name,path:r.path,href:r.href,method:r.httpVerb},servers:r.servers},b=q(S)||{},o=p||b.requestValues||{};return W(r,o),r}function T(s,e,t,a,m){let d=I(s,e.pathParameters,e.parameters,{pathPointer:V.dirName(t.pointer),operationPointer:t.pointer}).map(({paramOrRef:h,pointer:p})=>{const c=F(s,h,p,a,{operation:t,type:"request"});return w(c,m),c});return a.sortRequiredPropsFirst&&(d=N(d)),O(d)}function U(s,e){if(!e)return s;const t={url:e.url,description:e.description};switch(e.position){case"first":return[t,...s];case"last":return[...s,t];case"replace":return[t];default:return s}}export{i as getOperation,$ as isPayloadSample,U as mergeInMockServer};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const h=["number","boolean","function","symbol"];function x(c){return Object.prototype.toString.call(c)==="[object RegExp]"}function j(c){const s=typeof c;return c!==null&&(s==="object"||s==="function")}function O(c,s,b=""){const i=[];return
|
|
1
|
+
const h=["number","boolean","function","symbol"];function x(c){return Object.prototype.toString.call(c)==="[object RegExp]"}function j(c){const s=typeof c;return c!==null&&(s==="object"||s==="function")}function O(c,s,b=""){const i=[];return(function y(e,r={},f=""){r.indent=r.indent||" ";const n={newLine:`
|
|
2
2
|
`,newLineOrSpace:`
|
|
3
3
|
`,pad:f,indent:f+r.indent},w=t=>{if(r.inlineCharacterLimit===void 0)return t;const l=t.replace(new RegExp(n.newLine,"g"),"").replace(new RegExp(n.newLineOrSpace,"g")," ").replace(new RegExp(n.pad+"|"+n.indent,"g"),"");return l.length<=r.inlineCharacterLimit?l:t.replace(new RegExp(n.newLine+"|"+n.newLineOrSpace,"g"),`
|
|
4
4
|
`).replace(new RegExp(n.pad,"g"),f).replace(new RegExp(n.indent,"g"),f+r.indent)};if(i.indexOf(e)!==-1)return'"Circular"';if(e===null)return"NULL";if(e===void 0||h.includes(typeof e)||x(e))return String(e);if(e instanceof Date)return`date('${e.toISOString()}')`;if(Array.isArray(e)){if(e.length===0)return"array()";i.push(e);const t="array("+n.newLine+e.map((l,a)=>{const d=e.length-1===a?n.newLine:","+n.newLineOrSpace;let g=y(l,r,f+r.indent);return r.transform&&(g=r.transform(e,a,g)),n.indent+g+d}).join("")+n.pad+")";return i.pop(),w(t)}if(j(e)){let t=Object.keys(e);if(r.filter&&(t=t.filter(a=>r.filter?.(e,a))),t.length===0)return Array.isArray(e)?"array()":"(object)[]";i.push(e);const l="array("+n.newLine+t.map((a,d)=>{const g=t.length-1===d?n.newLine:","+n.newLineOrSpace,L=typeof a=="symbol",m=!L&&/^[a-z$_][a-z$_0-9]*$/i.test(a),S=L||m?a:y(a,r);let o=y(e[a],r,f+r.indent);return r.transform&&(o=r.transform(e,a,o)),`${n.indent}"${String(S)}" => ${o}${g}`}).join("")+n.pad+")";return i.pop(),w(l)}return e=String(e).replace(/[\r\n]/g,t=>t===`
|
|
5
|
-
`?"\\n":"\\r"),r.singleQuotes===!1?(e=e.replace(/"/g,'\\"'),`"${e}"`):(e=e.replace(/\\?'/g,"\\'"),`"${e}"`)}(c,s,b)}export{O as objectToPhpArray};
|
|
5
|
+
`?"\\n":"\\r"),r.singleQuotes===!1?(e=e.replace(/"/g,'\\"'),`"${e}"`):(e=e.replace(/\\?'/g,"\\'"),`"${e}"`)})(c,s,b)}export{O as objectToPhpArray};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{encodeBackSlashes as o,queryString as s}from"../../utils/index.js";import{getActiveMediaType as r}from"../../models/mediaContent.js";function d(e,n){return e===n||"#"+e===n||e==="#"+n}function p(e,n){if(!e.in){if(e.deps.type==="request"&&e.deps.operation?.requestBody?.content?.mediaTypes)return e.deps.operation?.requestBody?.content?.mediaTypes.length>1?e.deps.operation?.requestBody?.content&&r(e.deps.operation.requestBody.content,n).name:void 0;if(e.deps.type==="response"&&e.deps.response?.content?.mediaTypes)return e.deps.response?.content?.mediaTypes.length>1?e.deps.response?.content&&r(e.deps.response.content,n).name:void 0}}function
|
|
1
|
+
import{encodeBackSlashes as o,queryString as s}from"../../utils/index.js";import{getActiveMediaType as r}from"../../models/mediaContent.js";function d(e,n){return e===n||"#"+e===n||e==="#"+n}function p(e,n){if(!e.in){if(e.deps.type==="request"&&e.deps.operation?.requestBody?.content?.mediaTypes)return e.deps.operation?.requestBody?.content?.mediaTypes.length>1?e.deps.operation?.requestBody?.content&&r(e.deps.operation.requestBody.content,n).name:void 0;if(e.deps.type==="response"&&e.deps.response?.content?.mediaTypes)return e.deps.response?.content?.mediaTypes.length>1?e.deps.response?.content&&r(e.deps.response.content,n).name:void 0}}function y(e,n){if(!e)return"";const t={t:e.deps.type,in:e.in||e.deps.in,c:e.deps.type==="response"?e.deps.response?.code:void 0,cb:e.deps.operation?.isCallback?e.deps.operation.callbackId:void 0,ct:p(e,n),path:e.fieldFullPath};return s.stringify(t,{encode:!1,sort:!1})}function c(e="",n="",t="/"){return e.endsWith(t)&&e!==t&&(e=e.slice(0,-t.length)),n.startsWith(t)&&(n=n.slice(t.length)),!e||!n||e===t?e+n:e+t+n}function a(e,n){return e=o(e),(`/${e}#`+c(e,n)).toLowerCase()}export{y as constructFieldDeepFragment,d as isSameHash,c as joinWithSeparator,a as makeDeepLink};
|
package/lib/types/open-api.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Sample } from '../models';
|
|
2
|
-
import type { ENTITY_RELATION_TYPES } from '@redocly/
|
|
2
|
+
import type { ENTITY_RELATION_TYPES } from '@redocly/config';
|
|
3
3
|
export interface OpenAPIDefinition {
|
|
4
4
|
openapi: string;
|
|
5
5
|
info: OpenAPIInfo;
|
|
@@ -16,6 +16,7 @@ export interface OpenAPIDefinition {
|
|
|
16
16
|
tags: Array<string>;
|
|
17
17
|
}>;
|
|
18
18
|
'x-feedback'?: any;
|
|
19
|
+
'x-schema-catalog-link'?: string;
|
|
19
20
|
}
|
|
20
21
|
export interface OpenAPIInfo extends ParsedDescriptionWithSummary {
|
|
21
22
|
title: string;
|
|
@@ -6,6 +6,7 @@ export declare function updateRequestBodyWithUserValues(operation: OperationMode
|
|
|
6
6
|
export declare function updateSecurityWithUserValues(operation: OperationModel, securityValues?: SecurityDetails, serverUrl?: string): void;
|
|
7
7
|
export declare function updateOperationWithServerUserValues(operation: OperationModel, serverRequestValues: ConfigureServerRequestValues): void;
|
|
8
8
|
export declare function updateEnvVariablesWithUserValues(operation: OperationModel, environmentValues?: Record<string, string>, serverUrl?: string): void;
|
|
9
|
+
export declare function updateServerVariablesWithUserValues(operation: OperationModel, serverVariables?: Record<string, string>, serverUrl?: string): void;
|
|
9
10
|
export declare function isDirectRequestValues(value: any): value is ConfigureRequestValues;
|
|
10
11
|
export declare function updateObjectProperties(original: any, updates: any): any;
|
|
11
12
|
export declare function createSecurityUpdates(scheme: any, securityValues: SecurityDetails): SecurityCredentials;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isObject as
|
|
1
|
+
import{isObject as V}from"@redocly/theme/core/openapi";function p(e,t){Object.keys(t).length!==0&&(y(t)?(b(e,t),h(e,t.security),d(e,t.envVariables),v(e,t.serverVariables)):j(e,t))}function O(e,t){if(!t)return;const{in:r,name:s}=e;if(y(t)){const a=t,c={header:a.headers,query:a.query,path:a.path,cookie:a.cookie};r&&c[r]?.[s]&&(e.example=c[r][s])}else Object.entries(t).forEach(([a,c])=>{const f=c;if(!f)return;const n={header:f.headers,query:f.query,path:f.path,cookie:f.cookie};r&&n[r]?.[s]&&(e.serverValues||(e.serverValues={}),e.serverValues[a]={example:n[r][s]})})}function b(e,t,r){if(!e.requestBody||!t?.body)return;const s=e.requestBody.content;if(!s?.mediaTypes)return;const a=(c,f)=>{c[f]&&Object.keys(c[f]).forEach(n=>{const u=c[f]?.[n]?.value;let l;if(V(u)?l=o(u,t.body):l=t.body,!!l)if(r){const i=c[f][n];i.serverValues||(i.serverValues={}),i.serverValues[r]={value:l,rawValue:l},c[f][n]={...i,mime:c.name}}else c[f][n]={value:l,rawValue:l,mime:c.name}})};for(const c of s.mediaTypes)a(c,"examples"),a(c,"formExamples");return e}function h(e,t,r){!t||!e.security.length||e.security.forEach(s=>{r?s.schemes.forEach(a=>{a.serverValues||(a.serverValues={});const c=k(a,t);a.serverValues[r]=c}):s.schemes.forEach(a=>{const c=k(a,t);Object.assign(a,c)})})}function j(e,t){e.servers.forEach(r=>{if(t[r.url]){const s=t[r.url];s&&(b(e,s,r.url),h(e,s.security,r.url),d(e,s.envVariables,r.url),v(e,s.serverVariables,r.url))}})}function d(e,t,r){!t||Object.keys(t).length===0||(e.envVariables||(e.envVariables={}),r?(e.envVariables.serverValues||(e.envVariables.serverValues={}),e.envVariables.serverValues[r]={...e.envVariables.serverValues[r],...t}):e.envVariables.values={...e.envVariables.values,...t})}function v(e,t,r){if(!(!t||Object.keys(t).length===0))if(r){const s=e.servers.find(a=>a.url===r);if(s){s.variables||(s.variables={});for(const[a,c]of Object.entries(t))s.variables[a]&&(s.variables[a].default=c)}}else e.servers.forEach(s=>{s.variables||(s.variables={});for(const[a,c]of Object.entries(t))s.variables[a]&&(s.variables[a].default=c)})}function y(e){return!e||typeof e!="object"?!1:"headers"in e||"body"in e||"query"in e||"path"in e||"cookie"in e||"security"in e||"envVariables"in e||"serverVariables"in e}function o(e,t){if(!e||typeof e!="object")return t;if(Array.isArray(e)&&Array.isArray(t)){if(e.length>0&&typeof e[0]=="object"&&e[0]!==null){const s=Object.keys(e[0]),a=t.filter(c=>typeof c!="object"||c===null?!1:s.some(f=>f in c)&&Object.keys(c).every(f=>s.includes(f)));return a.length>0?a:e}return t}const r=Array.isArray(e)?[...e]:{...e};for(const[s,a]of Object.entries(t))s in e&&(Array.isArray(e[s])||typeof a=="object"&&a!==null&&typeof e[s]=="object"?r[s]=o(e[s],a):r[s]=a);return r}function k(e,t){const r={"x-defaultAccessToken":t.token?.access_token,"x-defaultTokenType":t.token?.token_type||"Bearer","x-defaultClientId":t.client_id,"x-defaultClientSecret":t.client_secret,scopes:t.scopes||e.scopes};return e.type==="http"&&e.scheme==="basic"?(r["x-defaultUsername"]=t.username,r["x-defaultPassword"]=t.password,delete r["x-defaultAccessToken"],delete r["x-defaultTokenType"]):e.type==="oauth2"&&!t.token?.access_token&&(delete r["x-defaultAccessToken"],delete r["x-defaultTokenType"]),r}export{k as createSecurityUpdates,y as isDirectRequestValues,d as updateEnvVariablesWithUserValues,o as updateObjectProperties,p as updateOperationWithRequestValues,j as updateOperationWithServerUserValues,O as updateParametersWithUserValues,b as updateRequestBodyWithUserValues,h as updateSecurityWithUserValues,v as updateServerVariablesWithUserValues};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function r(e){return e?[...e.fields||[],...e.oneOf?.flatMap(i=>i.fields||[])||[]].some(({schema:i})=>!i.isPrimitive&&!i.isCircular):!1}export{r as hasNestedFields};
|
package/lib/utils/index.d.ts
CHANGED
|
@@ -20,5 +20,6 @@ export * from './queryString.js';
|
|
|
20
20
|
export * from './isMobile.js';
|
|
21
21
|
export * from './replaceVariables.js';
|
|
22
22
|
export * from './areArraysEqual.js';
|
|
23
|
+
export * from './hasNestedFields.js';
|
|
23
24
|
export * from './configure-helpers.js';
|
|
24
25
|
export * from './telemetry.js';
|
package/lib/utils/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./JsonPointer.js";export*from"./openapi.js";export*from"./helpers.js";export*from"./dom.js";export*from"./debug.js";export*from"./sort.js";export*from"./argValuesHelpers.js";export*from"./theme-helpers.js";export*from"./debounce.js";export*from"./security-details.js";export*from"./session-storage.js";export*from"./local-storage.js";export*from"./parameters.js";export*from"./string.js";export*from"./test-utils.js";export*from"./compose.js";export*from"./saveTextBeforeHeading.js";export*from"./path.js";export*from"./queryString.js";export*from"./isMobile.js";export*from"./replaceVariables.js";export*from"./areArraysEqual.js";export*from"./configure-helpers.js";export*from"./telemetry.js";
|
|
1
|
+
export*from"./JsonPointer.js";export*from"./openapi.js";export*from"./helpers.js";export*from"./dom.js";export*from"./debug.js";export*from"./sort.js";export*from"./argValuesHelpers.js";export*from"./theme-helpers.js";export*from"./debounce.js";export*from"./security-details.js";export*from"./session-storage.js";export*from"./local-storage.js";export*from"./parameters.js";export*from"./string.js";export*from"./test-utils.js";export*from"./compose.js";export*from"./saveTextBeforeHeading.js";export*from"./path.js";export*from"./queryString.js";export*from"./isMobile.js";export*from"./replaceVariables.js";export*from"./areArraysEqual.js";export*from"./hasNestedFields.js";export*from"./configure-helpers.js";export*from"./telemetry.js";
|