@redocly/openapi-docs 3.15.0-next.11 → 3.15.0-next.13
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 +1799 -1678
- package/lib/components/Discriminator/DefaultMappingOption.d.ts +5 -0
- package/lib/components/Discriminator/DefaultMappingOption.js +15 -0
- package/lib/components/Discriminator/Discriminator.js +16 -2
- package/lib/components/RedoclyOpenAPIDocs/RedoclyOpenAPIDocs.js +1 -1
- package/lib/components/common/Dropdown/Dropdown.d.ts +3 -3
- package/lib/components/common/Dropdown/Dropdown.js +9 -9
- package/lib/components/common/SchemaSelection/SchemaSelection.d.ts +2 -2
- package/lib/components/common/SchemaSelection/SchemaSelection.js +1 -1
- package/lib/icons/DefaultMappingIcon/DefaultMappingIcon.d.ts +4 -0
- package/lib/icons/DefaultMappingIcon/DefaultMappingIcon.js +8 -0
- package/lib/icons/DefaultMappingIcon/index.d.ts +1 -0
- package/lib/icons/DefaultMappingIcon/index.js +1 -0
- package/lib/models/mediaType.js +1 -1
- package/lib/models/schema.d.ts +2 -1
- package/lib/models/schema.js +2 -2
- package/lib/models/types.d.ts +1 -0
- package/lib/types/open-api.d.ts +1 -0
- package/package.json +5 -5
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import{jsx as e,jsxs as p}from"react/jsx-runtime";import{Tooltip as o}from"@redocly/theme/components/Tooltip/Tooltip";import{DefaultMappingIcon as r}from"../../icons/DefaultMappingIcon/DefaultMappingIcon.js";import{useTranslate as a}from"../../hooks/index.js";import{styled as i}from"../../styled-components.js";function g({label:t}){const n=a();return e(o,{tip:n("openapi.discriminator.defaultMappingTooltip","OpenAPI 3.2: defaultMapping used when other mappings don't match."),placement:"bottom",children:p(s,{children:[e(l,{children:e(r,{})}),e(m,{children:t})]})})}const s=i.div`
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
gap: 4px;
|
|
5
|
+
min-width: 0;
|
|
6
|
+
`,l=i.div`
|
|
7
|
+
flex-shrink: 0;
|
|
8
|
+
display: flex;
|
|
9
|
+
align-items: center;
|
|
10
|
+
`,m=i.span`
|
|
11
|
+
overflow: hidden;
|
|
12
|
+
text-overflow: ellipsis;
|
|
13
|
+
white-space: nowrap;
|
|
14
|
+
min-width: 0;
|
|
15
|
+
`;export{g as DefaultMappingOption};
|
|
@@ -1,5 +1,19 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as n,jsxs as s}from"react/jsx-runtime";import{memo as c,useMemo as d}from"react";import{strikethroughText as f}from"../../utils/index.js";import{SchemaSelection as g}from"../common/SchemaSelection/SchemaSelection.js";import{SelectionTitle as u}from"../common/index.js";import{styled as t}from"../../styled-components.js";import{DefaultMappingOption as x}from"./DefaultMappingOption.js";function D({activeOneOfIdx:a,parent:e,onChange:p,translate:i}){const m=d(()=>(e.oneOf||[]).map((o,r)=>{const l=o.schema.deprecated?`${f(o.title)} (${i("openapi.badges.deprecated","deprecated").toLowerCase()})`:o.title;return o.isDefaultMapping?{label:i("openapi.discriminator.defaultMapping","Default mapping"),value:r,element:n(x,{label:i("openapi.discriminator.defaultMapping","Default mapping")}),...e.oneOf&&e.oneOf.length>1?{divider:n(v,{})}:{}}:{label:l,value:r}}),[e.oneOf,i]);return e.oneOf===void 0?null:s(h,{children:[n(u,{children:i("openapi.discriminator","Discriminator")}),n(g,{options:m,pointer:e.operationPointer,onChange:p,schema:e,defaultOneOfIdx:a})]})}const C=c(D),h=t.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-direction: column;
|
|
4
4
|
align-items: flex-start;
|
|
5
|
-
|
|
5
|
+
`,v=t.span`
|
|
6
|
+
background-color: var(--border-color-primary);
|
|
7
|
+
display: block;
|
|
8
|
+
align-self: stretch;
|
|
9
|
+
|
|
10
|
+
[data-component-name='Dropdown/DropdownMenu'] & {
|
|
11
|
+
height: 1px;
|
|
12
|
+
margin: calc(var(--spacing-xxs) / 2) var(--spacing-xxs);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
[data-component-name='Segmented/Segmented'] & {
|
|
16
|
+
width: 1px;
|
|
17
|
+
margin: var(--spacing-xxs) calc(var(--spacing-xxs) / 2);
|
|
18
|
+
}
|
|
19
|
+
`;export{C as Discriminator};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as t,jsxs as s,Fragment as C}from"react/jsx-runtime";import{memo as O,useRef as T,useEffect as w}from"react";import{LayoutVariant as d}from"@redocly/config";import{useSetAtom as A}from"jotai";import{ThreePanelLayout as I}from"@redocly/theme/layouts/ThreePanelLayout";import{SidebarLogo as j}from"@redocly/theme/components/SidebarLogo/SidebarLogo";import{GlobalStyle as M,useMount as N}from"@redocly/theme/core/openapi";import{StoreProvider as _}from"./Providers.js";import{Overlay as D}from"../Overlay.js";import{RedocWrap as V}from"./styled.js";import{StickyResponsiveSidebar as k}from"../StickySidebar/index.js";import{SideMenu as v}from"../SideMenu/index.js";import{Content as B}from"../Content/index.js";import{useContentItems as K,useUppercase2LowercaseRedirect as F,useTelemetry as H,usePerformanceMetrics as U}from"../../hooks/index.js";import{withRouter as Y}from"../../hoc/withRouter.js";import{withStore as G}from"../../hoc/withStore.js";import{compose as W}from"../../utils/index.js";import{useLicense as q}from"../../hooks/useLicense.js";import{allOperationsAtom as z}from"../../jotai/replay.js";const J=W(Y,G,O)(({licenseKey:m,onLoaded:a,children:e,options:o,layout:i,collapsedSidebar:u,parser:c,withCommonStyles:g})=>{const R=T(null),{isValid:l,licenseInfo:S}=q(m),h=A(z),y=H();F();const{contentItems:b,flatItems:f}=K({parser:c,options:o});U({sendTelemetry:p=>{const r=Object.fromEntries(Object.entries(p).map(([E,x])=>[E.toLowerCase(),x]));y.sendPerformanceMetricsMessage({cls:r.cls,lcp:r.lcp,fcp:r.fcp,ttfb:r.ttfb})}}),w(()=>{if(!o.hideReplay&&f.length>0){const p=f.filter(r=>r.type==="operation");h(p)}},[f,o.hideReplay,h]),N(()=>{a?.(),y.sendViewedMessage({layout:i})});const{hideSidebar:P,scrollYOffset:L}=o||{},n=c.definition?.info?.["x-logo"];return s(C,{children:[g&&t(M,{}),s(V,{className:"redoc-wrap",ref:R,children:[!l&&t(D,{licenseInfo:S}),!P&&s(k,{scrollYOffset:L,className:"menu-content",collapsedSidebar:!u,children:[t(j,{imageUrl:n?.url,href:n?.href||c.definition?.info?.contact?.url,altText:n?.altText,backgroundColor:n?.backgroundColor}),t(v,{items:l?b:[]})]}),s(I,{className:"api-content",id:"api-content",layout:i===d.THREE_PANEL?d.THREE_PANEL:d.STACKED,collapsedSidebar:u,children:[t(B,{items:l?b:[],routingBasePath:o.routingBasePath}),e]})]})]})});function he({onLoaded:m,children:a,store:e,withCommonStyles:o,router:i}){return e?.definition?t(_,{...e,children:t(J,{onLoaded:m,basePath:e.options?.routingBasePath,licenseKey:e.options?.licenseKey,disableRouter:e.options?.disableRouter,withCommonStyles:o,router:i,children:a})}):null}export{he as RedoclyOpenAPIDocs};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SegmentedOption } from '@redocly/theme/core/openapi';
|
|
2
2
|
export interface DropdownProps<T> {
|
|
3
3
|
value: T;
|
|
4
|
-
onChange: ({ label, value }:
|
|
5
|
-
options:
|
|
4
|
+
onChange: ({ label, value }: SegmentedOption<T>) => void;
|
|
5
|
+
options: SegmentedOption<T>[];
|
|
6
6
|
className?: string;
|
|
7
7
|
triggerVariant?: 'ghost' | 'outlined';
|
|
8
8
|
triggerSize?: string;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{jsx as r,
|
|
1
|
+
import{jsx as r,jsxs as s,Fragment as f}from"react/jsx-runtime";import g,{useMemo as k,useState as C}from"react";import{Dropdown as D}from"@redocly/theme/components/Dropdown/Dropdown";import{CheckmarkIcon as I}from"@redocly/theme/icons/CheckmarkIcon/CheckmarkIcon";import{DropdownMenu as j}from"@redocly/theme/components/Dropdown/DropdownMenu";import{DropdownMenuItem as z}from"@redocly/theme/components/Dropdown/DropdownMenuItem";import{Button as M}from"@redocly/theme/components/Button/Button";import{SearchIcon as F}from"@redocly/theme/icons/SearchIcon/SearchIcon";import{typedMemo as N}from"@redocly/theme/core/openapi";import{styled as n}from"../../../styled-components.js";import{useTranslate as A}from"../../../hooks/index.js";function P({options:t,value:o,onChange:d,className:v,triggerVariant:x="outlined",triggerSize:b="small",withSearch:w=!1}){const[l,h]=C(""),m=A(),a=t.find(e=>e.value===o),p=k(()=>t.filter(e=>e.label?.toLowerCase().includes(l.toLowerCase())??!1),[t,l]);if(t.length===1)return r(V,{children:a?.element||a?.label});const y=e=>{h(e.target.value)},S=()=>w?s(f,{children:[r(R,{prefix:r(L,{children:r(F,{color:"var(--icon-color-additional)",onClick:e=>e.stopPropagation()})}),content:r(O,{placeholder:m("openapi.discriminator.searchPlaceholder","Search items"),onClick:e=>e.stopPropagation(),onChange:y,value:l})}),r(_,{children:p.length?p.map((e,c)=>s(g.Fragment,{children:[e.divider,r(i,{active:e.value===o,onAction:()=>d(e),suffix:e.value===o&&r(u,{}),children:e.element||e.label},e.label)]},c)):r(T,{content:m("openapi.discriminator.searchNoResults","No items found")})})]}):r(f,{children:t.map((e,c)=>s(g.Fragment,{children:[e.divider,r(i,{active:e.value===o,onAction:()=>d(e),suffix:e.value===o&&r(u,{}),children:e.element||e.label},e.label)]},c))});return r(D,{className:v,trigger:r(M,{variant:x,size:b,type:"button",children:a?.element||a?.label}),withArrow:!0,onClose:()=>h(""),children:r(j,{children:S()})})}const Y=N(P),u=n(I)`
|
|
2
2
|
width: 16px;
|
|
3
3
|
height: 16px;
|
|
4
4
|
margin-left: auto;
|
|
5
|
-
`,
|
|
5
|
+
`,i=n(z)`
|
|
6
6
|
--dropdown-menu-item-justify-content: space-between;
|
|
7
7
|
|
|
8
8
|
width: 100%;
|
|
@@ -12,23 +12,23 @@ import{jsx as r,Fragment as p,jsxs as w}from"react/jsx-runtime";import{useMemo a
|
|
|
12
12
|
padding: var(--spacing-xxs) var(--spacing-sm);
|
|
13
13
|
font-size: var(--font-size-base);
|
|
14
14
|
line-height: var(--line-height-base);
|
|
15
|
-
`,
|
|
15
|
+
`,R=n(i)`
|
|
16
16
|
gap: 0;
|
|
17
17
|
padding: var(--spacing-xxs) var(--spacing-xs);
|
|
18
18
|
&:hover {
|
|
19
19
|
background-color: transparent;
|
|
20
20
|
}
|
|
21
|
-
`,
|
|
21
|
+
`,T=n(i)`
|
|
22
22
|
height: 66px;
|
|
23
23
|
justify-content: center;
|
|
24
24
|
&:hover,
|
|
25
25
|
&:focus-visible {
|
|
26
26
|
background-color: transparent;
|
|
27
27
|
}
|
|
28
|
-
`,
|
|
28
|
+
`,_=n.div`
|
|
29
29
|
overflow-y: auto;
|
|
30
30
|
max-height: 300px;
|
|
31
|
-
`,
|
|
31
|
+
`,L=n.div`
|
|
32
32
|
display: flex;
|
|
33
33
|
align-items: center;
|
|
34
34
|
justify-content: center;
|
|
@@ -36,7 +36,7 @@ import{jsx as r,Fragment as p,jsxs as w}from"react/jsx-runtime";import{useMemo a
|
|
|
36
36
|
height: 24px;
|
|
37
37
|
cursor: pointer;
|
|
38
38
|
flex-shrink: 0;
|
|
39
|
-
`,
|
|
39
|
+
`,O=n.input`
|
|
40
40
|
width: 100%;
|
|
41
41
|
border: none;
|
|
42
42
|
outline: none;
|
|
@@ -51,7 +51,7 @@ import{jsx as r,Fragment as p,jsxs as w}from"react/jsx-runtime";import{useMemo a
|
|
|
51
51
|
&::placeholder {
|
|
52
52
|
color: var(--search-trigger-color);
|
|
53
53
|
}
|
|
54
|
-
`,
|
|
54
|
+
`,V=n.span`
|
|
55
55
|
margin-right: var(--spacing-unit);
|
|
56
56
|
cursor: default;
|
|
57
57
|
background: none;
|
|
@@ -62,4 +62,4 @@ import{jsx as r,Fragment as p,jsxs as w}from"react/jsx-runtime";import{useMemo a
|
|
|
62
62
|
line-height: var(--line-height-lg);
|
|
63
63
|
font-family: var(--font-family-base);
|
|
64
64
|
font-weight: var(--font-weight-regular);
|
|
65
|
-
`;export{
|
|
65
|
+
`;export{Y as Dropdown};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SegmentedOption } from '@redocly/theme/core/openapi';
|
|
2
2
|
import type { SchemaModel } from '../../../models/index.js';
|
|
3
3
|
interface SchemaSelectionProps {
|
|
4
|
-
options:
|
|
4
|
+
options: SegmentedOption<number>[];
|
|
5
5
|
onChange?: (idx: number) => void;
|
|
6
6
|
pointer: string;
|
|
7
7
|
schema: SchemaModel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as m}from"react/jsx-runtime";import{useCallback as h,useEffect as v,useRef as A,useState as T}from"react";import{useAtom as g}from"jotai";import{
|
|
1
|
+
import{jsx as m}from"react/jsx-runtime";import{useCallback as h,useEffect as v,useRef as A,useState as T}from"react";import{useAtom as g}from"jotai";import{isUndefined as w}from"@redocly/theme/core/openapi";import{Segmented as I}from"@redocly/theme/components/Segmented/Segmented";import{Dropdown as x}from"../Dropdown/index.js";import{operationStore as y}from"../../../jotai/operation.js";const L=5,R=7;function _({options:t,onChange:r,pointer:u,schema:n,defaultOneOfIdx:d}){const[S,c]=g(y(u)),p=S.activeOneOf[n.pointer]??d,o=t[p]?.value,[i,E]=T(!1),s=A(null);v(()=>{if(!s.current)return;const e=()=>{const O=s.current?.querySelectorAll('button[role="tab"]'),a=Array.from(O||[]).some(l=>l.offsetWidth<l.scrollWidth);a!==i&&E(a)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[i,t]);const f=h(({value:e})=>{e!==void 0&&(r?r(e):c({activeExampleName:n.oneOf?.[e]?.title,activeOneOf:{[n.pointer]:e},requestValues:{body:null}}))},[r,n.oneOf,n.pointer,c]);return w(o)?null:t.length>L||i?m(x,{options:t,value:o,withSearch:t.length>=R,onChange:f}):m(I,{ref:s,value:o,onChange:f,options:t,size:"small","data-testid":"segmented-schema"})}const k=_;export{k as SchemaSelection};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{jsx as t,jsxs as a}from"react/jsx-runtime";import{styled as C}from"../../styled-components.js";const r=o=>a("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",...o,children:[t("path",{d:"M10.5 9.75H9.375V9H10.5V3H9.375V2.25H10.5C10.6988 2.25023 10.8895 2.32932 11.0301 2.46992C11.1707 2.61052 11.2498 2.80116 11.25 3V9C11.2497 9.19883 11.1706 9.38944 11.03 9.53003C10.8894 9.67063 10.6988 9.74973 10.5 9.75Z"}),t("path",{d:"M8.625 6.75C9.03921 6.75 9.375 6.41421 9.375 6C9.375 5.58579 9.03921 5.25 8.625 5.25C8.21079 5.25 7.875 5.58579 7.875 6C7.875 6.41421 8.21079 6.75 8.625 6.75Z"}),t("path",{d:"M6 6.75C6.41421 6.75 6.75 6.41421 6.75 6C6.75 5.58579 6.41421 5.25 6 5.25C5.58579 5.25 5.25 5.58579 5.25 6C5.25 6.41421 5.58579 6.75 6 6.75Z"}),t("path",{d:"M3.375 6.75C3.78921 6.75 4.125 6.41421 4.125 6C4.125 5.58579 3.78921 5.25 3.375 5.25C2.96079 5.25 2.625 5.58579 2.625 6C2.625 6.41421 2.96079 6.75 3.375 6.75Z"}),t("path",{d:"M2.625 9.75H1.5C1.30116 9.74977 1.11052 9.67068 0.969922 9.53008C0.829319 9.38948 0.750228 9.19884 0.75 9V3C0.750199 2.80115 0.82928 2.6105 0.969889 2.46989C1.1105 2.32928 1.30115 2.2502 1.5 2.25H2.625V3H1.5V9H2.625V9.75Z"})]}),p=C(r).attrs(()=>({"data-component-name":"icons/DefaultMappingIcon"}))`
|
|
2
|
+
path {
|
|
3
|
+
fill: var(--color-warm-grey-11);
|
|
4
|
+
html.dark & {
|
|
5
|
+
fill: var(--text-color-secondary);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
`;export{p as DefaultMappingIcon,r as Icon};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DefaultMappingIcon } from './DefaultMappingIcon.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{DefaultMappingIcon as a}from"./DefaultMappingIcon.js";export{a as DefaultMappingIcon};
|
package/lib/models/mediaType.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getSchema as E}from"./schema.js";import{isFormUrlEncoded as P,isJsonLike as b,isXmlLike as
|
|
1
|
+
import{getSchema as E}from"./schema.js";import{isFormUrlEncoded as P,isJsonLike as b,isXmlLike as g,isMultipartFormData as j,JsonPointer as D,mapValues as M}from"../utils/index.js";import{getExamples as r}from"./example.js";import{safeSample as k}from"../services/code-samples/index.js";function v({parser:i,info:{encoding:e,schema:m},schema:l,mime:s,options:{isRequestType:a,onlyRequiredInSamples:u,generatedSamplesMaxDepth:p,format:d="json"}}){const f={skipReadOnly:a,skipWriteOnly:!a,skipNonRequired:a&&u,maxSampleDepth:p,quiet:!0,format:d};let n={};if(l&&l.oneOf)for(const o of l.oneOf){const t=k(o.rawSchema,f,i.definition);t!==null&&(l.discriminatorProp&&typeof t=="object"&&t&&t[l.discriminatorProp]&&!o.isDefaultMapping&&(t[l.discriminatorProp]=o.title),n[o.title]=r({parser:i,infoOrRef:{value:t},mime:s,encoding:e}))}else if(l){const o=k(m,f,i.definition);o!==null?n={default:r({parser:i,infoOrRef:{value:o},mime:s,encoding:e})}:n={default:{value:null,rawValue:"null"}}}else n={default:{value:null,rawValue:"null"}};return n}function J(i,e,m,l,s,{operation:a,type:u,response:p,absolutePointer:d=""}){let f,n;const o=l.schema&&E({parser:i,schemaOrRef:l.schema,pointer:"",absolutePointer:D.join(d,["content",e,"schema"]),options:s,deps:{operation:a,type:u,response:p}}),{onlyRequiredInSamples:t,generatedSamplesMaxDepth:c}=s,{encoding:x,examples:O,example:S}=l;return s.unstable_skipSamples||(O!==void 0?f=M(O,h=>r({parser:i,infoOrRef:h,mime:e,encoding:x})):S!==void 0?f={default:r({parser:i,infoOrRef:{value:i.deref(S).resolved},mime:e,encoding:x})}:b(e)||g(e)?f=v({parser:i,info:l,schema:o,mime:e,options:{isRequestType:m,onlyRequiredInSamples:t,generatedSamplesMaxDepth:c,format:g(e)?"xml":"json"}}):(P(e)||j(e))&&(n=v({parser:i,info:l,schema:o,mime:e,options:{isRequestType:m,onlyRequiredInSamples:t,generatedSamplesMaxDepth:c}}))),{examples:f,schema:o,name:e,isRequestType:m,formExamples:n,onlyRequiredInSamples:t,operation:a}}export{J as getMediaType};
|
package/lib/models/schema.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { OpenAPISchema, Referenced } from '../types/index.js';
|
|
2
2
|
import type { OpenAPIParser, Options } from '../services/index.js';
|
|
3
3
|
import type { Deps, SchemaModel } from './types.js';
|
|
4
|
-
export declare function getSchema({ parser, schemaOrRef, pointer, options, isChild, baseRefsStack, deps, absolutePointer, }: {
|
|
4
|
+
export declare function getSchema({ parser, schemaOrRef, pointer, options, isChild, isDefaultMapping, baseRefsStack, deps, absolutePointer, }: {
|
|
5
5
|
parser: OpenAPIParser;
|
|
6
6
|
schemaOrRef: Referenced<OpenAPISchema>;
|
|
7
7
|
pointer: string;
|
|
8
8
|
options: Options;
|
|
9
9
|
isChild?: boolean;
|
|
10
|
+
isDefaultMapping?: boolean;
|
|
10
11
|
baseRefsStack?: string[];
|
|
11
12
|
deps: Deps;
|
|
12
13
|
absolutePointer?: string;
|
package/lib/models/schema.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{REDOCLY_TEAMS_RBAC as
|
|
2
|
-
Field must be an object but got ${typeof i} at "${u}"`),{})}function
|
|
1
|
+
import{REDOCLY_TEAMS_RBAC as S}from"@redocly/config";import{isObject as I}from"@redocly/theme/core/openapi";import{pushRef as w}from"../services/OpenAPIParser.js";import{detectType as q,extractExtensions as C,getValueFromMdParsedExtension as M,humanizeConstraints as E,isNamedDefinition as h,isPrimitiveType as B,JsonPointer as A,pluralizeType as z,sortByDeprecated as L,sortByRequired as J}from"../utils/index.js";import{getField as T}from"./field.js";function F({parser:i,schemaOrRef:n,pointer:u,options:l,isChild:P=!1,isDefaultMapping:f=!1,baseRefsStack:m=[],deps:o,absolutePointer:y}){const{resolved:p,refsStack:c}=i.deref(n,m,!0),s=n.$ref||u||y||"",r=w(c,s),e=i.mergeAllOf(p,s,r,n.$ref||y),O=e.type||q(e),t={operationPointer:o.operation?.pointer||y||"",schemaOrRef:n,isChild:P,isDefaultMapping:f,typePrefix:"",pointer:s,absolutePointer:y,refsStack:r,rawSchema:p,type:O,isCircular:!!e["x-circular-ref"],isComplex:!!e["x-complex"],title:e.title||h(s)&&A.baseName(s)||"",description:M(e,"description")||"",format:e.format,enum:e.enum||[],example:e.example,deprecated:!!e.deprecated,pattern:e.pattern,externalDocs:e.externalDocs,displayFormat:e.format,isPrimitive:B(e,O),constraints:E(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,[S]:e[S],"x-enumDescriptions":M(e,"x-enumDescriptions"),get fields(){if(!t.isCircular&&!t.isComplex&&($(t,"object")||$(t,"array")&&v(e)))return K(i,e,s,l,r,o)}};if((e.nullable||e["x-nullable"])&&(Array.isArray(t.type)&&!t.type.some(d=>d===null||d==="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(d=>d===null?"null":d).join(" or "):t.type,t.isCircular)return t;if(e.if&&e.then||e.if&&e.else){const{oneOf:d,oneOfType:a}=_({schema:e,parser:i,pointer:s,options:l,deps:o,refsStack:r});return t.oneOf=d,t.oneOfType=a,t}if(!P&&R(e)!==void 0){const{oneOf:d,discriminatorProp:a}=V({schema:e,parser:i,deps:o,mergedSchema:e,options:l,pointer:s,refsStack:r});return t.oneOf=d,t.discriminatorProp=a,t}else P&&Array.isArray(e.oneOf)&&e.oneOf.find(d=>d.$ref===s)&&delete e.oneOf;if(e.oneOf!==void 0){const{oneOf:d,displayType:a}=j({schemaOneOf:e.oneOf,parser:i,deps:o,options:l,pointer:s,refsStack:r,schema:e});return t.oneOfType="One of",d&&(t.oneOf=d),t.displayType=a,e.anyOf!==void 0&&console.warn(`oneOf and anyOf are not supported on the same level. Skipping anyOf at ${s}`),t}if(e.anyOf!==void 0){const{oneOf:d,displayType:a}=j({schemaOneOf:e.anyOf,parser:i,deps:o,options:l,pointer:s,refsStack:r,schema:e});return d&&(t.oneOf=d),t.displayType=a,t.oneOfType="Any of",t}if($(t,"array")&&(e.items&&!v(e)&&(t.items=F({parser:i,schemaOrRef:Object.assign({type:"object"},e.items),pointer:s+"/items",options:l,baseRefsStack:r,deps:o,absolutePointer:A.join(e.absolutePointer||"",["items"])})),t.displayType=e.prefixItems||Array.isArray(e.items)?"items":z(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"]=M(t.items,"x-enumDescriptions")),Array.isArray(t.type))){const d=t.type.filter(a=>a!=="array");d.length&&(t.displayType+=` or ${d.join(" or ")}`)}return l.showExtensions&&(t.extensions=C(e,l.showExtensions)),t}function V({schema:i,parser:n,pointer:u,options:l,refsStack:P,deps:f,mergedSchema:m}){const o=R(i),y=o?.propertyName,p=n.findDerived([...m["x-parentRefs"]||[],u]);if(i.oneOf)for(const a of i.oneOf){if(a.$ref===void 0)continue;const x=A.baseName(a.$ref);p[a.$ref]=x}const c=o?.mapping||{};let s=o?.["x-explicitMappingOnly"]||!1;Object.keys(c).length===0&&(s=!1);const r={};for(const a in c){const x=c[a];Array.isArray(r[x])?r[x].push(a):r[x]=[a]}const e=s?{...r}:{...p,...r};let O=[];for(const a of Object.keys(e)){const x=e[a];if(Array.isArray(x))for(const g of x)O.push({$ref:a,name:g});else O.push({$ref:a,name:x})}if(o?.defaultMapping){const a=O.findIndex(g=>g.name===A.baseName(o.defaultMapping)),x="Default mapping";~a?O[a]={$ref:o.defaultMapping,name:x,isDefaultMapping:!0}:O.push({$ref:o.defaultMapping,name:x,isDefaultMapping:!0})}const t=Object.keys(c);return t.length!==0&&(O=O.sort((a,x)=>{if(a.isDefaultMapping&&!x.isDefaultMapping)return 1;if(!a.isDefaultMapping&&x.isDefaultMapping)return-1;const g=t.indexOf(a.name),b=t.indexOf(x.name);return g<0&&b<0?a.name.localeCompare(x.name):g<0?1:b<0?-1:g-b})),{oneOf:O.map(({$ref:a,name:x,isDefaultMapping:g},b)=>{const D=F({parser:n,schemaOrRef:{$ref:a},pointer:a,options:l,isChild:!0,isDefaultMapping:g,baseRefsStack:P.slice(0,-1),deps:{...f,parentFieldFullPath:f.parentFieldFullPath?f.parentFieldFullPath+"&d="+b:"&d="+b.toString()},absolutePointer:m.absolutePointer});return D.title=x,D}),discriminatorProp:y}}function j({schemaOneOf:i,parser:n,refsStack:u,pointer:l,schema:P,options:f,deps:m}){const o=i.map((p,c)=>{const{resolved:s,refsStack:r}=n.deref(p,u,!0),e=n.mergeAllOf(s,l+"/oneOf/"+c,r),O=h(p.$ref)&&!e.title?A.baseName(p.$ref):`${e.title||""}${e.const&&JSON.stringify(e.const)||""}`;return F({parser:n,schemaOrRef:{...e,title:O,allOf:[{...P,oneOf:void 0,anyOf:void 0}],discriminator:s.allOf?void 0:e.discriminator},pointer:p.$ref||l+"/oneOf/"+c,options:f,baseRefsStack:r,deps:{...m,parentFieldFullPath:m.parentFieldFullPath?m.parentFieldFullPath+"&oneOf="+c:"&oneOf="+c.toString()}})}),y=[...new Set(o.map(p=>{let c=p.typePrefix+(p.title&&!f.hideSchemaTitles?`${p.title} (${p.displayType})`:p.displayType);return c.indexOf(" or ")>-1&&(c=`(${c})`),c}))].join(" or ");return{oneOf:o,displayType:y}}function _({schema:i,parser:n,pointer:u,options:l,refsStack:P,deps:f}){const{if:m,else:o={},then:y={},...p}=i;return{oneOf:[{allOf:[p,y,m],title:m&&m["x-displayName"]||m?.title||"case 1"},{allOf:[p,o],title:o&&o["x-displayName"]||o?.title||"case 2"}].map((e,O)=>F({parser:n,schemaOrRef:{...e},pointer:u+"/oneOf/"+O,options:l,baseRefsStack:P,deps:{...f,parentFieldFullPath:f.parentFieldFullPath?f.parentFieldFullPath+"&oneOf="+O:"&oneOf="+O.toString()}})),oneOfType:"One of"}}function k(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 K(i,n,u,l,P,f){let m=n.properties||($(n,"array")?n.prefixItems||n.items:void 0)||{};const o=n.patternProperties||{},y=n.additionalProperties||n.unevaluatedProperties,p=n.prefixItems?n.items:n.additionalItems,c=n.default||{};let s=Object.keys(m).map(r=>{const e=k(m[r],r,u),O=n.required===void 0?!1:n.required.indexOf(r)>-1;return T(i,{name:n.properties?r:`[${r}]`,required:O,schema:{...e,example:n.example?.[r]||e.example,default:e.default===void 0&&c?c[r]:e.default}},u+"/properties/"+r,l,f,P,A.join(n.absolutePointer||"",["properties",r]))});return l.sortRequiredPropsFirst&&(s=J(s,n.required)),s.push(...Object.keys(o).map(r=>{const e=k(o[r],r,u);return T(i,{name:r,required:!1,schema:e,kind:"patternProperties"},`${u}/patternProperties/${r}`,l,f,P)})),(I(y)||y===!0)&&s.push(T(i,{name:(I(y)&&y["x-additionalPropertiesName"]||"property name").concat("*"),required:!1,schema:y===!0?{}:y,kind:"additionalProperties"},u+"/additionalProperties",l,f,P,A.join(n.absolutePointer||"",["additionalProperties"]))),s.push(...Y({parser:i,schema:p,fieldsCount:s.length,$ref:u,options:l,refsStack:P,deps:f})),L(s)}function Y({parser:i,schema:n=!1,fieldsCount:u,$ref:l,options:P,refsStack:f,deps:m}){return typeof n=="boolean"?n?[T(i,{name:`[${u}...]`,schema:{},kind:"additionalItems"},`${l}/additionalItems`,P,m,f)]:[]:Array.isArray(n)?[...n.map((o,y)=>T(i,{name:`[${u+y}]`,schema:o,kind:"additionalItems"},`${l}/additionalItems/${y}`,P,m,f))]:I(n)?[T(i,{name:`[${u}...]`,schema:n,kind:"additionalItems"},`${l}/additionalItems`,P,m,f)]:[]}function R(i){return i.discriminator||i["x-discriminator"]}function $(i,n){return i.type===n||Array.isArray(i.type)&&i.type.includes(n)}function v(i){return!!(Array.isArray(i.items)||Array.isArray(i.prefixItems))}export{F as getSchema};
|
package/lib/models/types.d.ts
CHANGED
package/lib/types/open-api.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/openapi-docs",
|
|
3
|
-
"version": "3.15.0-next.
|
|
3
|
+
"version": "3.15.0-next.13",
|
|
4
4
|
"description": "Redocly OpenAPI Docs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@markdoc/markdoc": "0.5.2",
|
|
24
|
-
"@redocly/openapi-core": "2.
|
|
24
|
+
"@redocly/openapi-core": "2.10.0",
|
|
25
25
|
"deepmerge": "^4.2.2",
|
|
26
26
|
"dompurify": "3.2.7",
|
|
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/config": "0.
|
|
40
|
-
"@redocly/replay": "0.18.0-next.
|
|
39
|
+
"@redocly/config": "0.37.0",
|
|
40
|
+
"@redocly/replay": "0.18.0-next.13"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@jest/globals": "29.5.0",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"typescript": "5.9.3",
|
|
76
76
|
"url": "~0.11.0",
|
|
77
77
|
"vite": "7.1.9",
|
|
78
|
-
"@redocly/theme": "0.59.0-next.
|
|
78
|
+
"@redocly/theme": "0.59.0-next.12"
|
|
79
79
|
},
|
|
80
80
|
"scripts": {
|
|
81
81
|
"start": "npm run copy-highlight-hook && vite",
|