@redocly/openapi-docs 3.19.0-next.4 → 3.19.0-next.6
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 +1875 -1754
- package/lib/components/Discriminator/Discriminator.d.ts +0 -1
- package/lib/components/Discriminator/Discriminator.js +2 -2
- package/lib/components/McpTool/McpPrompt.js +3 -1
- package/lib/components/McpTool/McpResource.js +3 -1
- package/lib/components/McpTool/McpTool.js +6 -4
- package/lib/components/Replay/utils.js +1 -1
- package/lib/components/Schema/ArraySchema.js +1 -1
- package/lib/components/Schema/ObjectSchema.js +1 -1
- package/lib/components/Schema/Schema.js +3 -3
- package/lib/components/Schema/types.d.ts +2 -3
- package/lib/components/SchemaDefinition/SchemaDefinition.js +7 -5
- package/lib/components/TagItem/TagItem.js +26 -19
- package/lib/components/common/styled.d.ts +1 -0
- package/lib/components/common/styled.js +7 -20
- package/lib/models/field.js +1 -1
- package/lib/models/types.d.ts +1 -0
- package/lib/services/OpenAPIParser.js +1 -1
- package/lib/services/menu/tags.js +2 -4
- package/package.json +7 -7
|
@@ -3,7 +3,6 @@ import type { SchemaModel } from '../../models/index.js';
|
|
|
3
3
|
interface DiscriminatorDropdownProps {
|
|
4
4
|
activeOneOfIdx: number;
|
|
5
5
|
parent: SchemaModel;
|
|
6
|
-
onChange?: (idx: number) => void;
|
|
7
6
|
translate: TFunction;
|
|
8
7
|
}
|
|
9
8
|
export declare const Discriminator: import("react").NamedExoticComponent<DiscriminatorDropdownProps>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{jsx as n,jsxs as
|
|
1
|
+
import{jsx as n,jsxs as l}from"react/jsx-runtime";import{memo as s,useMemo as c}from"react";import{strikethroughText as d}from"../../utils/index.js";import{SchemaSelection as f}from"../common/SchemaSelection/SchemaSelection.js";import{SelectionTitle as g}from"../common/index.js";import{styled as t}from"../../styled-components.js";import{DefaultMappingOption as u}from"./DefaultMappingOption.js";function x({activeOneOfIdx:a,parent:e,translate:i}){const p=c(()=>(e.oneOf||[]).map((o,r)=>{const m=o.schema.deprecated?`${d(o.title)} (${i("openapi.badges.deprecated","deprecated").toLowerCase()})`:o.title;return o.isDefaultMapping?{label:i("openapi.discriminator.defaultMapping","Default mapping"),value:r,element:n(u,{label:i("openapi.discriminator.defaultMapping","Default mapping")}),...e.oneOf&&e.oneOf.length>1?{divider:n(v,{})}:{}}:{label:m,value:r}}),[e.oneOf,i]);return e.oneOf===void 0?null:l(D,{children:[n(g,{children:i("openapi.discriminator","Discriminator")}),n(f,{options:p,pointer:e.operationPointer,schema:e,defaultOneOfIdx:a})]})}const k=s(x),D=t.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-direction: column;
|
|
4
4
|
align-items: flex-start;
|
|
@@ -16,4 +16,4 @@ import{jsx as n,jsxs as s}from"react/jsx-runtime";import{memo as c,useMemo as d}
|
|
|
16
16
|
width: 1px;
|
|
17
17
|
margin: var(--spacing-xxs) calc(var(--spacing-xxs) / 2);
|
|
18
18
|
}
|
|
19
|
-
`;export{
|
|
19
|
+
`;export{k as Discriminator};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import{jsxs as
|
|
1
|
+
import{jsxs as r,jsx as o}from"react/jsx-runtime";import{memo as j,useCallback as v,useMemo as l}from"react";import{useAtomValue as s}from"jotai";import{LayoutVariant as h}from"@redocly/config";import{getMediaContent as A,getSecurity as E}from"../../models/index.js";import{globalStoreAtom as f}from"../../jotai/store.js";import{Section as P,Row as b,SamplesMiddlePanel as R,SamplesPanel as w,CodeBlockPanel as D}from"../common/index.js";import{Schema as F}from"../Schema/index.js";import{getSchema as L}from"../../models/schema.js";import{layoutAtom as S}from"../../jotai/app.js";import{MediaTypeSamples as N}from"../PayloadSamples/MediaTypeSamples.js";import{useTranslate as O}from"../../hooks/index.js";import{Title as I}from"../common/OperationItemTitle.js";import{LinkToField as K}from"../common/LinkToField.js";import{makeDeepLink as V}from"../../services/index.js";import{Security as _}from"../Security/Security.js";import{Markdown as q}from"../Markdown/index.js";import{styled as T}from"../../styled-components.js";function B({name:i,id:m}){const{parser:p}=s(f),t=O(),a=s(S),u=a===h.STACKED,e=l(()=>(p.definition["x-mcp"]?.tools||[]).find(c=>c.name===i),[p,i]),n=l(()=>e?E(e.security,p):null,[p,e]);return e?r(P,{className:"mcp-tool",children:[o(x,{layout:a,children:o(M,{isStacked:u,children:r("div",{children:[r("p",{children:[t("openapi.mcp.toolName","Tool name"),": ",o("code",{children:e.name})]}),e.description&&o(q,{source:e.description})]})})}),o(y,{id:m,type:"input",schema:e.inputSchema,title:t("openapi.mcp.inputSchema","Input schema"),exampleTitle:t("openapi.mcp.inputExample","Input example"),children:n&&o(_,{securities:n})}),e.outputSchema&&o(y,{id:m,type:"output",schema:e.outputSchema,title:t("openapi.mcp.outputSchema","Output schema"),exampleTitle:t("openapi.mcp.outputExample","Output example")})]}):r("div",{children:["Tool not found: ",i]})}function y({schema:i,title:m,exampleTitle:p,id:t,type:a,children:u}){const{parser:e,options:n}=s(f),d=s(S),c=d===h.STACKED,k=l(()=>A({parser:e,info:{"application/json":{schema:i}},isRequestType:!1,options:n,data:{operation:{pointer:"McpTool"}}}),[n,e,i]),g=l(()=>i&&L({parser:e,schemaOrRef:i,pointer:"#",options:n,deps:{operation:{pointer:t},parentFieldFullPath:a+"-schema"}}),[n,e,i,t,a]),C=v(()=>{},[]);return r(x,{layout:d,children:[o(M,{isStacked:c,children:r("div",{children:[r(I,{children:[t&&o(K,{to:V(t,a)}),m]}),u,o(F,{schema:g})]})}),o(w,{isStacked:c,children:o(D,{className:"panel-response-samples",header:p,children:o(N,{mediaType:k.mediaTypes[0],onChange:C})})})]})}const x=T(b)`
|
|
2
2
|
margin: calc(var(--spacing-unit) * 2) 0;
|
|
3
3
|
|
|
4
4
|
& + & {
|
|
5
5
|
margin-top: calc(var(--spacing-base) * 2);
|
|
6
6
|
}
|
|
7
|
-
`,
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
`,M=T(R)`
|
|
8
|
+
&& {
|
|
9
|
+
padding-left: 0;
|
|
10
|
+
}
|
|
11
|
+
`,ae=j(B);export{ae as McpTool};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isPrimitive as h}from"@redocly/theme/core/openapi";import{getOperation as v}from"../../models/index.js";import{normalizeOptions as O,OpenAPIParser as b}from"../../services/index.js";import{JsonPointer as E}from"../../utils/index.js";function
|
|
1
|
+
import{isPrimitive as h}from"@redocly/theme/core/openapi";import{getOperation as v}from"../../models/index.js";import{normalizeOptions as O,OpenAPIParser as b}from"../../services/index.js";import{JsonPointer as E}from"../../utils/index.js";function w(t,r,n,a,e,i,o){if(!n)return;const m=new b(n),u=m.definition.paths?.[t];let l=u?.[r];!l&&u?.additionalOperations&&(l=u.additionalOperations[r]);const s=v(m,{...l,pathName:t,httpVerb:r,pathParameters:u.parameters||[],pathServers:u.servers||[]},void 0,O({}),"",{isCallback:!1},a,o);if(!s)return;const x=i?.activeMimeName||s.requestBody?.content?.mediaTypes[0]?.name||"application/json";return{id:s.id,name:s.name,method:s.httpVerb,operationId:s.operationId,parameters:V(s.parameters,e?.requestValues),body:S(s.requestBody,n,e?.requestValues?.body?{activeExampleName:e?.activeExampleName,[x]:e?.requestValues?.body}:e?.activeExampleName?{activeExampleName:e?.activeExampleName}:void 0),path:s.path,href:s.href,servers:s.servers,security:q(s.security),responses:Object.fromEntries(s.responses.map(c=>[c.code,{code:c.code,description:c.description,mediaTypes:c.content?.mediaTypes.reduce((f,d)=>(f[d.name]={name:d.name,schema:p(d.schema?.rawSchema,n)},f),{})}]))}}function T(t,r){return function(n,a,e){const i=w(n,a,e,t,void 0,void 0,r);if(i)return{...i,operationId:i.operationId||E.compile(["paths",i.path,i.method])}}}function V(t,r){const n=new Set,a=t.map(e=>(n.add(e.in+":"+e.name),{name:e.name,in:e.in,required:e.required,description:e.description,example:r?.[String(e.in)]?.[e.name]||e.example,schema:e.schema,...e.allowReserved&&{allowReserved:e.allowReserved}}));for(const[e,i]of Object.entries(r||{}))for(const[o,m]of Object.entries(i||{}))n.has(e+":"+o)||a.push({name:o,in:e,required:!1,description:"",example:String(m),schema:void 0});return a}function y({type:t,format:r,enum:n}){return t==="string"&&(r==="binary"||r==="base64")?"file":t==="object"?"multiline":n.length>0?"select":"text"}function g(t,r){const n=t[0]?.example||t[0]?.examples;if(n)return n;if(t.schema?.example)return t.schema.example;const a=r?.default?.value||r?.default?.rawValue;return a?.[t.name]?h(a?.[t.name])?String(a?.[t.name]):JSON.stringify(a?.[t.name]):""}function N(t){if(t?.fields)return t.fields;if(t?.oneOf){for(const r of t.oneOf)if(r?.fields)return r.fields}}function S(t,r,n){if(!t||!t.content?.mediaTypes){if(!n)return;const{activeExampleName:a,...e}=n;return{activeExampleName:a,mediaTypes:Object.fromEntries(Object.entries(e).map(([i,o])=>[i,{name:i,examples:{default:{value:o}},schema:{},parameters:[]}]))}}return{required:t.required,activeExampleName:n?.activeExampleName,mediaTypes:t.content.mediaTypes.reduce((a,e)=>{const i=e.schema,o=n?.[e.name]?{default:{value:n?.[e.name],rawValue:n?.[e.name],mime:e.name}}:e.examples||e.formExamples,m=N(i);return a[e.name]={name:e.name,examples:o,schema:p(e.schema?.rawSchema,r),parameters:m?.map(u=>({inputType:y(u.schema),name:u.name,example:g(u,o)}))},a},{})}}function p(t,r){if(!(!t||!r))return{...t,components:r?.components||{}}}function q(t){if(t)return t.map(({schemes:r})=>r.map(n=>{const a={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(a).forEach(e=>a[e]===void 0&&delete a[e]),a}))}export{w as convertOperationToReplayValue,T as convertOperationToReplayValueForRedoc,q as convertRequestSecurity};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as n,
|
|
1
|
+
import{jsx as n,jsxs as p,Fragment as L}from"react/jsx-runtime";import{memo as T,useCallback as k}from"react";import{useAtomValue as F}from"jotai";import{TypeName as j}from"../common/index.js";import{Schema as B}from"./Schema.js";import{ObjectSchema as S}from"./ObjectSchema.js";import{humanizeConstraints as D}from"../../utils/index.js";import{SubSchema as R}from"./SubSchema.js";import{globalOptionsAtom as W}from"../../jotai/store.js";import{getExpandByDefault as _}from"./helpers.js";import{ArrayLabel as q,LabelValue as c,ArrayClosingLabel as E,Line as h}from"../common/styled.js";function N({schema:r,schema:{minItems:u,maxItems:O,items:o},fieldParentsName:l,...e}){const{schemasExpansionLevel:g}=F(W),d=Array.isArray(e.parentType)?e.parentType:[e.parentType],i=d.includes("array")&&d.length===1,t=i?(e.level||0)+1:e.level,A=u===void 0&&O===void 0?"":`(${D(r)})`;let s=l&&[...l.slice(0,-1),l[l.length-1]+"[]"];const y=k(m=>e.skipReadOnly||e.skipWriteOnly?m?.filter(f=>!(e.skipReadOnly&&f.schema.readOnly||e.skipWriteOnly&&f.schema.writeOnly)):m,[e.skipReadOnly,e.skipWriteOnly]);if(r?.fields)return n(S,{...e,shouldCloseArray:i,level:t,schema:r,fieldParentsName:s,onOneOfChange:e.onOneOfChange});if(r.displayType&&!o&&!A.length)return n("div",{children:n(j,{children:r.displayType})});const v=y(o?.fields),x=y(o?.oneOf?.[0]?.fields),b=v?.length||x?.length,a=e.level===1,C=_({level:e.level,required:e.required,schemasExpansionLevel:g});return n(R,{...e,propertyLength:b,isNestedArray:i,level:t,isArray:!0,expandable:!a,expandByDefault:C,operationPointer:r.operationPointer,children:p(L,{children:[a&&p(q,{children:[n(c,{children:"Array ["}),n(h,{})]}),n(B,{...e,parentType:a?void 0:r.type,level:t,schema:o,shouldCloseArray:i,hideBottomBorder:a,fieldParentsName:s,expandable:!1,onOneOfChange:e.onOneOfChange}),a&&p(E,{className:"array-closing-label",children:[n(h,{}),n(c,{children:"]"})]})]})})}const Q=T(N);export{Q as ArraySchema};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as r,Fragment as P,jsxs as m}from"react/jsx-runtime";import{memo as C}from"react";import{useAtomValue as F}from"jotai";import{PropertiesTableCaption as N}from"../common/index.js";import{Discriminator as v}from"../Discriminator/index.js";import{globalOptionsAtom as A}from"../../jotai/store.js";import{PropertyDetails as B}from"../PropertyDetails/index.js";import{SubSchema as _}from"./SubSchema.js";import{getExpandByDefault as w}from"./helpers.js";import{useTranslate as E}from"../../hooks/index.js";import{ArrayClosingLabel as I,LabelValue as T,Line as V}from"../common/styled.js";function k({schema:i,showTitle:s,discriminator:t,level:a,skipWriteOnly:n,skipReadOnly:o,fieldParentsName:c,expandable:f,deepLink:d,required:h,disableDeepLinks:u,shouldCloseArray:x,oneOfLevel:b,slug:g,onOneOfChange:O}){const{fields:l=[],title:L}=i,y=E(),{schemasExpansionLevel:D}=F(A),p=o||n?l.filter(e=>!(o&&e.schema.readOnly||n&&e.schema.writeOnly)):l,S=w({required:h,level:a,schemasExpansionLevel:D});return m(_,{expandable:f,expandByDefault:S,level:a,propertyLength:p.length,deepLink:d,operationPointer:i.operationPointer,children:[m(P,{children:[s&&r(N,{children:L}),p.map((e,j)=>r(B,{isFirst:j===0,field:e,fieldParentsName:Number(a)>1?c:[],renderDiscriminatorSwitch:t?.fieldName===e.name&&t?.parentSchema?()=>r(v,{parent:t.parentSchema,activeOneOfIdx:t.activeOneOfIdx,translate:y}):void 0,skipReadOnly:o,skipWriteOnly:n,showTitle:s,level:a,disableDeepLinks:u,oneOfLevel:b,slug:g,onOneOfChange:O},e.name))]}),x&&m(I,{className:"array-closing-label",children:[r(V,{}),r(T,{children:"]"})]})]})}const Z=C(k);export{Z as ObjectSchema};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{jsx as r}from"react/jsx-runtime";import{memo as
|
|
1
|
+
import{jsx as r}from"react/jsx-runtime";import{memo as y}from"react";import{useAtomValue as S}from"jotai";import{useLocation as g}from"react-router-dom";import{ArraySchema as I}from"./ArraySchema.js";import{ObjectSchema as p}from"./ObjectSchema.js";import{OneOfSchema as b}from"./OneOfSchema.js";import{RecursiveSchema as s}from"./RecursiveSchema.js";import{operationStore as j}from"../../jotai/operation.js";import{FieldDetails as A}from"../PropertyDetails/index.js";import{pathIncludesLink as C}from"../../utils/index.js";import{styled as L}from"../../styled-components.js";function P({schema:e,onOneOfChange:n,...i}){const{activeOneOf:d}=S(j(e?.operationPointer||"")),u=g();if(!e)return null;const{type:t,oneOf:o,discriminatorProp:f,isCircular:h}=e;if(h)return r(s,{schema:e});if(f!==void 0){if(!o||!o.length)return console.warn(`Looks like you are using discriminator wrong: you don't have any definition inherited from the ${e.title}`),null;const c=o.findIndex((k,x)=>C(u,`d=${x}`)),l=c===-1?0:c,v=d[e.pointer]!==void 0?d[e.pointer]:l,a=o[v];return a?.isCircular?r(s,{schema:a}):r(p,{...i,schema:a,discriminator:{fieldName:f,parentSchema:e,activeOneOfIdx:l},onOneOfChange:n})}if(o!==void 0&&o.length>=1)return r(b,{...i,schema:e,onChange:n});const m=Array.isArray(t)?t:[t];if(m.includes("object")){if(e.fields?.length)return r(p,{...i,schema:e,onOneOfChange:n})}else if(m.includes("array"))return r(I,{...i,schema:e,onOneOfChange:n});const O={schema:e,name:"",description:i.oneOfLevel?"":e.description,required:!1,deprecated:!1};return r($,{$hideBorder:i.hideBottomBorder,children:r(A,{field:O,fieldParentsName:i.fieldParentsName})})}const G=y(P),$=L.div`
|
|
2
2
|
width: 100%;
|
|
3
3
|
padding: var(--spacing-xxs) 0;
|
|
4
|
-
border-bottom: 1px solid var(--border-color-primary);
|
|
5
|
-
`;export{
|
|
4
|
+
${({$hideBorder:e})=>!e&&"border-bottom: 1px solid var(--border-color-primary)"};
|
|
5
|
+
`;export{G as Schema};
|
|
@@ -12,7 +12,6 @@ export interface SchemaOptions {
|
|
|
12
12
|
export interface SchemaProps extends SchemaOptions {
|
|
13
13
|
schema: SchemaModel;
|
|
14
14
|
parentType?: string[] | string;
|
|
15
|
-
onDiscriminatorChange?: (idx: number) => void;
|
|
16
15
|
onOneOfChange?: (params: OneOfChangeParams) => void;
|
|
17
16
|
fieldParentsName?: string[];
|
|
18
17
|
expandable?: boolean;
|
|
@@ -22,13 +21,13 @@ export interface SchemaProps extends SchemaOptions {
|
|
|
22
21
|
disableDeepLinks?: boolean;
|
|
23
22
|
oneOfLevel?: number;
|
|
24
23
|
shouldCloseArray?: boolean;
|
|
24
|
+
hideBottomBorder?: boolean;
|
|
25
25
|
}
|
|
26
|
-
export interface ObjectSchemaProps extends
|
|
26
|
+
export interface ObjectSchemaProps extends SchemaProps {
|
|
27
27
|
discriminator?: {
|
|
28
28
|
fieldName: string;
|
|
29
29
|
parentSchema: SchemaModel;
|
|
30
30
|
activeOneOfIdx: number;
|
|
31
|
-
onChange?: (idx: number) => void;
|
|
32
31
|
};
|
|
33
32
|
fieldParentsName?: string[];
|
|
34
33
|
expandable?: boolean;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as i,jsxs as S}from"react/jsx-runtime";import{memo as M,useCallback as j,useMemo as C}from"react";import{LayoutVariant as D}from"@redocly/config";import{useAtom as k,useAtomValue as O}from"jotai";import{useWriteAtom as T}from"../../jotai/use-write-atom.js";import{SamplesMiddlePanel as b,SamplesPanel as N,Row as P,Section as E,CodeBlockPanel as w}from"../common/index.js";import{getMediaType as B}from"../../models/index.js";import{MediaTypeSamples as I}from"../PayloadSamples/index.js";import{Schema as L}from"../Schema/index.js";import{Markdown as W}from"../Markdown/index.js";import{layoutAtom as V}from"../../jotai/app.js";import{globalStoreAtom as _}from"../../jotai/store.js";import{operationStore as x}from"../../jotai/operation.js";import{styled as g}from"../../styled-components.js";import{SchemaCatalogLink as $}from"../SchemaCatalogLink/SchemaCatalogLink.js";const F=(e,t)=>{if(!e)return{};const n={schema:{$ref:e}};return t&&(n.examples={example:{$ref:t}}),n};function K(e){if(!e?.description)return!1;const t=Array.isArray(e.type)?e.type:[e.type],n=t.includes("object")&&(e.fields?.length??0)>0,c=t.includes("array"),a=!!e.oneOf?.length,s=!!e.discriminatorProp;return n||c||a||s}function q({schemaRef:e,exampleRef:t,showReadOnly:n=!0,showWriteOnly:c=!1}){const a=O(V),{parser:s,options:l}=O(_),d=T(),o=C(()=>B(s,"json",!1,F(e,t),l,{operation:{pointer:"SchemaDefinitionComponent"}}),[t,l,s,e]),[f,h]=k(x(o.operation?.pointer)),v=j(m=>{if(!o.schema)return;const r=o.schema,y=r.oneOf;if(y&&o?.examples&&Object.keys(o?.examples).includes(m)){const p=y.findIndex(A=>A.title===m);p!==-1&&r&&d(x(r.operationPointer),{activeExampleName:r.oneOf?.[p]?.title,activeOneOf:{[r.pointer]:p}})}f.activeExampleName!==m&&h({activeExampleName:m})},[o?.examples,o.schema,f.activeExampleName,h,d]),u=a===D.STACKED;return i(E,{className:"schema-definition",children:S(P,{layout:a,children:[S(G,{isStacked:u,children:[e&&i($,{schemaRef:e}),o.schema?.description&&K(o.schema)&&i(z,{children:i(W,{source:o.schema.description})}),i(L,{skipWriteOnly:!c,skipReadOnly:!n,schema:o.schema,level:1})]}),i(N,{isStacked:u,children:i(w,{className:"panel-response-samples",children:i(I,{mediaType:o,onChange:v})})})]})})}const se=M(q),z=g.div`
|
|
2
2
|
margin-bottom: var(--spacing-vertical);
|
|
3
|
-
`,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
`,G=g(b)`
|
|
4
|
+
&& {
|
|
5
|
+
padding-left: 0;
|
|
6
|
+
padding-right: 0;
|
|
7
|
+
}
|
|
8
|
+
`;export{se as SchemaDefinition};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as i,jsxs as e}from"react/jsx-runtime";import{memo as T,useCallback as v}from"react";import{useNavigate as W}from"react-router-dom";import{useAtomValue as M}from"jotai";import{LayoutVariant as C}from"@redocly/config";import{Markdown as o}from"@redocly/theme/components/Markdown/Markdown";import{breakpoints as d}from"@redocly/theme/core/openapi";import{Button as I}from"@redocly/theme/components/Button/Button";import{PageActions as j}from"@redocly/theme/components/PageActions/PageActions";import{H2 as B}from"@redocly/theme/components/Typography/H2";import{LinkIcon as A}from"@redocly/theme/icons/LinkIcon/LinkIcon";import{encodeBackSlashes as L,getBreadcrumbs as H}from"../../utils/index.js";import{joinWithSeparator as $}from"../../services/history/helpers.js";import{Row as P,SamplesMiddlePanel as w,SamplesPanel as c,ShareLink as D}from"../common/index.js";import{Markdown as N}from"../Markdown/index.js";import{OperationsNavigation as V}from"./OperationsNavigation.js";import{Breadcrumbs as _}from"./Breadcrumbs.js";import{layoutAtom as E}from"../../jotai/app.js";import{useTranslate as F}from"../../hooks/index.js";import{styled as r}from"../../styled-components.js";import{StyledShareLink as K}from"../common/linkify.js";function O({item:a,routingBasePath:n="",isExpanded:g}){const b=F(),{description:k,name:f,href:x}=a,t=W(),h=M(E),l=$(n,a.href),S=v(()=>{t(l)},[t,l]),p=!!a.items.length,m=h===C.STACKED,s=!p,u=H(a),y=v(z=>{t($(n,L(z)))},[t,n]);return e(R,{expanded:g,children:[e(P,{layout:h,children:[e(q,{fullWidth:s,isStacked:m,children:[e(G,{fullWidth:s,isStacked:m,children:[u.length>0&&i(_,{breadcrumbs:u,onClick:y}),e(Q,{children:[i(D,{to:x,"aria-label":`link to ${f}`}),f]}),i(j,{pageSlug:l})]}),i(J,{fullWidth:s,isStacked:m,children:i(N,{source:k})})]}),p&&i(V,{items:a.items,routingBasePath:n})]}),p&&!g&&e(U,{type:"button",variant:"text",size:"medium",onClick:S,children:["+ ",b("openapi.actions.show","Show")]})]})}const $a=T(O),R=r.div`
|
|
2
2
|
padding-top: var(--spacing-lg);
|
|
3
3
|
padding-bottom: ${({expanded:a})=>a?"var(--spacing-xxl)":""};
|
|
4
4
|
`,q=r(w)`
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
&& {
|
|
6
|
+
@media screen and (min-width: ${d.large}) {
|
|
7
|
+
padding-left: ${({fullWidth:a,isStacked:n})=>a&&!n?"0":void 0};
|
|
8
|
+
padding-right: ${({fullWidth:a,isStacked:n})=>a&&!n?"0":void 0};
|
|
9
|
+
}
|
|
8
10
|
}
|
|
9
11
|
`,G=r.div`
|
|
10
12
|
display: flex;
|
|
@@ -12,13 +14,13 @@ import{jsx as n,jsxs as e}from"react/jsx-runtime";import{memo as W,useCallback a
|
|
|
12
14
|
margin: var(--h2-margin-top) 0 var(--h2-margin-bottom);
|
|
13
15
|
position: relative;
|
|
14
16
|
|
|
15
|
-
@media screen and (min-width: ${
|
|
16
|
-
padding-left: ${({fullWidth:a,isStacked:
|
|
17
|
-
padding-right: ${({fullWidth:a,isStacked:
|
|
18
|
-
width: ${({fullWidth:a,isStacked:
|
|
17
|
+
@media screen and (min-width: ${d.large}) {
|
|
18
|
+
padding-left: ${({fullWidth:a,isStacked:n})=>a&&!n?"calc(var(--panel-gap-horizontal) * 2)":void 0};
|
|
19
|
+
padding-right: ${({fullWidth:a,isStacked:n})=>a&&!n?"var(--panel-gap-horizontal)":void 0};
|
|
20
|
+
width: ${({fullWidth:a,isStacked:n})=>a&&!n?"calc(100% - var(--panel-samples-width))":void 0};
|
|
19
21
|
|
|
20
22
|
${K} {
|
|
21
|
-
left: ${({fullWidth:a,isStacked:
|
|
23
|
+
left: ${({fullWidth:a,isStacked:n})=>a&&!n?"unset":void 0};
|
|
22
24
|
}
|
|
23
25
|
}
|
|
24
26
|
`,J=r.div`
|
|
@@ -27,20 +29,25 @@ import{jsx as n,jsxs as e}from"react/jsx-runtime";import{memo as W,useCallback a
|
|
|
27
29
|
E.g. SchemaDefinition, McpTool
|
|
28
30
|
padding is added by the TagItem itself
|
|
29
31
|
*/
|
|
30
|
-
${
|
|
32
|
+
${o} ${c} {
|
|
31
33
|
padding-left: 0;
|
|
32
34
|
padding-right: 0;
|
|
33
35
|
}
|
|
34
36
|
|
|
35
|
-
@media screen and (min-width: ${
|
|
36
|
-
${
|
|
37
|
-
padding-left: ${({fullWidth:a,isStacked:
|
|
38
|
-
padding-right: ${({fullWidth:a,isStacked:
|
|
37
|
+
@media screen and (min-width: ${d.large}) {
|
|
38
|
+
${o} ${w} {
|
|
39
|
+
padding-left: ${({fullWidth:a,isStacked:n})=>a&&!n?"calc(var(--panel-gap-horizontal) * 2)":void 0};
|
|
40
|
+
padding-right: ${({fullWidth:a,isStacked:n})=>a&&!n?"var(--panel-gap-horizontal)":void 0};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
${o} .schema-definition ${c} {
|
|
44
|
+
padding-left: ${({fullWidth:a,isStacked:n})=>a&&!n?"var(--panel-gap-horizontal)":void 0};
|
|
45
|
+
padding-right: ${({fullWidth:a,isStacked:n})=>a&&!n?"calc(var(--panel-gap-horizontal) * 2)":void 0};
|
|
39
46
|
}
|
|
40
47
|
|
|
41
|
-
${
|
|
42
|
-
padding-left: ${({fullWidth:a,isStacked:
|
|
43
|
-
padding-right: ${({fullWidth:a,isStacked:
|
|
48
|
+
${o} .mcp-tool ${c} {
|
|
49
|
+
padding-left: ${({fullWidth:a,isStacked:n})=>a&&!n?"var(--panel-gap-horizontal)":void 0};
|
|
50
|
+
padding-right: ${({fullWidth:a,isStacked:n})=>a&&!n?"calc(var(--panel-gap-horizontal) * 2)":void 0};
|
|
44
51
|
}
|
|
45
52
|
}
|
|
46
53
|
`,Q=r(B)`
|
|
@@ -63,11 +70,11 @@ import{jsx as n,jsxs as e}from"react/jsx-runtime";import{memo as W,useCallback a
|
|
|
63
70
|
margin: var(--spacing-md) var(--spacing-xl) var(--spacing-xxs);
|
|
64
71
|
width: calc(100% - var(--spacing-xl) * 2);
|
|
65
72
|
|
|
66
|
-
@media screen and (min-width: ${
|
|
73
|
+
@media screen and (min-width: ${d.medium}) {
|
|
67
74
|
--button-margin-md: calc(var(--spacing-xl) * 2);
|
|
68
75
|
|
|
69
76
|
margin-left: var(--button-margin-md);
|
|
70
77
|
margin-right: var(--button-margin-md);
|
|
71
78
|
width: calc(100% - var(--button-margin-md) * 2);
|
|
72
79
|
}
|
|
73
|
-
`;export{
|
|
80
|
+
`;export{$a as TagItem,O as TagItemComponent};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{Tag as o}from"@redocly/theme/components/Tag/Tag";import{styled as r}from"../../styled-components.js";const
|
|
1
|
+
import{Tag as o}from"@redocly/theme/components/Tag/Tag";import{styled as r}from"../../styled-components.js";const i=r.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-direction: column;
|
|
4
4
|
margin: var(--spacing-unit) var(--spacing-md) var(--spacing-sm);
|
|
5
|
-
`,
|
|
5
|
+
`,t=r(o)`
|
|
6
6
|
text-transform: uppercase;
|
|
7
7
|
background-color: unset;
|
|
8
8
|
border: none;
|
|
@@ -28,12 +28,6 @@ import{Tag as o}from"@redocly/theme/components/Tag/Tag";import{styled as r}from"
|
|
|
28
28
|
align-items: center;
|
|
29
29
|
gap: var(--spacing-xs);
|
|
30
30
|
margin-top: var(--spacing-xs);
|
|
31
|
-
|
|
32
|
-
&:after {
|
|
33
|
-
content: '';
|
|
34
|
-
flex: auto;
|
|
35
|
-
border-top: 1px solid var(--border-color-primary);
|
|
36
|
-
}
|
|
37
31
|
`,d=r.span`
|
|
38
32
|
padding: 0 var(--spacing-xs);
|
|
39
33
|
border-radius: var(--border-radius);
|
|
@@ -42,17 +36,10 @@ import{Tag as o}from"@redocly/theme/components/Tag/Tag";import{styled as r}from"
|
|
|
42
36
|
font-size: var(--font-size-sm);
|
|
43
37
|
line-height: var(--line-height-sm);
|
|
44
38
|
color: var(--tag-basic-content-color);
|
|
45
|
-
`,
|
|
39
|
+
`,p=r(a)`
|
|
46
40
|
margin-top: 0;
|
|
47
41
|
width: 100%;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
&:before {
|
|
54
|
-
content: '';
|
|
55
|
-
flex: auto;
|
|
56
|
-
border-top: 1px solid var(--border-color-primary);
|
|
57
|
-
}
|
|
58
|
-
`;export{l as ArrayClosingLabel,a as ArrayLabel,t as Container,i as HttpVerb,d as LabelValue,s as MimeLabel};
|
|
42
|
+
`,l=r.span`
|
|
43
|
+
flex: 1;
|
|
44
|
+
border-top: 1px solid var(--border-color-primary);
|
|
45
|
+
`;export{p as ArrayClosingLabel,a as ArrayLabel,i as Container,t as HttpVerb,d as LabelValue,l as Line,s as MimeLabel};
|
package/lib/models/field.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{REDOCLY_TEAMS_RBAC as m}from"@redocly/config";import{joinWithSeparator as
|
|
1
|
+
import{REDOCLY_TEAMS_RBAC as m}from"@redocly/config";import{joinWithSeparator as M}from"../services/index.js";import{extractExtensions as V,getValueFromMdParsedExtension as E,mapValues as I,removePercentChart as L}from"../utils/index.js";import{getSchema as T}from"./schema.js";import{getExamples as _}from"./example.js";const F={path:{style:"simple",explode:!1},query:{style:"form",explode:!0},header:{style:"simple",explode:!1},cookie:{style:"form",explode:!0},querystring:{style:"form",explode:!0}};function N(l,i,p,a,d,x,g=p){const{resolved:e}=l.deref(i),P=i.kind||"field",f=i.name||e.name,n=e.in,v=!!e.required;let r=e.schema,u,s="",c;if(!r&&e.in&&e.content){s=Object.keys(e.content)[0];const t=e.content[s];r=t&&t?.example?{...l.deref(t.schema,x,!0).resolved,example:e.example||t.example}:t.schema}const h=M(d.parentFieldFullPath,L(f||"")),o=T({parser:l,schemaOrRef:r||{},pointer:p,options:a,baseRefsStack:x,absolutePointer:i.$ref||e.schema?.absolutePointer||g,deps:{...d,parentFieldFullPath:h,in:n}}),w=e.description===void 0?E(o,"description")||"":E(e,"description"),R=e.example||o.example,y=e.examples||e.content?.[s]?.examples,S=y?I(y,(t,C)=>_({parser:l,infoOrRef:t,mime:C,encoding:e.encoding})):void 0;s?u=s:e.style?c=e.style:n&&(c=F[n]?.style??"form");const A=e.explode===void 0&&n?F[n]?.explode??!0:!!e.explode,b=e.deprecated===void 0?o.deprecated:e.deprecated,k=a.showExtensions?V(e,a.showExtensions):void 0,q=o?.const||e?.const||"";return{deps:d||{},schema:o,name:f,required:v,description:w,example:R,examples:S,deprecated:b,in:n,kind:P,extensions:k,explode:A,style:c,const:q,serializationMime:u,fieldFullPath:h,...e.allowReserved&&{allowReserved:e.allowReserved},[m]:e[m]||o[m]}}export{N as getField};
|
package/lib/models/types.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{IS_BROWSER as E,isObject as R,isString as B,isUndefined as o}from"@redocly/theme/core/openapi";import{tryDecodeURIComponent as W,getDefinitionName as I}from"../utils/index.js";import{JsonPointer as g}from"../utils/JsonPointer.js";import{normalizeOptions as z}from"./config-options/normalizeOptions.js";function w(m,e){return e&&m[m.length-1]!==e?[...m,e]:m}function $(m,e){return e?m.concat(e):m}class _{options;definitionUrl;definition;allowMergeRefs=!1;constructor(e,t,f=z({})){this.options=f,this.definition=Object.assign({},e),this.validate(e),this.definition=e,this.allowMergeRefs=e.openapi.startsWith("3.1");const n=E?window.location.href:"";B(t)&&(this.definitionUrl=new URL(t,n).href)}validate(e){if(o(e.openapi))throw new Error("Document must be valid OpenAPI 3.0.0 definition")}byRef=e=>{let t;if(this.definition){e.charAt(0)!=="#"&&(e="#"+e),e=W(e);try{t=g.get(this.definition,e)}catch{}return t||{}}};isRef(e){return e?(e=e,e.$ref!==void 0&&e.$ref!==null):!1}deref(e,t=[],f=!1,n=0){const i=e?.["x-refsStack"];if(t=$(t,i),n>5)return{resolved:Object.assign({},e,{"x-complex":!0}),refsStack:t};if(this.isRef(e)){const r=I(e.$ref);if(r&&this.options.ignoreNamedSchemas.has(r))return{resolved:{type:"object",title:r},refsStack:t};let s=this.byRef(e.$ref);if(!s)throw new Error(`Failed to resolve $ref "${e.$ref}"`);return t.includes(e.$ref)?s=Object.assign({},s,{"x-circular-ref":!0}):this.isRef(s)&&(s=this.deref(s,t,f,n).resolved),this.allowMergeRefs&&(s=this.mergeRefs(e,s,f)),{resolved:s,refsStack:w(t,e.$ref)}}return{resolved:e,refsStack:$(t,i)}}mergeRefs(e,t,f){const{$ref:n,...i}=e,r=Object.keys(i);if(r.length===0)return t;if(f&&r.some(s=>!["description","title","externalDocs","x-refsStack","x-parentRefs","readOnly","writeOnly","x-complex"].includes(s))){const{description:s,title:u,readOnly:y,writeOnly:a,...O}=i;return{allOf:[{description:s,title:u,readOnly:y,writeOnly:a},t,O]}}else return{...t,...i}}mergeAllOf(e,t,f,n="",i=0){if(e["x-circular-ref"])return e;if(e=this.hoistOneOfs(e),e.allOf===void 0)return{absolutePointer:n,...e};let r={...e,"x-parentRefs":[],absolutePointer:g.join(n,["allOf"]),allOf:void 0,title:i===0?e.title||I(t):e.title};!o(r.properties)&&R(r.properties)&&(r.properties={...r.properties}),!o(r.items)&&R(r.items)&&(r.items={...r.items});const s=e.allOf.map((u,y)=>{const{resolved:a,refsStack:O}=this.deref(u,f,!0,i),c=u.$ref,p=c||g.join(n,[String(y)]);if(a["x-complex"])return{$ref:c,refsStack:w(O,c),schema:{"x-complex":!0},absolutePointer:p};const d=this.mergeAllOf(a,c,O,p,i+1);if(!(d["x-circular-ref"]&&d.allOf))return c&&r["x-parentRefs"]?.push(...d["x-parentRefs"]||[],c),{$ref:c,refsStack:w(O,c),schema:d,absolutePointer:p}}).filter(Boolean);for(const[u,{$ref:y,schema:a,refsStack:O,absolutePointer:c}]of s.entries()){const{type:p,enum:d,properties:h,items:D,required:k,title:S,description:C,readOnly:M,writeOnly:N,oneOf:P,anyOf:v,"x-circular-ref":A,"x-complex":b,...U}=a||{};if(!(r.type!==p&&!o(r.type)&&!o(p)&&!i)){if(o(p)||(Array.isArray(p)&&Array.isArray(r.type)?r.type=[...p,...r.type]:r.type=p),o(d)||(Array.isArray(d)&&Array.isArray(r.enum)?r.enum=Array.from(new Set([...d,...r.enum])):r.enum=d),!o(h)&&R(h)){r.properties=r.properties||{};for(const l in h){const x=$(O,h[l]?.["x-refsStack"]);if(!r.properties[l])r.properties[l]={...h[l],absolutePointer:g.join(c,["properties",l]),"x-refsStack":x};else if(!A){const q=this.mergeAllOf({allOf:[r.properties[l],h[l]],"x-refsStack":x},t+"/properties/"+l,x,g.join(c,["allOf",String(u),"properties",l]),i+1);r.properties[l]=q}}}if(!o(D)&&!A&&!b){const l=typeof r.items=="boolean"?{}:Object.assign({},r.items),x=typeof a.items=="boolean"?{}:Object.assign({},a.items);r.items=this.mergeAllOf({allOf:[l,x]},t+"/items",O,"",i+1)}o(P)||(r.oneOf=P),o(v)||(r.anyOf=v),Array.isArray(k)&&(r.required=[...r.required||[],...k]),r={...r,title:y&&S?S:r.title||S,description:r.description||C,readOnly:o(r.readOnly)?M:r.readOnly,writeOnly:o(r.writeOnly)?N:r.writeOnly,"x-circular-ref":r["x-circular-ref"]||A,"x-complex":r["x-complex"]||b,...U}}}return r}findDerived(e){const t={},f=this.definition.components&&this.definition.components.schemas||{};for(const n in f){const{resolved:i}=this.deref(f[n]);!o(i.allOf)&&i.allOf.find(r=>!o(r.$ref)&&e.indexOf(r.$ref)>-1)&&(t["#/components/schemas/"+n]=[i["x-discriminator-value"]||n])}return t}hoistOneOfs(e){if(o(e.allOf))return e;const{allOf:t,...f}=e;for(let n=0;n<t.length;n++){const{oneOf:i,...r}=t[n];if(i&&Array.isArray(i)){const s=t.slice(0,n),u=t.slice(n+1),y=Object.keys(r).length>0?[r]:[];return{...f,oneOf:i.map(a=>({allOf:[...s,...y,a,...u]}))}}}return e}}export{_ as OpenAPIParser,$ as concatRefStacks,w as pushRef};
|
|
1
|
+
import{IS_BROWSER as E,isObject as R,isString as B,isUndefined as o}from"@redocly/theme/core/openapi";import{tryDecodeURIComponent as W,getDefinitionName as I}from"../utils/index.js";import{JsonPointer as g}from"../utils/JsonPointer.js";import{normalizeOptions as z}from"./config-options/normalizeOptions.js";function w(m,e){return e&&m[m.length-1]!==e?[...m,e]:m}function $(m,e){return e?m.concat(e):m}class _{options;definitionUrl;definition;allowMergeRefs=!1;constructor(e,t,f=z({})){this.options=f,this.definition=Object.assign({},e),this.validate(e),this.definition=e,this.allowMergeRefs=e.openapi.startsWith("3.1");const n=E?window.location.href:"";B(t)&&(this.definitionUrl=new URL(t,n).href)}validate(e){if(o(e.openapi))throw new Error("Document must be valid OpenAPI 3.0.0 definition")}byRef=e=>{let t;if(this.definition){e.charAt(0)!=="#"&&(e="#"+e),e=W(e);try{t=g.get(this.definition,e)}catch{}return t||{}}};isRef(e){return e?(e=e,e.$ref!==void 0&&e.$ref!==null):!1}deref(e,t=[],f=!1,n=0){const i=e?.["x-refsStack"];if(t=$(t,i),n>5)return{resolved:Object.assign({},e,{"x-complex":!0}),refsStack:t};if(this.isRef(e)){const r=I(e.$ref);if(r&&this.options.ignoreNamedSchemas.has(r))return{resolved:{type:"object",title:r},refsStack:t};let s=this.byRef(e.$ref);if(!s)throw new Error(`Failed to resolve $ref "${e.$ref}"`);return t.includes(e.$ref)?s=Object.assign({},s,{"x-circular-ref":!0}):this.isRef(s)&&(s=this.deref(s,t,f,n).resolved),this.allowMergeRefs&&(s=this.mergeRefs(e,s,f)),{resolved:s,refsStack:w(t,e.$ref)}}return{resolved:e,refsStack:$(t,i)}}mergeRefs(e,t,f){const{$ref:n,...i}=e,r=Object.keys(i);if(r.length===0)return t;if(f&&r.some(s=>!["description","title","externalDocs","x-refsStack","x-parentRefs","readOnly","writeOnly","x-complex"].includes(s))){const{description:s,title:u,readOnly:y,writeOnly:a,...O}=i;return{allOf:[{description:s,title:u,readOnly:y,writeOnly:a},t,O]}}else return{...t,...i}}mergeAllOf(e,t,f,n="",i=0){if(e["x-circular-ref"])return e;if(e=this.hoistOneOfs(e),e.allOf===void 0)return{absolutePointer:n,...e};let r={...e,"x-parentRefs":[],absolutePointer:g.join(n,["allOf"]),allOf:void 0,title:i===0?e.title||I(t):e.title};!o(r.properties)&&R(r.properties)&&(r.properties={...r.properties}),!o(r.items)&&R(r.items)&&(r.items={...r.items});const s=e.allOf.map((u,y)=>{const{resolved:a,refsStack:O}=this.deref(u,f,!0,i),c=u.$ref,p=c||g.join(n,[String(y)]);if(a["x-complex"])return{$ref:c,refsStack:w(O,c),schema:{"x-complex":!0},absolutePointer:p};const d=this.mergeAllOf(a,c,O,p,i+1);if(!(d["x-circular-ref"]&&d.allOf))return c&&r["x-parentRefs"]?.push(...d["x-parentRefs"]||[],c),{$ref:c,refsStack:w(O,c),schema:d,absolutePointer:p}}).filter(Boolean);for(const[u,{$ref:y,schema:a,refsStack:O,absolutePointer:c}]of s.entries()){const{type:p,enum:d,properties:h,items:D,required:k,title:S,description:C,readOnly:M,writeOnly:N,oneOf:P,anyOf:v,"x-circular-ref":A,"x-complex":b,...U}=a||{};if(!(r.type!==p&&!o(r.type)&&!o(p)&&!i)){if(o(p)||(Array.isArray(p)&&Array.isArray(r.type)?r.type=[...p,...r.type]:r.type=p),o(d)||(Array.isArray(d)&&Array.isArray(r.enum)?r.enum=Array.from(new Set([...d,...r.enum])):r.enum=d),!o(h)&&R(h)){r.properties=r.properties||{};for(const l in h){const x=$(O,h[l]?.["x-refsStack"]);if(!r.properties[l])r.properties[l]={...h[l],absolutePointer:g.join(c,["properties",l]),"x-refsStack":x};else if(!A){const q=this.mergeAllOf({allOf:[r.properties[l],h[l]],"x-refsStack":x},t+"/properties/"+l,x,g.join(c,["allOf",String(u),"properties",l]),i+1);r.properties[l]=q}}}if(!o(D)&&!A&&!b){const l=typeof r.items=="boolean"?{}:Object.assign({},r.items),x=typeof a.items=="boolean"?{}:Object.assign({},a.items);r.items=this.mergeAllOf({allOf:[l,x]},t+"/items",O,"",i+1)}o(P)||(r.oneOf=P),o(v)||(r.anyOf=v),Array.isArray(k)&&(r.required=[...r.required||[],...k]),r={...r,title:e.title||(y&&S?S:r.title||S),description:r.description||C,readOnly:o(r.readOnly)?M:r.readOnly,writeOnly:o(r.writeOnly)?N:r.writeOnly,"x-circular-ref":r["x-circular-ref"]||A,"x-complex":r["x-complex"]||b,...U}}}return r}findDerived(e){const t={},f=this.definition.components&&this.definition.components.schemas||{};for(const n in f){const{resolved:i}=this.deref(f[n]);!o(i.allOf)&&i.allOf.find(r=>!o(r.$ref)&&e.indexOf(r.$ref)>-1)&&(t["#/components/schemas/"+n]=[i["x-discriminator-value"]||n])}return t}hoistOneOfs(e){if(o(e.allOf))return e;const{allOf:t,...f}=e;for(let n=0;n<t.length;n++){const{oneOf:i,...r}=t[n];if(i&&Array.isArray(i)){const s=t.slice(0,n),u=t.slice(n+1),y=Object.keys(r).length>0?[r]:[];return{...f,oneOf:i.map(a=>({allOf:[...s,...y,a,...u]}))}}}return e}}export{_ as OpenAPIParser,$ as concatRefStacks,w as pushRef};
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
import{getTagOrGroup as l}from"../../models/group.js";import{DEFAULT_WEBHOOKS_TAG_NAME as
|
|
2
|
-
|
|
3
|
-
`:"",d=l(s==="tools"?"tool":s==="resources"?"rsrc":"prompt",{name:r.name,"x-displayName":r.title||r.name,description:`${p}${r.description||""}
|
|
4
|
-
{% mcp${t.slice(0,-1)} name="${r.name}" id="${n}" /%}`,isSchema:!0,level:2},i);d.depth=i.depth+1,o.push(d)}}return o}function W(c,a){const{definition:i}=c,o={},s=i["x-webhooks"]||i.webhooks,t=i["x-mcp"];for(const f of a||[])o[f.name]={...f,operations:[]};return i.paths&&S(c,i.paths,o),s&&S(c,s,o,!0),t&&U(t,o),o}function U(c,a){for(const i of N)if(c[i])for(const o of c[i]){const s=o.tags&&o.tags.length?o.tags:[$(i)];for(const t of s){let f=a[t];f===void 0&&(f={name:t,operations:[],used:!0},a[t]=f)}}}function P(c,a,i,o,s,t,f,r){if(s.$ref){const{resolved:n}=c.deref(s);S(c,{[o]:n},t,f);return}let e=i?.tags;(!e||!e.length)&&(e=f?[y]:[""]);for(const n of e){let p=t[n];p===void 0&&(p={name:n,operations:[]},t[n]=p),!p["x-traitTag"]&&p.operations.push({...i,pathName:o,pointer:D.compile(["paths",o,a]),httpVerb:a==="x-query"?"query":a,pathParameters:s.parameters||[],pathServers:s.servers,isWebhook:!!f,isAdditionalOperation:!!r,keywords:i["x-keywords"]})}}function S(c,a,i,o){for(const s of Object.keys(a||{})){const t=a[s],f=Object.keys(t).filter(j);for(const r of f){const e=t[r];P(c,r,e,s,t,i,o)}if(t.additionalOperations)for(const[r,e]of Object.entries(t.additionalOperations))P(c,r,e,s,t,i,o,!0)}}function z(c,a,i,o){const s=Object.values(a).filter(e=>{const n=e.kind;return n===void 0||n==="nav"}),t=new Map;s.forEach(e=>{t.set(e.name,e)});const f=s.filter(e=>{const n=e.parent;return!n||!t.has(n)}),r=(e,n,p=1)=>{if(p>_)return console.warn("The tags exceed the maximum nesting level."),[];const u=[];for(const d of e){const m=l("tag",d,n);if(m.depth=(n?.depth||O)+1,d.name===""){const x=[...T(h(d,"description")||"",m,m.depth+1),...g(void 0,d,m.depth+1,a)];u.push(...x);continue}const b=s.filter(x=>x.parent===d.name),k=w({definition:c.definition,tag:d,parent:m,schemaDefinitionsTagName:o.schemaDefinitionsTagName}),v=E(c.definition,d,m),A=r(b,m,p+1);m.items=[...k,...v,...T(h(d,"description")||"",m,m.depth+1),...g(m,d,m.depth+1,a),...A],u.push(m)}return u};return r(f,i,1).filter(({name:e,items:n})=>e!==y||n.length>0)}function $(c){return c.charAt(0).toUpperCase()+c.slice(1)}export{z as buildNestedTagsItems,$ as capitalize,L as getTagGroupsItems,R as getTagsItems,W as getTagsWithOperations,P as processOperation};
|
|
1
|
+
import{getTagOrGroup as l}from"../../models/group.js";import{DEFAULT_WEBHOOKS_TAG_NAME as O,GROUP_DEPTH as y,MAX_NESTING_TAGS_LEVEL as _}from"../../constants.js";import{getValueFromMdParsedExtension as h,isOperationName as j,JsonPointer as D,safeSlugify as G}from"../../utils/index.js";import{getOperationsItems as g}from"./operation.js";import{addMarkdownItems as T}from"./markdown.js";import{joinWithSeparator as I}from"../history/helpers.js";const N=["tools","resources","prompts"];function R(r,c,i,o,s){let t;if(o===void 0?t=Object.keys(c):t=o.tags,!Array.isArray(t))return console.warn("Unexpected values of tags. Check tags or x-tagGroups in your definition."),[];const f=t.map(e=>c[e]?(c[e].used=!0,c[e]):(console.warn(`Non-existing tag "${e}" is added to the group "${o?.name}"`),null)),a=[];for(const e of f){if(!e)continue;const n=l("tag",e,i);if(n.depth=y+1,e.name===""){const d=[...T(h(e,"description")||"",n,n.depth+1),...g(void 0,e,n.depth+1,c)];a.push(...d);continue}const m=P({definition:r.definition,tag:e,parent:n,schemaDefinitionsTagName:s.schemaDefinitionsTagName}),u=w(r.definition,e,n);n.items=[...m,...u,...T(h(e,"description")||"",n,n.depth+1),...g(n,e,n.depth+1,c)],a.push(n)}return a.filter(({name:e,items:n})=>e!==O||n.length>0)}function L(r,c,i,o,s){const t=[];for(const f of i){const a=l("group",f,c);a.depth=y,a.items=R(r,o,a,f,s),t.push(a)}return t}function P({definition:r,tag:c,parent:i,schemaDefinitionsTagName:o}){const s=o?[o]:[];return Object.entries(r.components?.schemas||{}).map(([t,f])=>{if(!(f["x-tags"]||s).includes(c.name))return null;const e=l("schema",{name:t,"x-displayName":`${f.title||t}`,description:`{% schemaDefinition showWriteOnly="true" schemaRef="#/components/schemas/${t}" /%}`,isSchema:!0,level:2},i);return e.depth=i.depth+1,e}).filter(Boolean)}function w(r,c,i){const o=[];for(const s of N)if(r["x-mcp"]?.[s]){const t=b(s),f=[t];for(const a of r["x-mcp"]?.[s]||[])if((a.tags?.length?a.tags:f).includes(c.name)){const n=I(i.id,G(a.name)),m=s==="tools"?"tool":s==="resources"?"rsrc":"prompt",u=s==="tools"?"":`${a.description||""}
|
|
2
|
+
`,d=l(m,{name:a.name,"x-displayName":a.title||a.name,description:`${u}{% mcp${t.slice(0,-1)} name="${a.name}" id="${n}" /%}`,isSchema:!0,level:2},i);d.depth=i.depth+1,o.push(d)}}return o}function W(r,c){const{definition:i}=r,o={},s=i["x-webhooks"]||i.webhooks,t=i["x-mcp"];for(const f of c||[])o[f.name]={...f,operations:[]};return i.paths&&S(r,i.paths,o),s&&S(r,s,o,!0),t&&U(t,o),o}function U(r,c){for(const i of N)if(r[i])for(const o of r[i]){const s=o.tags&&o.tags.length?o.tags:[b(i)];for(const t of s){let f=c[t];f===void 0&&(f={name:t,operations:[],used:!0},c[t]=f)}}}function E(r,c,i,o,s,t,f,a){if(s.$ref){const{resolved:n}=r.deref(s);S(r,{[o]:n},t,f);return}let e=i?.tags;(!e||!e.length)&&(e=f?[O]:[""]);for(const n of e){let m=t[n];m===void 0&&(m={name:n,operations:[]},t[n]=m),!m["x-traitTag"]&&m.operations.push({...i,pathName:o,pointer:D.compile(["paths",o,c]),httpVerb:c==="x-query"?"query":c,pathParameters:s.parameters||[],pathServers:s.servers,isWebhook:!!f,isAdditionalOperation:!!a,keywords:i["x-keywords"]})}}function S(r,c,i,o){for(const s of Object.keys(c||{})){const t=c[s],f=Object.keys(t).filter(j);for(const a of f){const e=t[a];E(r,a,e,s,t,i,o)}if(t.additionalOperations)for(const[a,e]of Object.entries(t.additionalOperations))E(r,a,e,s,t,i,o,!0)}}function z(r,c,i,o){const s=Object.values(c).filter(e=>{const n=e.kind;return n===void 0||n==="nav"}),t=new Map;s.forEach(e=>{t.set(e.name,e)});const f=s.filter(e=>{const n=e.parent;return!n||!t.has(n)}),a=(e,n,m=1)=>{if(m>_)return console.warn("The tags exceed the maximum nesting level."),[];const u=[];for(const d of e){const p=l("tag",d,n);if(p.depth=(n?.depth||y)+1,d.name===""){const x=[...T(h(d,"description")||"",p,p.depth+1),...g(void 0,d,p.depth+1,c)];u.push(...x);continue}const k=s.filter(x=>x.parent===d.name),$=P({definition:r.definition,tag:d,parent:p,schemaDefinitionsTagName:o.schemaDefinitionsTagName}),v=w(r.definition,d,p),A=a(k,p,m+1);p.items=[...$,...v,...T(h(d,"description")||"",p,p.depth+1),...g(p,d,p.depth+1,c),...A],u.push(p)}return u};return a(f,i,1).filter(({name:e,items:n})=>e!==O||n.length>0)}function b(r){return r.charAt(0).toUpperCase()+r.slice(1)}export{z as buildNestedTagsItems,b as capitalize,L as getTagGroupsItems,R as getTagsItems,W as getTagsWithOperations,E as processOperation};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/openapi-docs",
|
|
3
|
-
"version": "3.19.0-next.
|
|
3
|
+
"version": "3.19.0-next.6",
|
|
4
4
|
"description": "Redocly OpenAPI Docs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@markdoc/markdoc": "0.5.2",
|
|
24
|
-
"@redocly/openapi-core": "2.
|
|
24
|
+
"@redocly/openapi-core": "2.20.1",
|
|
25
25
|
"deepmerge": "^4.2.2",
|
|
26
26
|
"dompurify": "3.2.7",
|
|
27
27
|
"fast-deep-equal": "^3.1.3",
|
|
28
|
-
"fast-xml-parser": "5.
|
|
28
|
+
"fast-xml-parser": "5.4.1",
|
|
29
29
|
"jotai": "^2.12.5",
|
|
30
30
|
"jotai-family": "^1.0.1",
|
|
31
31
|
"json-pointer": "^0.6.2",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"url-template": "^2.0.8",
|
|
39
39
|
"util": "~0.12.5",
|
|
40
40
|
"web-vitals": "3.3.1",
|
|
41
|
-
"@redocly/config": "0.
|
|
42
|
-
"@redocly/replay": "0.22.0-next.
|
|
41
|
+
"@redocly/config": "0.44.0",
|
|
42
|
+
"@redocly/replay": "0.22.0-next.5"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@shikijs/transformers": "3.21.0",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@types/react": "^19.2.7",
|
|
53
53
|
"@types/react-dom": "^19.2.3",
|
|
54
54
|
"@types/styled-components": "5.1.34",
|
|
55
|
-
"@vitejs/plugin-react": "5.1.
|
|
55
|
+
"@vitejs/plugin-react": "5.1.2",
|
|
56
56
|
"@vitest/coverage-v8": "4.0.10",
|
|
57
57
|
"esbuild": "0.27.0",
|
|
58
58
|
"jest-styled-components": "7.2.0",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"url": "~0.11.0",
|
|
73
73
|
"vite": "7.2.6",
|
|
74
74
|
"vitest": "4.0.10",
|
|
75
|
-
"@redocly/theme": "0.63.0-next.
|
|
75
|
+
"@redocly/theme": "0.63.0-next.4"
|
|
76
76
|
},
|
|
77
77
|
"scripts": {
|
|
78
78
|
"start": "pnpm run copy-highlight-hook && vite",
|