@redocly/openapi-docs 3.12.0-next.9 → 3.12.0
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 +2139 -1951
- package/lib/components/ApiInfo/ApiInfo.js +1 -1
- package/lib/components/ApiInfo/styled.js +6 -5
- package/lib/components/Content/useAutoScroll.js +1 -1
- package/lib/components/ExpandAllButton/ExpandAllButton.js +2 -2
- package/lib/components/OperationItem/Description.d.ts +1 -4
- package/lib/components/OperationItem/Description.js +1 -1
- package/lib/components/OperationItem/OperationItem.js +5 -5
- package/lib/components/Request/RequestDetails.js +2 -2
- package/lib/components/RequestSamples/Example.js +1 -1
- package/lib/components/RequestSamples/RequestSamples.js +1 -1
- package/lib/components/ResponseSamples/ResponseSamples.js +1 -1
- package/lib/components/Samples/ExampleSwitch.js +1 -1
- package/lib/components/TagItem/TagItem.js +8 -7
- package/lib/components/common/OperationItemTitle.d.ts +1 -0
- package/lib/components/common/OperationItemTitle.js +10 -5
- package/lib/components/common/panels.js +22 -20
- package/lib/models/schema.js +2 -2
- package/lib/services/code-samples/httpsnippet/helpers/code-builder.d.ts +5 -1
- package/lib/services/code-samples/httpsnippet/helpers/code-builder.js +2 -2
- package/lib/services/code-samples/httpsnippet/helpers/code-helpers.d.ts +2 -2
- package/lib/services/code-samples/httpsnippet/helpers/code-helpers.js +2 -2
- package/lib/types/open-api.d.ts +1 -0
- package/lib/utils/loadAndBundleSpec.js +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{jsx as t,jsxs as n}from"react/jsx-runtime";import{useAtomValue as A}from"jotai";import{LayoutVariant as g}from"@redocly/config";import{AfterOpenApiTitle as h}from"@redocly/theme/components/OpenApiDocs/hooks/AfterOpenApiTitle";import{PageActions as D}from"@redocly/theme/components/PageActions/PageActions";import{SamplesMiddlePanel as k,Row as S}from"../common/index.js";import{ExternalDocumentation as M}from"../ExternalDocumentation/index.js";import{Markdown as s}from"../Markdown/index.js";import{ApiHeader as T}from"./styled.js";import{globalStoreAtom as j}from"../../jotai/store.js";import{saveTextBeforeHeading as y}from"../../utils/saveTextBeforeHeading.js";import{getValueFromMdParsedExtension as m}from"../../utils/helpers.js";import{RenderHook as H}from"../RenderHook/index.js";import{Metadata as P}from"./Metadata.js";import{useTranslate as v}from"../../hooks/index.js";function $({item:p,layout:r}){const l=v(),{options:{unstable_hooks:d,hideInfoMetadata:f,routingBasePath:c},parser:{definition:u}}=A(j),o=p.infoDefinition;if(!o)return null;const e=y(m(o,"description")||""),i=m(o,"summary")||void 0,a=u?.externalDocs||o?.externalDocs,x=r===g.STACKED;return t(S,{layout:r,children:n(k,{fullWidth:!0,className:"api-info",isStacked:x,children:[n(T,{children:[(o.title||"")+(o.version?` (${o.version})`:""),t(D,{pageSlug:c})]}),t(H,{Hook:h||d?.AfterApiTitle,props:{info:o}}),i&&t(s,{source:i,"data-role":"redoc-summary"}),e&&t(s,{source:e,"data-role":"redoc-description"}),a&&t(M,{externalDocs:a}),!f&&t(P,{metadata:o["x-metadata"],translate:l})]})})}export{$ as ApiInfo};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import{H1 as
|
|
1
|
+
import{H1 as e}from"@redocly/theme/components/Typography/H1";import{Markdown as n}from"@redocly/theme/components/Markdown/Markdown";import{styled as o}from"../../styled-components.js";const t=15,p=o(e)`
|
|
2
|
+
display: flex;
|
|
2
3
|
margin-top: 0;
|
|
3
4
|
margin-bottom: 0;
|
|
4
|
-
& + ${
|
|
5
|
+
& + ${n} {
|
|
5
6
|
margin-top: var(--h1-margin-bottom);
|
|
6
7
|
}
|
|
7
|
-
`,
|
|
8
|
+
`,l=o.span`
|
|
8
9
|
&::before {
|
|
9
10
|
content: '|';
|
|
10
11
|
display: inline-block;
|
|
@@ -16,11 +17,11 @@ import{H1 as n}from"@redocly/theme/components/Typography/H1";import{Markdown as
|
|
|
16
17
|
&:last-child::after {
|
|
17
18
|
display: none;
|
|
18
19
|
}
|
|
19
|
-
`,
|
|
20
|
+
`,d=o.div`
|
|
20
21
|
overflow: hidden;
|
|
21
22
|
`,m=o.div`
|
|
22
23
|
display: flex;
|
|
23
24
|
flex-wrap: wrap;
|
|
24
25
|
// hide separator on new lines: idea from https://stackoverflow.com/a/31732902/1749888
|
|
25
26
|
margin-left: -${t}px;
|
|
26
|
-
`;export{p as ApiHeader,
|
|
27
|
+
`;export{p as ApiHeader,l as InfoSpan,m as InfoSpanBox,d as InfoSpanBoxWrap};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useLocation as p}from"react-router-dom";import{useEffect as
|
|
1
|
+
import{useLocation as p}from"react-router-dom";import{useEffect as s}from"react";import{addLeadingSlash as u,removeLeadingSlash as l,useActiveSectionId as m,IS_BROWSER as f}from"@redocly/theme/core/openapi";import{compose as h,encodeBackSlashes as w,tryDecodeURIComponent as S}from"../../utils/index.js";let d=!0;function E(t){const e=p(),o=t||"/";s(()=>{if(e.pathname===o&&e.hash===""){window.scrollTo(0,0);return}const a=l(e.pathname.replace(o,"")),c=g(e.hash),i=c?r(a+c)||document.querySelector(`[id$="${l(c)}"]`):r(e.hash.replace("#",""))||r(a);i&&i.scrollIntoView()},[e,o]);const n=m(e,!1,!1);s(()=>{if(n&&d){d=!1;return}if(f&&!window.location.pathname.includes(n)&&!window.location.hash.includes(n)){const a=h(u,w)(n);window.history.replaceState({},"",a)}},[n])}function r(t){return document.getElementById(S(t))}function g(t){const e=["#tag","#operation","#paths"];for(const o of e)if(t.includes(o))return t.replace(o,"").toLowerCase();return""}export{r as getElementById,g as getLegacyHash,E as useAutoScroll};
|
|
@@ -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
|
|
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 j=({operationPointer:a,type:o,onPanelToggle:r})=>{const t=f(),[l,s]=d(x(a)),p=u(),i=()=>{const e=!l[o].expandedAll;p.send({type:"openapi_docs.expand_collapse_all.clicked",payload:{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:i,children:l[o].expandedAll?t("openapi.collapseAll","Collapse all"):t("openapi.expandAll","Expand all")})},g=A(c)`
|
|
2
2
|
margin-left: auto;
|
|
3
|
-
`;export{
|
|
3
|
+
`;export{j as ExpandAllButton};
|
|
@@ -2,9 +2,6 @@ import type { OpenAPIExternalDocumentation } from '../../types/index.js';
|
|
|
2
2
|
interface DescriptionProps {
|
|
3
3
|
description?: string | GenericObject;
|
|
4
4
|
externalDocs?: OpenAPIExternalDocumentation;
|
|
5
|
-
extensions: {
|
|
6
|
-
[p: string]: string | Record<string, unknown>;
|
|
7
|
-
};
|
|
8
5
|
}
|
|
9
|
-
export declare function Description({ description, externalDocs
|
|
6
|
+
export declare function Description({ description, externalDocs }: DescriptionProps): import("react/jsx-runtime").JSX.Element | null;
|
|
10
7
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as o,Fragment as t,jsxs as s}from"react/jsx-runtime";import{Markdown as e}from"../Markdown/index.js";import{ExternalDocumentation as m}from"../ExternalDocumentation/index.js";function x({description:r,externalDocs:n}){return r?s(t,{children:[o(e,{source:r}),n&&o(m,{externalDocs:n})]}):null}export{x as Description};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t,Fragment 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 j,useMemo as L}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 r,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 ue}from"../Request/RequestDetails.js";import{StyledBadge as H}from"../common/Badges.js";import{useTranslate as be}from"../../hooks/index.js";import{styled as k}from"../../styled-components.js";import{createPanelToggleEvent as fe}from"../../events/index.js";function he({item:{operationDefinition:S,parent:v,href:u}}){const s=be(),{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=L(()=>pe(y,S,v,l,u,void 0,T),[u,S,l,v,y,T]),{name:O,deprecated:_,isWebhook:q,badges:D}=a||{},o=n===$.STACKED,A=p?.type||"sentiment",R=p?.hide!==!0,b=se(l.routingBasePath,a.href),[f,E]=F(null),P=j(m=>{c!==m&&I(m)},[c]),d=j((m,w)=>{if(!w)return;const N=fe({operation:a,isExpanded:m,panelType:w});x?.panelToggle?.(N)},[x,a]),M=L(()=>R?e(Se,{children:e(Q,{type:A,settings:p.settings,path:b})}):null,[R,A,p.settings,b]);return t(ve,{layout:n,children:[e(i,{layout:n,children:t(r,{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:u,"aria-label":`link to ${O}`}),e(Y,{badges:D,children:O}),_&&e(H,{deprecated:!0,children:s("openapi.badges.deprecated","Deprecated")}),q&&e(H,{children:s("openapi.badges.webhook","Webhook")})]}),e(J,{pageSlug:b})]})]})}),t(i,{layout:n,children:[e(r,{isStacked:o,children:e(ue,{operation:a,translate:s,onPanelToggle:d})}),e(h,{isStacked:o,"data-testid":"samples-block",className:"panel-container-request-samples",children:e(ae,{operation:a,onPanelToggle:d})})]}),t(i,{layout:n,children:[e(r,{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(h,{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(r,{isStacked:o,children:[a.callbacks?.length?t(V,{children:[t(ge,{children:[e(ke,{to:ne(a.id,"callbacks")}),s("openapi.callbacks","Callbacks")]}),e(Z,{callbacks:a.callbacks,onExpand:E,selectedCallback:f})]}):null,e(B,{Hook:z||C?.AfterOperation,props:{operation:a}})]}),f?e(h,{isStacked:o,"data-testid":"samples-block",children:e(ee,{callback:f,translate:s})}):null]}),e(i,{layout:n,children:e(r,{isStacked:o,fullWidth:!0,children:M})})]})}const Ge=K(he),h=k(U)`
|
|
2
2
|
margin-left: auto;
|
|
3
3
|
--code-block-padding: var(--spacing-xs) 0 var(--spacing-xs) 20px;
|
|
4
|
-
`,
|
|
4
|
+
`,Se=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 N}from"react/jsx-runtime";import{memo as V
|
|
|
12
12
|
width: 100%;
|
|
13
13
|
max-width: var(--feedback-width);
|
|
14
14
|
}
|
|
15
|
-
`,
|
|
15
|
+
`,ve=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{Ge as OperationItem,h as OperationSamplesPanel};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{jsx as e,jsxs as s,Fragment as
|
|
1
|
+
import{jsx as e,jsxs as s,Fragment as v}from"react/jsx-runtime";import{memo as P,useMemo as j}from"react";import{useAtomValue as k}from"jotai";import{Row as y}from"../common/index.js";import{Title as A}from"../common/OperationItemTitle.js";import{LinkToField as N}from"../common/LinkToField.js";import{makeDeepLink as C}from"../../services/index.js";import{Description as D}from"../OperationItem/Description.js";import{Security as E}from"../Security/index.js";import{ExpandAllButton as M}from"../ExpandAllButton/index.js";import{RequestParameters as T}from"../RequestParameters/index.js";import{activeMimeNameAtom as b}from"../../jotai/app.js";import{getActiveMediaType as w}from"../../models/mediaContent.js";import{styled as F}from"../../styled-components.js";import{Extensions as _}from"../common/Extensions.js";function I({operation:{id:r,description:m,externalDocs:n,parameters:i,requestBody:o,pointer:l,security:u,extensions:a,callbackId:f},title:d,translate:h,onPanelToggle:x}){const p=k(b),g=j(()=>{const c=i.some(({schema:t})=>!t.isPrimitive&&!t.isCircular);if(!o?.content||c)return c;const{schema:q}=w(o.content,p)||{};return q?.fields?.some(({schema:t})=>!t.isPrimitive&&!t.isCircular)},[p,i,o?.content]),R=Object.keys(a||{}).length>0;return s(v,{children:[e(y,{children:s(L,{children:[s(A,{children:[r&&e(N,{to:C(r,"request")}),d||h?.("openapi.request","Request"),g&&e(M,{operationPointer:l,type:"request",onPanelToggle:x})]}),e(D,{description:m||n?m:void 0,externalDocs:n}),R&&e(_,{extensions:a}),e(E,{securities:u})]})}),e(T,{parameters:i,body:o,operationId:r,callbackId:f})]})}const L=F.div`
|
|
2
2
|
width: 100%;
|
|
3
|
-
`,
|
|
3
|
+
`,ee=P(I);export{ee as RequestDetails};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as c,Fragment as f,jsxs as h}from"react/jsx-runtime";import{memo as u}from"react";import{useAtom as E}from"jotai";import{ExampleSwitch as g,useExampleKey as
|
|
1
|
+
import{jsx as c,Fragment as f,jsxs as h}from"react/jsx-runtime";import{memo as u}from"react";import{useAtom as E}from"jotai";import{ExampleSwitch as g,useExampleKey as d}from"../Samples/index.js";import{useActivateExample as O,useTelemetry as j}from"../../hooks/index.js";import{operationStore as y}from"../../jotai/operation.js";function _({mediaType:o,mediaContent:p,renderSample:n}){const r=j(),m=o.operation.pointer,[l,x]=E(y(m)),a=o.examples||{},e=Object.keys(a),i=O(p),{exampleKey:s}=d(o.operation,a);return!e.length||e.length===1?n():h(f,{children:[c(g,{examples:a,exampleKey:s,onChange:t=>{r.send({type:"openapi_docs.examples_switcher.clicked",payload:{example:t,numberOfExamples:e.length}}),x({...l,activeExampleName:t,activeOneOf:{[m]:e.indexOf(t)},requestValues:{body:null}}),i(t)}}),n(s)]})}const N=u(_);export{N as Example};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{jsx as o,jsxs as D}from"react/jsx-runtime";import{memo as
|
|
1
|
+
import{jsx as o,jsxs as D}from"react/jsx-runtime";import{memo as T,useCallback as k,useMemo as A}from"react";import{useAtomValue as y,useAtom as M}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 L}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 v}from"../../styled-components.js";function Z({operation:a,disableFooter:P,onPanelToggle:S,...p}){const c=X(),[{activeLanguage:q,languages:m},R]=M(K),{samples:n}=F(a),{parser:d,options:{events:s,corsProxyUrl:g,hideReplay:_}}=y($),i=!P&&!a.isWebhook&&!_&&!a.hideReplay,t=!!m?.length,u=Q(n,q),E=e=>{R(e),c.send({type:"openapi_docs.select_language.clicked",payload:{language:e}});const r=m?.find(l=>l.key===e);if(s?.codeSamplesLanguageSwitch&&r){const l=V({operation:a,sample:{lang:r.lang,label:r.title}});s.codeSamplesLanguageSwitch(l)}},h=y(J),{activeExampleName:x}=y(Y(a.pointer)),f=k(({lang:e,title:r})=>()=>{const l=O({operation:a,label:r,lang:e,type:"request",activeMimeName:h,activeExampleName:x});c.send({type:"openapi_docs.copy_code_snippet.clicked",payload:{snippetType:"request",language:e}}),s?.codeSamplesCopy?.(l)},[a,c,s,h,x]),b=k(e=>{S?.(e,"request-samples")},[S]),C=()=>D(I,{isExpandable:!1,withReplay:!t&&i,children:[o(ee,{operation:a}),t&&o(G,{activeTab:u,samples:n,onChange:E}),!t&&i&&o(L,{operation:a,corsProxyUrl:g,fullOpenApi:d.definition})]}),j=A(()=>{if(i&&t)return o(ae,{children:o(L,{operation:a,corsProxyUrl:g,fullOpenApi:d.definition})})},[i,t,a,g,d.definition]),N=A(()=>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 m&&!n.length?o(w,{className:"panel-request-samples",header:C,isExpandable:!1,expanded:!1}):n.length?o(w,{className:"panel-request-samples",header:C,footer:j,isExpandable:!1,children:N}):null}const xe=T(Z),I=v(U)`
|
|
2
2
|
flex-wrap: nowrap;
|
|
3
3
|
${({withReplay:a})=>a&&"padding: var(--spacing-xs) var(--spacing-sm);"}
|
|
4
4
|
`,ee=v(z)`
|
|
@@ -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 _,useTranslate as A}from"../../hooks/index.js";import{activeMimeNameAtom as E}from"../../jotai/app.js";import{operationStore as P}from"../../jotai/operation.js";function R({operation:o,activeResponseTab:d,onTabChange:y,onPanelToggle:a}){const m=_(),{events:p}=n(T),f=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(P(o.pointer)),C=i(()=>{m.send({type:"openapi_docs.copy_code_snippet.clicked",payload:{
|
|
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 _,useTranslate as A}from"../../hooks/index.js";import{activeMimeNameAtom as E}from"../../jotai/app.js";import{operationStore as P}from"../../jotai/operation.js";function R({operation:o,activeResponseTab:d,onTabChange:y,onPanelToggle:a}){const m=_(),{events:p}=n(T),f=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(P(o.pointer)),C=i(()=>{m.send({type:"openapi_docs.copy_code_snippet.clicked",payload:{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=>y(e.key)})}),isExpandable:!1,children:o.responses.map(e=>e.code===r.key?t("div",{children:e?.content?.hasSample?t(h,{content:e.content,onCopyClick:C,onPanelToggle:S}):t(v,{source:f("openapi.noResponseContent","No content")})},e.code):null)}):null}const J=b(R);export{J as ResponseSamples};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as n}from"react/jsx-runtime";import{useState as f,useEffect as h}from"react";import{MimeLabel as x,Container as v,Select as b}from"../common/index.js";import{SelectOrLabel as y}from"../SelectOrLabel/index.js";import{normalizeText as S}from"../../utils/index.js";import{useTelemetry as
|
|
1
|
+
import{jsx as n}from"react/jsx-runtime";import{useState as f,useEffect as h}from"react";import{MimeLabel as x,Container as v,Select as b}from"../common/index.js";import{SelectOrLabel as y}from"../SelectOrLabel/index.js";import{normalizeText as S}from"../../utils/index.js";import{useTelemetry as g}from"../../hooks/index.js";const I=({exampleKey:a,examples:s,onChange:m,className:c})=>{const i=g(),t=Object.keys(s),o=a?t.indexOf(a):0,[p,l]=f(o>-1?o:0);h(()=>l(o>-1?o:0),[a,o]);const r=t.map((e,d)=>({value:S(s[e].summary)||e,idx:d})),u=({idx:e})=>{i.send({type:"openapi_docs.examples_switcher.clicked",payload:{example:t[e],numberOfExamples:t.length}}),l(e),m(t[e])};return r.length<2?null:n(v,{"data-testid":"example-switch",className:c,children:n(y,{Select:b,Label:x,variant:"dark",fullWidth:!0,options:r,value:r[p]?.value,onChange:u})})};export{I as ExampleSwitch};
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import{jsx 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 y}from"@redocly/theme/core/openapi";import{Button as S}from"@redocly/theme/components/Button/Button";import{PageActions as w}from"@redocly/theme/components/PageActions/PageActions";import{H2 as C}from"@redocly/theme/components/Typography/H2";import{LinkIcon as j}from"@redocly/theme/icons/LinkIcon/LinkIcon";import{Row as A,SamplesMiddlePanel as I,ShareLink as T}from"../common/index.js";import{Markdown as $}from"../Markdown/index.js";import{OperationsNavigation as B}from"./OperationsNavigation.js";import{layoutAtom as L}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 p=H(),{description:d,name:s,href:g}=t,c=x(),l=b(L),i=m+t.href,u=v(()=>{c(i)},[c,i]),r=!!t.items.length,f=l===k.STACKED;return o(N,{expanded:e,children:[o(A,{layout:l,children:[o(I,{fullWidth:!r,isStacked:f,children:[o(V,{children:[a(T,{to:g,"aria-label":`link to ${s}`}),s,a(w,{pageSlug:i})]}),a($,{source:d})]}),r&&a(B,{items:t.items,routingBasePath:m})]}),r&&!e&&o(P,{type:"button",variant:"text",size:"medium",onClick:u,children:["+ ",p("openapi.actions.show","Show")]})]})}const Z=h(M),N=n.div`
|
|
2
2
|
padding-top: var(--spacing-lg);
|
|
3
|
-
padding-bottom: ${({expanded:
|
|
4
|
-
`,
|
|
3
|
+
padding-bottom: ${({expanded:t})=>t?"var(--spacing-xxl)":""};
|
|
4
|
+
`,P=n(S)`
|
|
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: ${y.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
|
-
`,
|
|
15
|
+
`,V=n(C)`
|
|
16
|
+
display: flex;
|
|
16
17
|
:hover {
|
|
17
|
-
${
|
|
18
|
+
${j} {
|
|
18
19
|
opacity: 1;
|
|
19
20
|
visibility: visible;
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
|
-
`;export{
|
|
23
|
+
`;export{Z as TagItem,M as TagItemComponent};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{LinkIcon as
|
|
1
|
+
import{LinkIcon as t}from"@redocly/theme/icons/LinkIcon/LinkIcon";import{H2 as e}from"@redocly/theme/components/Typography/H2";import{styled as i}from"../../styled-components.js";const n=i.h4`
|
|
2
2
|
font-size: var(--h4-font-size);
|
|
3
3
|
font-weight: var(--h4-font-weight);
|
|
4
4
|
line-height: var(--h4-line-height);
|
|
@@ -11,22 +11,27 @@ import{LinkIcon as i}from"@redocly/theme/icons/LinkIcon/LinkIcon";import{H2 as e
|
|
|
11
11
|
position: relative;
|
|
12
12
|
|
|
13
13
|
:hover {
|
|
14
|
-
${
|
|
14
|
+
${t} {
|
|
15
15
|
opacity: 1;
|
|
16
16
|
visibility: visible;
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
`,l=
|
|
19
|
+
`,l=i(e)`
|
|
20
20
|
position: relative;
|
|
21
21
|
display: flex;
|
|
22
22
|
align-items: center;
|
|
23
23
|
gap: var(--spacing-xs);
|
|
24
24
|
flex-wrap: wrap;
|
|
25
|
+
margin: 0;
|
|
25
26
|
|
|
26
27
|
:hover {
|
|
27
|
-
${
|
|
28
|
+
${t} {
|
|
28
29
|
opacity: 1;
|
|
29
30
|
visibility: visible;
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
|
-
|
|
33
|
+
`,s=i.div`
|
|
34
|
+
display: flex;
|
|
35
|
+
align-items: flex-start;
|
|
36
|
+
margin: var(--h2-margin-top) 0 var(--h2-margin-bottom);
|
|
37
|
+
`;export{l as Heading,s as HeadingWrapper,n as Title};
|
|
@@ -1,43 +1,45 @@
|
|
|
1
|
-
import{css as
|
|
2
|
-
${({compact:a,isStacked:
|
|
1
|
+
import{css as i}from"styled-components";import{LayoutVariant as p}from"@redocly/config";import{H2 as l}from"@redocly/theme/components/Typography/H2";import{Markdown as d}from"@redocly/theme/components/Markdown/Markdown";import{breakpoints as t}from"@redocly/theme/core/openapi";import{SECTION_ATTR as c}from"../../constants.js";import{styled as r}from"../../styled-components.js";const f=r.div`
|
|
2
|
+
${({compact:a,isStacked:o,fullWidth:e})=>{const n=a?0:"var(--spacing-vertical)";return i`
|
|
3
3
|
display: flex;
|
|
4
4
|
flex-direction: column;
|
|
5
5
|
width: 100%;
|
|
6
|
-
padding: ${
|
|
6
|
+
padding: ${n} var(--panel-gap-horizontal);
|
|
7
7
|
|
|
8
8
|
&:empty {
|
|
9
9
|
display: none;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
@media screen and (min-width: ${t.large}) {
|
|
13
|
-
width: ${e||
|
|
14
|
-
padding-left: ${
|
|
15
|
-
padding-right: ${
|
|
13
|
+
width: ${e||o?"100%":"calc(100% - var(--panel-samples-width))"};
|
|
14
|
+
padding-left: ${o?"var(--panel-gap-horizontal)":"calc(var(--panel-gap-horizontal) * 2)"};
|
|
15
|
+
padding-right: ${o?"var(--panel-gap-vertical)":"var(--panel-gap-horizontal)"};
|
|
16
16
|
padding-top: 0;
|
|
17
|
-
padding-bottom: ${
|
|
17
|
+
padding-bottom: ${o?"var(--spacing-vertical)":0};
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
@media print {
|
|
21
21
|
width: 100%;
|
|
22
|
-
padding-top: ${
|
|
23
|
-
padding-bottom: ${
|
|
22
|
+
padding-top: ${n};
|
|
23
|
+
padding-bottom: ${n};
|
|
24
24
|
}
|
|
25
25
|
`}};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
|
|
27
|
+
${({compact:a})=>a&&i`
|
|
28
|
+
& & {
|
|
29
|
+
padding-left: 0;
|
|
30
|
+
padding-right: 0;
|
|
31
|
+
}
|
|
32
|
+
`}
|
|
30
33
|
|
|
31
34
|
&:last-child > ${d} :last-child,
|
|
32
35
|
${d} article :last-child {
|
|
33
36
|
margin-bottom: 0;
|
|
34
37
|
}
|
|
35
|
-
`,w=
|
|
36
|
-
z-index: 0;
|
|
38
|
+
`,w=r.div.attrs(a=>({[c]:a.sectionId,id:a.id}))`
|
|
37
39
|
padding: 0;
|
|
38
40
|
width: 100%;
|
|
39
41
|
|
|
40
|
-
${({expanded:a})=>a&&
|
|
42
|
+
${({expanded:a})=>a&&i`
|
|
41
43
|
background-color: var(--layer-color);
|
|
42
44
|
border-bottom: 1px solid var(--border-color-secondary);
|
|
43
45
|
--code-block-bg-color: var(--bg-color);
|
|
@@ -51,7 +53,7 @@ import{css as o}from"styled-components";import{LayoutVariant as p}from"@redocly/
|
|
|
51
53
|
@media screen and (min-width: ${t.medium}) {
|
|
52
54
|
padding-top: var(--spacing-xs);
|
|
53
55
|
|
|
54
|
-
${({expanded:a})=>!a&&
|
|
56
|
+
${({expanded:a})=>!a&&i`
|
|
55
57
|
padding-bottom: var(--spacing-xs);
|
|
56
58
|
`}
|
|
57
59
|
}
|
|
@@ -60,7 +62,7 @@ import{css as o}from"styled-components";import{LayoutVariant as p}from"@redocly/
|
|
|
60
62
|
padding: 0;
|
|
61
63
|
}
|
|
62
64
|
|
|
63
|
-
${({underlined:a})=>a&&
|
|
65
|
+
${({underlined:a})=>a&&i`
|
|
64
66
|
position: relative;
|
|
65
67
|
|
|
66
68
|
&:not(:last-of-type):after {
|
|
@@ -75,7 +77,7 @@ import{css as o}from"styled-components";import{LayoutVariant as p}from"@redocly/
|
|
|
75
77
|
${l} {
|
|
76
78
|
position: relative;
|
|
77
79
|
}
|
|
78
|
-
`,x=
|
|
80
|
+
`,x=r.div`
|
|
79
81
|
color: var(--panel-samples-text-color);
|
|
80
82
|
width: 100%;
|
|
81
83
|
height: fit-content;
|
|
@@ -105,7 +107,7 @@ import{css as o}from"styled-components";import{LayoutVariant as p}from"@redocly/
|
|
|
105
107
|
padding-top: var(--spacing-vertical);
|
|
106
108
|
padding-bottom: var(--spacing-vertical);
|
|
107
109
|
}
|
|
108
|
-
`,y=
|
|
110
|
+
`,y=r.div`
|
|
109
111
|
display: flex;
|
|
110
112
|
flex-direction: column;
|
|
111
113
|
justify-content: space-between;
|
package/lib/models/schema.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{REDOCLY_TEAMS_RBAC as h}from"@redocly/config";import{isObject as I}from"@redocly/theme/core/openapi";import{pushRef as M}from"../services/OpenAPIParser.js";import{detectType as w,extractExtensions as q,getValueFromMdParsedExtension as S,humanizeConstraints as C,isNamedDefinition as
|
|
2
|
-
Field must be an object but got ${typeof i} at "${u}"`),{})}function _(i,n,u,a,y,f){let o=n.properties||($(n,"array")?n.prefixItems||n.items:void 0)||{};const p=n.patternProperties||{},c=n.additionalProperties||n.unevaluatedProperties,m=n.prefixItems?n.items:n.additionalItems,r=n.default||{};let l=Object.keys(o).map(e=>{const d=R(o[e],e,u),t=n.required===void 0?!1:n.required.indexOf(e)>-1;return
|
|
1
|
+
import{REDOCLY_TEAMS_RBAC as h}from"@redocly/config";import{isObject as I}from"@redocly/theme/core/openapi";import{pushRef as M}from"../services/OpenAPIParser.js";import{detectType as w,extractExtensions as q,getValueFromMdParsedExtension as S,humanizeConstraints as C,isNamedDefinition as j,isPrimitiveType as E,JsonPointer as b,pluralizeType as B,sortByDeprecated as z,sortByRequired as L}from"../utils/index.js";import{getField as T}from"./field.js";function F({parser:i,schemaOrRef:n,pointer:u,options:a,isChild:y=!1,baseRefsStack:f=[],deps:o,absolutePointer:p}){const{resolved:c,refsStack:m}=i.deref(n,f,!0),r=n.$ref||u||p||"",l=M(m,r),e=i.mergeAllOf(c,r,l,n.$ref||p),d=e.type||w(e),t={operationPointer:o.operation?.pointer||p||"",schemaOrRef:n,isChild:y,typePrefix:"",pointer:r,absolutePointer:p,refsStack:l,rawSchema:c,type:d,isCircular:!!e["x-circular-ref"],isComplex:!!e["x-complex"],title:e.title||j(r)&&b.baseName(r)||"",description:S(e,"description")||"",format:e.format,enum:e.enum||[],example:e.example,deprecated:!!e.deprecated,pattern:e.pattern,externalDocs:e.externalDocs,displayFormat:e.format,isPrimitive:E(e,d),constraints:C(e),default:e.default,readOnly:!!e.readOnly,writeOnly:!!e.writeOnly,const:e.const||"",contentEncoding:e.contentEncoding,contentMediaType:e.contentMediaType,minItems:e.minItems,maxItems:e.maxItems,nullable:e.nullable||e["x-nullable"],schema:e,displayType:"",items:void 0,extensions:void 0,oneOfType:"",discriminatorProp:void 0,oneOf:void 0,[h]:e[h],"x-enumDescriptions":S(e,"x-enumDescriptions"),get fields(){if(!t.isCircular&&!t.isComplex&&($(t,"object")||$(t,"array")&&D(e)))return _(i,e,r,a,l,o)}};if((e.nullable||e["x-nullable"])&&(Array.isArray(t.type)&&!t.type.some(s=>s===null||s==="null")?t.type=[...t.type,"null"]:!Array.isArray(t.type)&&(t.type!==null||t.type!=="null")&&(t.type=[t.type,"null"])),t.displayType=Array.isArray(t.type)?t.type.map(s=>s===null?"null":s).join(" or "):t.type,t.isCircular)return t;if(e.if&&e.then||e.if&&e.else){const{oneOf:s,oneOfType:P}=V({schema:e,parser:i,pointer:r,options:a,deps:o,refsStack:l});return t.oneOf=s,t.oneOfType=P,t}if(!y&&v(e)!==void 0){const{oneOf:s,discriminatorProp:P}=J({schema:e,parser:i,deps:o,mergedSchema:e,options:a,pointer:r,refsStack:l});return t.oneOf=s,t.discriminatorProp=P,t}else y&&Array.isArray(e.oneOf)&&e.oneOf.find(s=>s.$ref===r)&&delete e.oneOf;if(e.oneOf!==void 0){const{oneOf:s,displayType:P}=k({schemaOneOf:e.oneOf,parser:i,deps:o,options:a,pointer:r,refsStack:l,schema:e});return t.oneOfType="One of",s&&(t.oneOf=s),t.displayType=P,e.anyOf!==void 0&&console.warn(`oneOf and anyOf are not supported on the same level. Skipping anyOf at ${r}`),t}if(e.anyOf!==void 0){const{oneOf:s,displayType:P}=k({schemaOneOf:e.anyOf,parser:i,deps:o,options:a,pointer:r,refsStack:l,schema:e});return s&&(t.oneOf=s),t.displayType=P,t.oneOfType="Any of",t}if($(t,"array")&&(e.items&&!D(e)&&(t.items=F({parser:i,schemaOrRef:Object.assign({type:"object"},e.items),pointer:r+"/items",options:a,baseRefsStack:l,deps:o,absolutePointer:b.join(e.absolutePointer||"",["items"])})),t.displayType=e.prefixItems||Array.isArray(e.items)?"items":B(t.items?.displayType||t.displayType),t.displayFormat=t.items?.format||"",t.typePrefix=t.items?.typePrefix||"Array of ",t.title=t.title||t.items?.title||"",t.isPrimitive=t.items?.isPrimitive!==void 0?t.items?.isPrimitive:t.isPrimitive,t.example===void 0&&t.items?.example!==void 0&&(t.example=[t.items.example]),t.items?.isPrimitive&&(t.enum=t.items.enum,t["x-enumDescriptions"]=S(t.items,"x-enumDescriptions")),Array.isArray(t.type))){const s=t.type.filter(P=>P!=="array");s.length&&(t.displayType+=` or ${s.join(" or ")}`)}return a.showExtensions&&(t.extensions=q(e,a.showExtensions)),t}function J({schema:i,parser:n,pointer:u,options:a,refsStack:y,deps:f,mergedSchema:o}){const p=v(i),c=p?.propertyName,m=n.findDerived([...o["x-parentRefs"]||[],u]);if(i.oneOf)for(const O of i.oneOf){if(O.$ref===void 0)continue;const x=b.baseName(O.$ref);m[O.$ref]=x}const r=p?.mapping||{};let l=p?.["x-explicitMappingOnly"]||!1;Object.keys(r).length===0&&(l=!1);const e={};for(const O in r){const x=r[O];Array.isArray(e[x])?e[x].push(O):e[x]=[O]}const d=l?{...e}:{...m,...e};let t=[];for(const O of Object.keys(d)){const x=d[O];if(Array.isArray(x))for(const A of x)t.push({$ref:O,name:A});else t.push({$ref:O,name:x})}const s=Object.keys(r);return s.length!==0&&(t=t.sort((O,x)=>{const A=s.indexOf(O.name),g=s.indexOf(x.name);return A<0&&g<0?O.name.localeCompare(x.name):A<0?1:g<0?-1:A-g})),{oneOf:t.map(({$ref:O,name:x},A)=>{const g=F({parser:n,schemaOrRef:{$ref:O},pointer:O,options:a,isChild:!0,baseRefsStack:y.slice(0,-1),deps:{...f,parentFieldFullPath:f.parentFieldFullPath?f.parentFieldFullPath+"&d="+A:"&d="+A.toString()},absolutePointer:o.absolutePointer});return g.title=x,g}),discriminatorProp:c}}function k({schemaOneOf:i,parser:n,refsStack:u,pointer:a,schema:y,options:f,deps:o}){const p=i.map((m,r)=>{const{resolved:l,refsStack:e}=n.deref(m,u,!0),d=n.mergeAllOf(l,a+"/oneOf/"+r,e),t=j(m.$ref)&&!d.title?b.baseName(m.$ref):`${d.title||""}${d.const&&JSON.stringify(d.const)||""}`;return F({parser:n,schemaOrRef:{...d,title:t,allOf:[{...y,oneOf:void 0,anyOf:void 0}],discriminator:l.allOf?void 0:d.discriminator},pointer:m.$ref||a+"/oneOf/"+r,options:f,baseRefsStack:e,deps:{...o,parentFieldFullPath:o.parentFieldFullPath?o.parentFieldFullPath+"&oneOf="+r:"&oneOf="+r.toString()}})}),c=[...new Set(p.map(m=>{let r=m.typePrefix+(m.title&&!f.hideSchemaTitles?`${m.title} (${m.displayType})`:m.displayType);return r.indexOf(" or ")>-1&&(r=`(${r})`),r}))].join(" or ");return{oneOf:p,displayType:c}}function V({schema:i,parser:n,pointer:u,options:a,refsStack:y,deps:f}){const{if:o,else:p={},then:c={},...m}=i;return{oneOf:[{allOf:[m,c,o],title:o&&o["x-displayName"]||o?.title||"case 1"},{allOf:[m,p],title:p&&p["x-displayName"]||p?.title||"case 2"}].map((d,t)=>F({parser:n,schemaOrRef:{...d},pointer:u+"/oneOf/"+t,options:a,baseRefsStack:y,deps:{...f,parentFieldFullPath:f.parentFieldFullPath?f.parentFieldFullPath+"&oneOf="+t:"&oneOf="+t.toString()}})),oneOfType:"One of"}}function R(i,n,u){return i||(console.warn(`Field "${n}" is invalid, skipping.
|
|
2
|
+
Field must be an object but got ${typeof i} at "${u}"`),{})}function _(i,n,u,a,y,f){let o=n.properties||($(n,"array")?n.prefixItems||n.items:void 0)||{};const p=n.patternProperties||{},c=n.additionalProperties||n.unevaluatedProperties,m=n.prefixItems?n.items:n.additionalItems,r=n.default||{};let l=Object.keys(o).map(e=>{const d=R(o[e],e,u),t=n.required===void 0?!1:n.required.indexOf(e)>-1;return T(i,{name:n.properties?e:`[${e}]`,required:t,schema:{...d,example:n.example?.[e]||d.example,default:d.default===void 0&&r?r[e]:d.default}},u+"/properties/"+e,a,f,y,b.join(n.absolutePointer||"",["properties",e]))});return a.sortRequiredPropsFirst&&(l=L(l,n.required)),l.push(...Object.keys(p).map(e=>{const d=R(p[e],e,u);return T(i,{name:e,required:!1,schema:d,kind:"patternProperties"},`${u}/patternProperties/${e}`,a,f,y)})),(I(c)||c===!0)&&l.push(T(i,{name:(I(c)&&c["x-additionalPropertiesName"]||"property name").concat("*"),required:!1,schema:c===!0?{}:c,kind:"additionalProperties"},u+"/additionalProperties",a,f,y,b.join(n.absolutePointer||"",["additionalProperties"]))),l.push(...Y({parser:i,schema:m,fieldsCount:l.length,$ref:u,options:a,refsStack:y,deps:f})),z(l)}function Y({parser:i,schema:n=!1,fieldsCount:u,$ref:a,options:y,refsStack:f,deps:o}){return typeof n=="boolean"?n?[T(i,{name:`[${u}...]`,schema:{},kind:"additionalItems"},`${a}/additionalItems`,y,o,f)]:[]:Array.isArray(n)?[...n.map((p,c)=>T(i,{name:`[${u+c}]`,schema:p,kind:"additionalItems"},`${a}/additionalItems/${c}`,y,o,f))]:I(n)?[T(i,{name:`[${u}...]`,schema:n,kind:"additionalItems"},`${a}/additionalItems`,y,o,f)]:[]}function v(i){return i.discriminator||i["x-discriminator"]}function $(i,n){return i.type===n||Array.isArray(i.type)&&i.type.includes(n)}function D(i){return!!(Array.isArray(i.items)||Array.isArray(i.prefixItems))}export{F as getSchema};
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { OpenAPIServerVariable } from '../../../../types/index.js';
|
|
2
2
|
import { VariableType } from './constants.js';
|
|
3
|
+
interface VariableDeclarationOptions {
|
|
4
|
+
hasVariableInterpolation: boolean;
|
|
5
|
+
}
|
|
3
6
|
/**
|
|
4
7
|
* Helper object to format and aggragate lines of code.
|
|
5
8
|
* Lines are aggregated in a `code` array, and need to be joined to obtain a proper code snippet.
|
|
@@ -17,7 +20,7 @@ export declare class CodeBuilder {
|
|
|
17
20
|
langOptions: {
|
|
18
21
|
stringLiteral: (t: string) => string;
|
|
19
22
|
variableWrapperFn: (variableName: string, variableValue?: OpenAPIServerVariable | string) => string;
|
|
20
|
-
variableDeclaration: (v: string) => string;
|
|
23
|
+
variableDeclaration: (v: string, options?: VariableDeclarationOptions) => string;
|
|
21
24
|
joinSymbol: string;
|
|
22
25
|
urlFieldName: string;
|
|
23
26
|
rawName: boolean;
|
|
@@ -81,3 +84,4 @@ export declare class CodeBuilder {
|
|
|
81
84
|
*/
|
|
82
85
|
var(name: string, type?: VariableType): string;
|
|
83
86
|
}
|
|
87
|
+
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import*as
|
|
1
|
+
import*as p from"util";import{Lang as i,NamingVariableConventions as l,VariableType as c}from"./constants.js";import o from"./string-utility.js";const S={[i.NODEJS]:l.CAMEL_CASE,[i.JAVASCRIPT]:l.CAMEL_CASE,[i.PYTHON]:l.UNDER_SCORES,[i.JAVA8]:l.CAMEL_CASE,[i.JAVA]:l.CAMEL_CASE,[i.CSHARP]:l.PASCAL_CASE,[i.CSHARPNEWTONSOFT]:l.PASCAL_CASE,[i.CURL]:l.CAMEL_CASE,[i.GO]:l.CAMEL_CASE,[i.PHP]:l.CAMEL_CASE,[i.RUBY]:l.UNDER_SCORES,[i.R]:l.UNDER_SCORES},u={default:{joinSymbol:"",variableWrapperFn:a=>a,stringLiteral:a=>a,variableDeclaration:a=>a,urlFieldName:"url"},[i.CSHARP]:{joinSymbol:" + ",stringLiteral:a=>`"${a}"`,variableDeclaration:a=>`var ${a} = %s;`,urlFieldName:"fullUrl"},[i.CSHARPNEWTONSOFT]:{joinSymbol:" + ",stringLiteral:a=>`"${a}"`,variableDeclaration:a=>`var ${a} = %s;`,urlFieldName:"fullUrl"},[i.GO]:{joinSymbol:" + ",stringLiteral:a=>`"${a}"`,variableDeclaration:a=>`${a} := %s;`},[i.JAVA]:{joinSymbol:" + ",stringLiteral:a=>`"${a}"`,variableDeclaration:a=>`var ${a} = %s;`,urlFieldName:"pathname"},[i.JAVA8]:{joinSymbol:" + ",stringLiteral:a=>`"${a}"`,variableDeclaration:a=>`String ${a} = %s;`,urlFieldName:"fullUrl"},[i.JAVASCRIPT]:{variableWrapperFn:a=>"${"+a+"}",variableDeclaration:(a,e)=>`const ${a} = ${e?.hasVariableInterpolation?"`%s`":"'%s'"};`},[i.NODEJS]:{variableWrapperFn:a=>"${"+a+"}",variableDeclaration:(a,e)=>`const ${a} = ${e?.hasVariableInterpolation?"`%s`":"'%s'"};`},[i.PHP]:{joinSymbol:" . ",stringLiteral:a=>`"${a}"`,variableDeclaration:a=>`const ${a} = %s;`},[i.PYTHON]:{stringLiteral:a=>`"${a}"`,joinSymbol:" + ",variableDeclaration:a=>`${a} = %s`},[i.RUBY]:{joinSymbol:" + ",stringLiteral:a=>`'${a}'`,variableDeclaration:a=>`${a} = %s`},[i.CURL]:{variableWrapperFn:(a,e)=>e||`{${a}}`,urlFieldName:"fullUrl",rawName:!0},[i.R]:{joinSymbol:" %&% ",variableDeclaration:a=>`${a} = %s`,urlFieldName:"fullUrl",stringLiteral:a=>`"${a}"`,variableWrapperFn:a=>`${a}`}},b=["response","request","requests","data","url","payload","main","accessToken","resp","Program","client","postData","App","httpClient","params","pathname","host","body","fetch","query"];class A{code;indentation;variablesPrefix;lineJoin;capitalize;lang;langOptions;constructor({indentation:e,lineJoin:t=`
|
|
2
2
|
`,variablesPrefix:r="",capitalize:n=!1,lang:s=i.CURL}){this.code=[],this.indentation=e,this.variablesPrefix=r,this.lineJoin=t||`
|
|
3
|
-
`,this.capitalize=n,this.lang=s,this.langOptions={...u.default,...u[s]}}buildLine(e,t){let r="",n=2;if(typeof e=="string")n=1,t=e,e=0;else if(e===null)return null;for(;e;)r+=this.indentation,e--;const s=Array.prototype.slice.call(arguments,n,arguments.length);return s.unshift(r+t),
|
|
3
|
+
`,this.capitalize=n,this.lang=s,this.langOptions={...u.default,...u[s]}}buildLine(e,t){let r="",n=2;if(typeof e=="string")n=1,t=e,e=0;else if(e===null)return null;for(;e;)r+=this.indentation,e--;const s=Array.prototype.slice.call(arguments,n,arguments.length);return s.unshift(r+t),p.format.apply(this,s)}unshift(...e){return this.code.unshift(this.buildLine.apply(this,e)),this}push(...e){return this.code.push(this.buildLine.apply(this,e)),this}blank(){return this.code.push(null),this}join(){return this.code.join(this.lineJoin)}clean(){this.code.splice(1)}var(e,t=c.CUSTOM){if(t===c.PATH){let r=this.variablesPrefix+e;switch(b.includes(r)&&(r=`${r}_path`),S[this.lang]){case l.UNDER_SCORES:r=o.toSnakeCase(r);break;case l.PASCAL_CASE:r=o.toPascalCase(r);break;case l.CAMEL_CASE:default:r=o.toCamelCase(r);break}return r}return this.variablesPrefix?this.variablesPrefix+(this.capitalize?o.toPascalCase(e):e):e}}export{A as CodeBuilder};
|
|
@@ -24,5 +24,5 @@ export type CodeOperand = {
|
|
|
24
24
|
* parseUrlIntoOperands("/url/:test/", {test: 1})
|
|
25
25
|
**/
|
|
26
26
|
export declare function parseUrlIntoOperands(url: string, params: Record<string, unknown>): CodeOperand[];
|
|
27
|
-
export declare function buildUrlExpression(source: SnippetRequest, code: CodeBuilder): string;
|
|
28
|
-
export declare function printUrlVariablesDeclarations(
|
|
27
|
+
export declare function buildUrlExpression(source: SnippetRequest, code: CodeBuilder, url?: string): string;
|
|
28
|
+
export declare function printUrlVariablesDeclarations(source: SnippetRequest, code: CodeBuilder, indentationLevel?: number): void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{VariableType as
|
|
2
|
-
${e}`);return
|
|
1
|
+
import{VariableType as f}from"./constants.js";function x({body:r,authorizationHeader:a}){return function(n,s,e){return r&&s==="body"&&typeof n.body=="string"?n.body:a&&s==="Authorization"&&typeof n.Authorization=="string"?n.Authorization:e}}function d(r,{level:a=0,indent:n=" ",firstLine:s=!0}={}){const e=n.repeat(a),i=r.replace(/(\r\n|\n|\r)/gm,`
|
|
2
|
+
${e}`);return s?e.concat(i):i}function c(r,a){const s=Object.keys(a).map(t=>({name:t,idx:r.indexOf(`{${t}}`)})).filter(({idx:t})=>t>-1).sort((t,o)=>t.idx-o.idx),e=[];let i=0;for(const{name:t,idx:o}of s)o>i&&e.push({type:"string",value:r.substring(i,o)}),e.push({type:"variable",name:t}),i=o+t.length+2;return i<r.length&&e.push({type:"string",value:r.substring(i)}),e}function h(r,a,n){const{joinSymbol:s,variableWrapperFn:e,stringLiteral:i,urlFieldName:t,rawName:o}=a.langOptions,{pathParameters:b={},serverVariables:u={}}=r,p={...b,...u};return c(n??r[t]??"",p).map(l=>{if(l.type==="variable"){const m=p[l.name],v=o?l.name:a.var(l.name,f.PATH);return e(v,m)}else return i(l.value)}).join(s)}function y(r,a,n){const s={...r.pathParameters,...r.serverVariables};Object.entries(s).forEach(([e,i])=>{if(e==="server")return;const t=i||`YOUR_${e}_PARAMETER`,o=a.var(e,f.PATH),u=c(t,s).some(l=>l.type==="variable"),p=h(r,a,t);n!==void 0?a.push(n,a.langOptions.variableDeclaration(o,{hasVariableInterpolation:u}),p):a.push(a.langOptions.variableDeclaration(o,{hasVariableInterpolation:u}),p)})}export{d as addIndentation,h as buildUrlExpression,x as getPreserveTransformer,c as parseUrlIntoOperands,y as printUrlVariablesDeclarations};
|
package/lib/types/open-api.d.ts
CHANGED
|
@@ -105,6 +105,7 @@ export interface OpenAPIOperation extends ParsedDescriptionWithSummary {
|
|
|
105
105
|
'x-codeSamples'?: OpenAPIXCodeSample[];
|
|
106
106
|
'x-badges'?: OpenAPIXBadges[];
|
|
107
107
|
'x-hideReplay'?: boolean;
|
|
108
|
+
'x-owner-key'?: string;
|
|
108
109
|
}
|
|
109
110
|
export interface OpenAPIParameter extends ParsedDescription {
|
|
110
111
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{bundle as s,Config as
|
|
1
|
+
import{bundle as s,Config as r}from"@redocly/openapi-core";import{IS_BROWSER as i}from"@redocly/theme/core/openapi";import{convertSwagger2OpenAPI as f}from"./convertSwagger2OpenAPI.js";async function l(o){const t=new r({}),e={config:t,base:i?window.location.origin:typeof globalThis.process<"u"?globalThis.process.cwd():""};i&&(t.resolve.http.customFetch=globalThis.fetch),typeof o=="object"&&o!==null?e.doc=a(o):e.ref=o;const{bundle:{parsed:n}}=await s(e);return n.swagger!==void 0?f(n):n}function a(o){return{source:{absoluteRef:""},parsed:o}}export{l as loadAndBundleDefinition};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/openapi-docs",
|
|
3
|
-
"version": "3.12.0
|
|
3
|
+
"version": "3.12.0",
|
|
4
4
|
"description": "Redocly OpenAPI Docs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@markdoc/markdoc": "0.5.2",
|
|
24
|
-
"@redocly/openapi-core": "2.0.
|
|
24
|
+
"@redocly/openapi-core": "2.0.2",
|
|
25
25
|
"deepmerge": "^4.2.2",
|
|
26
26
|
"dompurify": "3.2.6",
|
|
27
27
|
"fast-deep-equal": "^3.1.3",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"url-template": "^2.0.8",
|
|
37
37
|
"util": "~0.12.5",
|
|
38
38
|
"web-vitals": "3.3.1",
|
|
39
|
-
"@redocly/
|
|
40
|
-
"@redocly/
|
|
39
|
+
"@redocly/replay": "0.15.0",
|
|
40
|
+
"@redocly/config": "0.28.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@jest/globals": "29.5.0",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"typescript": "5.6.2",
|
|
75
75
|
"url": "~0.11.0",
|
|
76
76
|
"vite": "^6.3.5",
|
|
77
|
-
"@redocly/theme": "0.56.0
|
|
77
|
+
"@redocly/theme": "0.56.0"
|
|
78
78
|
},
|
|
79
79
|
"scripts": {
|
|
80
80
|
"start": "npm run copy-highlight-hook && vite",
|