@redocly/openapi-docs 3.16.0-next.2 → 3.16.0-next.4
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 +1758 -1721
- package/lib/components/RedoclyOpenAPIDocs/Providers.js +1 -1
- package/lib/components/Replay/EmbeddedReplay.d.ts +2 -1
- package/lib/components/Replay/EmbeddedReplay.js +3 -3
- package/lib/components/Replay/utils.js +1 -1
- package/lib/components/ServerListDropdown/ServerListDropdown.js +1 -1
- package/lib/components/SideMenu/hooks/useMenuItems.js +1 -1
- package/lib/components/TagItem/OperationNavigationItems.js +4 -4
- package/lib/components/TagItem/OperationsNavigation.js +2 -2
- package/lib/models/operation.js +1 -1
- package/lib/models/types.d.ts +3 -0
- package/lib/services/OpenAPIParser.js +1 -1
- package/lib/services/menu/operation.js +1 -1
- package/lib/services/menu/tags.d.ts +1 -0
- package/lib/services/menu/tags.js +2 -2
- package/lib/services/types.d.ts +2 -0
- package/lib/types/open-api.d.ts +1 -0
- package/package.json +9 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as d}from"react/jsx-runtime";import{memo as v,useCallback as
|
|
1
|
+
import{jsx as d}from"react/jsx-runtime";import{memo as v,useCallback as y,useEffect as g,useMemo as b}from"react";import E from"@markdoc/markdoc";import{LayoutVariant as S}from"@redocly/config";import{createStore as O,Provider as A}from"jotai";import{html as N}from"@redocly/theme/markdoc/tags/html";import{Heading as M}from"@redocly/theme/markdoc/components/Heading/Heading";import{normalizeOptions as T,OpenAPIParser as D}from"../../services/index.js";import{SchemaDefinition as j}from"../SchemaDefinition/index.js";import{McpTool as k}from"../McpTool/index.js";import{getMarkdownHeaderId as x}from"./utils.js";import{mergeInMockServer as C}from"../../models/operation.js";import{normalizeServers as P}from"../../utils/index.js";import{appStore as H,appStoreOverrideAtom as I,layoutAtom as p,allowedEnvironmentsAtom as L,environmentAtom as R,userClaimsAtom as V}from"../../jotai/app.js";import{mapObject as z}from"../../utils/object.js";import{getServerEnvName as _}from"../../utils/environments.js";import{globalStoreAtom as q}from"../../jotai/store.js";import{getDefaultOperationStore as B,operationStore as F}from"../../jotai/operation.js";const W={ignoreNamedSchemas:["java.io.ObjectStreamField"],maxDisplayedEnumValues:10,markdocOptions:{tags:{html:N.schema,schemaDefinition:{render:"SchemaDefinition",attributes:{schemaRef:{type:String},exampleRef:{type:String},showReadOnly:{type:Boolean},showWriteOnly:{type:Boolean},htmlWrap:{type:String,default:!1}}},mcpTool:{render:"McpTool",attributes:{toolName:{type:String},id:{type:String}}}},nodes:{heading:{children:["inline"],attributes:{id:{type:String},level:{type:Number,required:!0,default:1}},transform(n,m){const t=n.transformAttributes(m),i=n.transformChildren(m),e=typeof t.id=="string"?t.id:x(i);return new E.Tag("Heading",{...t,id:e,level:n.attributes.level},i)}}},components:{SchemaDefinition:j,McpTool:k,Heading:M}}},se=v(({children:n,options:m,definitionUrl:t,definition:i,withState:e})=>{const l=y(()=>{const r=T(m,W),o=new D(i,t,r);return{options:r,parser:o}},[i,t,m]),a=b(()=>{const r=O(),o=l();r.set(q,o);const c=P(o.parser.definitionUrl,C(o.parser.definition?.servers||[],o.options.mockServer));r.sub(H,()=>{}),r.set(p,e?.layout||o.options?.layout||S.THREE_PANEL);const u=Object.fromEntries(c.map(s=>[_(s),{server:s.url,...z(s.variables||{},f=>f.default||"")}]));if(r.set(R,{environments:u}),r.set(V,e?.userClaims||{}),r.set(L,e?.allowedEnvironments),e&&r.set(I,{activeMimeName:e.activeMimeName,userClaims:e.userClaims,environment:e.environment,environments:e.environments}),e?.operation){const s=B(e.operation.pointer,e.operation.state.requestValues,e.operation.state.activeExampleName);r.set(F(e.operation.pointer),s)}return r},[l,e]);return g(()=>{e?.layout&&a.set(p,e?.layout)},[a,e?.layout]),d(A,{store:a,children:n})});export{se as StoreProvider};
|
|
@@ -4,7 +4,8 @@ export type ReplayProps = {
|
|
|
4
4
|
fullOpenApi: OpenAPIDefinition;
|
|
5
5
|
corsProxyUrl?: string;
|
|
6
6
|
pointer: string;
|
|
7
|
+
hideOtherSecuritySchemes?: boolean;
|
|
7
8
|
};
|
|
8
|
-
declare function EmbeddedReplayComponent({ activeOperationId, corsProxyUrl, fullOpenApi, pointer, }: ReplayProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
declare function EmbeddedReplayComponent({ activeOperationId, corsProxyUrl, fullOpenApi, pointer, hideOtherSecuritySchemes, }: ReplayProps): import("react/jsx-runtime").JSX.Element;
|
|
9
10
|
export declare const EmbeddedReplay: import("react").MemoExoticComponent<typeof EmbeddedReplayComponent>;
|
|
10
11
|
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import{Suspense as
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{Suspense as h,lazy as S,memo as x,useEffect as O,useState as R}from"react";import{useAtomValue as o}from"jotai";import{globalOptionsAtom as A}from"../../jotai/store.js";import{operationStore as C}from"../../jotai/operation.js";import{appStore as L,allowedEnvironmentsAtom as T,environmentsAtom as V}from"../../jotai/app.js";import{useTranslate as j}from"../../hooks/index.js";import{convertOperationToReplayValue as k}from"./utils.js";import{getDefaultCollectorUrl as w}from"../../utils/telemetry.js";import{styled as i}from"../../styled-components.js";const U=S(async()=>import("@redocly/replay").then(t=>({default:t.EmbeddedReplay})));function W({activeOperationId:t,corsProxyUrl:p,fullOpenApi:d,pointer:r,hideOtherSecuritySchemes:m}){const a=j(),{mockServer:s}=o(A),c=o(C(r)),f=o(L),u=o(V),n=o(T),[v,y]=R(!1);return O(()=>{y(!0)},[]),e(z,{children:v?e(h,{fallback:e(l,{children:a("openapi.loading","Loading...")}),children:e(U,{activeOperationId:t,activeOperationPointer:r,api:d,settings:{predefinedEnvValues:u,corsProxyUrl:p,mockServer:s,disableCollectionsTab:!0,hideOtherSecuritySchemes:m,...n&&{allowedEnvironments:n},telemetry:{tracerName:"replay-openapi",collectorUrl:w()},convertOperationToReplayValue:(g,b,E)=>k(g,b,E,void 0,c,f)}})}):e(l,{children:a("openapi.loading","Loading...")})})}const J=x(W),l=i.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
justify-content: center;
|
|
4
4
|
align-items: center;
|
|
5
5
|
min-height: 100px;
|
|
6
|
-
`,
|
|
6
|
+
`,z=i.div`
|
|
7
7
|
border: 1px solid var(--border-color-primary);
|
|
8
8
|
border-radius: var(--border-radius-lg);
|
|
9
9
|
padding: 0;
|
|
10
|
-
`;export{
|
|
10
|
+
`;export{J as EmbeddedReplay};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isPrimitive as h}from"@redocly/theme/core/openapi";import{getOperation as v}from"../../models/index.js";import{normalizeOptions as b,OpenAPIParser as E}from"../../services/index.js";import{JsonPointer as
|
|
1
|
+
import{isPrimitive as h}from"@redocly/theme/core/openapi";import{getOperation as v}from"../../models/index.js";import{normalizeOptions as b,OpenAPIParser as E}from"../../services/index.js";import{JsonPointer as O}from"../../utils/index.js";function V(t,r,n,a,e,i,s){if(!n)return;const u=new E(n),o=u.definition.paths?.[t];let l=o?.[r];!l&&o?.additionalOperations&&(l=o.additionalOperations[r]);const m=v(u,{...l,pathName:t,httpVerb:r,pathParameters:o.parameters||[],pathServers:o.servers||[]},void 0,b({}),"",{isCallback:!1},a,s);if(!m)return;const x=i?.activeMimeName||m.requestBody?.content?.mediaTypes[0]?.name||"application/json";return{id:m.id,name:m.name,method:m.httpVerb,operationId:m.operationId,parameters:y(m.parameters,e?.requestValues),body:w(m.requestBody,n,e?.requestValues?.body?{activeExampleName:e?.activeExampleName,[x]:e?.requestValues?.body}:e?.activeExampleName?{activeExampleName:e?.activeExampleName}:void 0),path:m.path,href:m.href,servers:m.servers,security:q(m.security),responses:Object.fromEntries(m.responses.map(c=>[c.code,{code:c.code,description:c.description,mediaTypes:c.content?.mediaTypes.reduce((p,d)=>(p[d.name]={name:d.name,schema:f(d.schema?.rawSchema,n)},p),{})}]))}}function T(t,r){return function(n,a,e){const i=V(n,a,e,t,void 0,void 0,r);if(i)return{...i,operationId:i.operationId||O.compile(["paths",i.path,i.method])}}}function y(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}));for(const[e,i]of Object.entries(r||{}))for(const[s,u]of Object.entries(i||{}))n.has(e+":"+s)||a.push({name:s,in:e,required:!1,description:"",example:String(u),schema:void 0});return a}function N({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 w(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,s])=>[i,{name:i,examples:{default:{value:s}},schema:{},parameters:[]}]))}}return{required:t.required,activeExampleName:n?.activeExampleName,mediaTypes:t.content.mediaTypes.reduce((a,e)=>{const i=e.schema,s=n?.[e.name]?{default:{value:n?.[e.name],rawValue:n?.[e.name],mime:e.name}}:e.examples||e.formExamples;return a[e.name]={name:e.name,examples:s,schema:f(e.schema?.rawSchema,r),parameters:i?.fields?.map(u=>({inputType:N(u.schema),name:u.name,example:g(u,s)}))},a},{})}}function f(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{V as convertOperationToReplayValue,T as convertOperationToReplayValueForRedoc,q as convertRequestSecurity};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as e,jsxs as f}from"react/jsx-runtime";import{useMemo as S,useCallback as c}from"react";import{useAtom as g,useAtomValue as w}from"jotai";import{DropdownMenu as y}from"@redocly/theme/components/Dropdown/DropdownMenu";import{Dropdown as A}from"@redocly/theme/components/Dropdown/Dropdown";import{getOperationColor as C}from"@redocly/theme/core/openapi";import{HttpVerb as b}from"../common/index.js";import{PathWrapper as k,Path as P,StyledCopyButton as V,StyledDropdownMenuItem as j}from"./styled.js";import{PanelItem as x}from"../PanelItem/index.js";import{joinWithSeparator as D}from"../../services/index.js";import{getServerDisplayName as M,replaceVariables as E}from"../../utils/index.js";import{environmentAtom as N}from"../../jotai/app.js";import{useActiveWithFallback as O,useTelemetry as W}from"../../hooks/index.js";import{getServerEnvName as p}from"../../utils/environments.js";import{createTargetServerSwitchEvent as I}from"../../events/index.js";import{globalStoreAtom as T}from"../../jotai/store.js";const $=({operation:r,className:h})=>{const n=W(),[[d],m]=g(N),{options:{events:i}}=w(T),s=O(r.servers.map(t=>({...t,key:t.url})),d.server),a=c(t=>{t.stopPropagation()},[]),l=c(t=>()=>{if(r.servers.length!==1&&(m({environment:p(t)}),n.sendSwitchServersClickedMessage({server:p(t)}),i?.targetServerSwitch&&t)){const o=I({operation:r,serverUrl:t.url});i.targetServerSwitch(o)}},[r,m,n,i]),v=S(()=>r.servers.map(t=>{const o=D(E(t),r.path);return e(j,{onAction:l(t),children:e(x,{header:M(t),title:o,actions:[e(V,{data:o,toasterPlacement:"left",onCopyClick:a},o)],active:t.url===s,withCheckmark:!0})},o)}),[r.servers,r.path,l,a,s]),u=C({isAdditionalOperation:r.isAdditionalOperation,httpVerb:r.httpVerb});return e(A,{className:h,trigger:f(k,{variant:"ghost",children:[e(b,{color:u,children:r.httpVerb}),e(P,{children:r.path})]}),withArrow:!0,children:e(y,{children:v})})};export{$ as ServerListDropdown};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useMemo as
|
|
1
|
+
import{useMemo as b}from"react";import{useLocation as h}from"react-router-dom";import{useActiveSectionId as I}from"@redocly/theme/core/openapi";import{pathMatchedLink as k}from"../../../utils/index.js";import{DEFAULT_WEBHOOKS_TAG_NAME as A}from"../../../constants.js";import{joinWithSeparator as y}from"../../../services/history/helpers.js";function L({items:s,routingBasePath:n}){const t=h(),o=I(t,!1,!1);return b(()=>S(s,o,t,n),[o,s,t,n])}function S(s,n="",t,o){const r=[];return c({contentItems:s,sidebarItems:r,activeItemId:n,location:t,routingBasePath:o}),r}function d(s,n="",t,o){return s.href?n&&o?y(o,s.id)===n:n&&!o?s.id===n:k(t,s.href):!1}function l(s,n="",t,o){return(s.items||[]).some(i=>d(i,n,t,o)||l(i,n,t,o))}function c(s){const{contentItems:n,sidebarItems:t,activeItemId:o,location:r,routingBasePath:i}=s;let p=!0;for(const e of n){const a=d(e,o,r,i),m=l(e,o,r,i);switch(e.type){case"group":t.push({type:"separator",label:e.name,active:a,hasActiveSubItem:m}),c({...s,contentItems:e.items,sidebarItems:t});break;case"tag":const f={type:"group",label:e.name,items:[],link:e.href,active:a,hasActiveSubItem:m,modified:!0};t.push(f),c({contentItems:e.items,sidebarItems:f.items||[],activeItemId:o,location:r,routingBasePath:i});break;case"operation":case"schema":case"mcp":e.isWebhook&&p&&e.parent.name!==A&&(t.push({type:"separator",label:"Webhooks",variant:"secondary"}),p=!1),t.push({type:"link",label:e.name,httpVerb:e.type=="operation"?e.httpVerb:e.type,link:e.href,badges:e.badges,active:a,hasActiveSubItem:m,modified:!0,deprecated:e.deprecated,isAdditionalOperation:e.isAdditionalOperation});break;case"section":if(e.depth===-1)continue;const u={type:e.items.length?"group":"link",label:e.name,link:e.href,items:[],active:a,hasActiveSubItem:m,modified:!0};t.push(u),e.items.length&&c({contentItems:e.items,sidebarItems:u.items,activeItemId:o,location:r,routingBasePath:i});break}}}export{L as useMenuItems};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import{jsx as r,jsxs as i,Fragment as
|
|
1
|
+
import{jsx as r,jsxs as i,Fragment as y}from"react/jsx-runtime";import{memo as w}from"react";import{getOperationColor as j}from"@redocly/theme/core/openapi";import{joinWithSeparator as z}from"../../services/index.js";import{encodeBackSlashes as k}from"../../utils/index.js";import{HttpVerb as C,NavigationBadge as s}from"../common/index.js";import{styled as o}from"../../styled-components.js";import{StyledButton as O}from"./styled.js";function B({title:p,items:l,onClick:c,routingBasePath:d,translate:h}){return i(y,{children:[r(I,{children:p}),l.map(e=>{const{id:g,href:m,deprecated:t,badges:f,isAdditionalOperation:v}=e,b=e.type==="operation"?e.path:e.name,a=e.type==="operation"?e.httpVerb:e.type,x=j({isAdditionalOperation:v,deprecated:t,httpVerb:a});return r(N,{variant:"outlined",size:"large",onClick:()=>c(z(d,k(m))),children:i("span",{children:[r(C,{color:x,children:a}),r(S,{children:b}),t&&r(s,{deprecated:!0,children:h("openapi.badges.deprecated","Deprecated")}),f?.map(({name:n,color:u})=>r(s,{color:u,children:n},n))]})},g)})]})}const q=w(B),I=o.span`
|
|
2
2
|
font-size: var(--font-size-base);
|
|
3
3
|
line-height: var(--line-height-base);
|
|
4
4
|
font-weight: var(--font-weight-bold);
|
|
5
5
|
color: var(--text-color-primary);
|
|
6
6
|
margin: var(--spacing-sm) 0 var(--spacing-xxs) 0;
|
|
7
|
-
`,
|
|
7
|
+
`,N=o(O)`
|
|
8
8
|
border-radius: var(--border-radius);
|
|
9
9
|
background: var(--bg-color);
|
|
10
10
|
justify-content: space-between;
|
|
@@ -24,7 +24,7 @@ import{jsx as r,jsxs as i,Fragment as x}from"react/jsx-runtime";import{memo as u
|
|
|
24
24
|
content: '→';
|
|
25
25
|
line-height: var(--line-height-base);
|
|
26
26
|
}
|
|
27
|
-
`,
|
|
27
|
+
`,S=o.span`
|
|
28
28
|
font-family: var(--font-family-base);
|
|
29
29
|
font-size: var(--font-size-base);
|
|
30
30
|
line-height: var(--line-height-base);
|
|
@@ -33,4 +33,4 @@ import{jsx as r,jsxs as i,Fragment as x}from"react/jsx-runtime";import{memo as u
|
|
|
33
33
|
white-space: nowrap;
|
|
34
34
|
text-overflow: ellipsis;
|
|
35
35
|
overflow-x: hidden;
|
|
36
|
-
`;export{
|
|
36
|
+
`;export{q as OperationNavigationItems};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{jsx as r,jsxs as
|
|
1
|
+
import{jsx as r,jsxs as x}from"react/jsx-runtime";import{useMemo as M,memo as I,useState as N,useCallback as j}from"react";import{useNavigate as E}from"react-router-dom";import{LayoutVariant as P}from"@redocly/config";import{useAtomValue as W}from"jotai/index";import{SamplesPanel as B}from"../common/index.js";import{layoutAtom as _}from"../../jotai/app.js";import{OperationNavigationItems as l}from"./OperationNavigationItems.js";import{StyledButton as R}from"./styled.js";import{useTranslate as V}from"../../hooks/index.js";import{styled as z}from"../../styled-components.js";import{isRenderableMenuItem as D}from"../../utils/menu.js";const m=8;function K({items:c,routingBasePath:a}){const o=V(),[n,C]=N(!1),h=E(),y=W(_)===P.STACKED,{operations:u,webhooks:d,schemas:f,mcpTools:g,showMoreCount:k,totalCount:O}=M(()=>{const s=c.filter(e=>D(e)),w=n?s:s.slice(0,m),{operations:b,additionalOperations:v,webhooks:S,schemas:T,mcpTools:A}=w.reduce((e,t)=>{if(t.type==="operation"&&t.isWebhook)e.webhooks.push(t);else if(t.type==="operation"){const p=t;p.isAdditionalOperation?e.additionalOperations.push(p):e.operations.push(p)}else t.type==="schema"?e.schemas.push(t):t.type==="mcp"&&e.mcpTools.push(t);return e},{operations:[],additionalOperations:[],webhooks:[],schemas:[],mcpTools:[]});return{operations:[...b,...v],schemas:T,mcpTools:A,webhooks:S,showMoreCount:!n&&s.length>m?s.length-m:0,totalCount:s.length}},[n,c]),i=j(s=>h(s),[h]);return O?x(L,{isStacked:y,"data-testid":"operation-navigation-list",children:[f.length>0&&r(l,{items:f,onClick:i,routingBasePath:a,translate:o,title:o("openapi.schemas","Schemas")}),g.length>0&&r(l,{items:g,onClick:i,routingBasePath:a,translate:o,title:o("openapi.mcp.tools","MCP Tools")}),u.length>0&&r(l,{items:u,onClick:i,routingBasePath:a,translate:o,title:o("openapi.operations","Operations")}),d.length>0&&r(l,{items:d,onClick:i,routingBasePath:a,translate:o,title:o("openapi.webhooks","Webhooks")}),!n&&!!k&&x(R,{variant:"link",size:"large","data-testid":"show-more-operations",fullWidth:!0,onClick:()=>C(!0),children:[o("openapi.actions.show","Show")," ",k," ",o("openapi.actions.more","more"),"..."]})]}):null}const eo=I(K),L=z(B)`
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-direction: column;
|
|
4
4
|
gap: var(--spacing-xxs);
|
|
5
5
|
padding-top: var(--spacing-xxl);
|
|
6
|
-
`;export{
|
|
6
|
+
`;export{eo as OperationsNavigation,K as OperationsNavigationComponent};
|
package/lib/models/operation.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{REDOCLY_TEAMS_RBAC as
|
|
1
|
+
import{REDOCLY_TEAMS_RBAC as o}from"@redocly/config";import{removeLeadingSlash as x}from"@redocly/theme/core/openapi";import{configure as q}from"@redocly/theme/ext/configure";import{extractExtensions as R,getOperationId as P,getOperationName as B,getStatusCodeType as E,getValueFromMdParsedExtension as C,isStatusCode as k,JsonPointer as O,mergeParams as V,normalizeServers as n,sortByDeprecated as I,sortByRequired as A,updateOperationWithRequestValues as N,updateParametersWithUserValues as W}from"../utils/index.js";import{getCallback as w}from"./callback.js";import{getField as F}from"./field.js";import{getRequestBody as M}from"./request.js";import{getSecurity as f}from"./security.js";import{getResponse as j}from"./response.js";import{getHref as L}from"../services/menu/operation.js";function $(s){return s.lang==="Payload"&&"requestBodyContent"in s}function i(s,e,t,a,m,d,h,p){const c=e.isWebhook,r={operationDefinition:e,parent:t,pointer:e.pointer,description:C(e,"description"),externalDocs:e.externalDocs,deprecated:!!e.deprecated,httpVerb:e.httpVerb,operationId:e.operationId,path:e.pathName,isWebhook:c,isAdditionalOperation:e.isAdditionalOperation,isCallback:!!d?.isCallback,isEvent:d?.isCallback||c,name:B(e),defaultExampleName:e.defaultSampleName,[o]:e[o]||t?.[o],type:"operation",callbackId:d?.id,href:m,get callbacks(){return Object.keys(e.callbacks||[]).map(u=>w(s,u,e.callbacks?.[u],r.pointer,a,m,t,h))},get responses(){let u=!1;return Object.keys(e.responses||[]).filter(l=>l==="default"?!0:(E(l)==="success"&&(u=!0),k(l))).map(l=>j({parser:s,code:l,defaultAsError:u,infoOrRef:e.responses[l],options:a,isEvent:r.isEvent,operation:r}))},get parameters(){return T(s,e,r,a,g)}};if(d?.isCallback)r.security=f(e.security,s),r.servers=n("",e.servers||e.pathServers||[]),r.id=x(m);else{r.id=P(e,t),r.href=r.href||L(r),r.security=f(e.security||s.definition.security,s);const u=e.servers||(e.pathServers?.length?e.pathServers:null)||s.definition.servers||[];r.servers=n(s.definitionUrl,U(u,a.mockServer))}a.showExtensions&&(r.extensions=R(e,a.showExtensions)),r.requestBody=e.requestBody?M({parser:s,infoOrRef:e.requestBody,options:a,operation:r,isEvent:r.isEvent}):void 0;const y=r.requestBody?.content;r.payload={lang:"Payload",source:"",requestBodyContent:y?.hasSample?y:void 0},r.definitionSamples=e["x-codeSamples"]||[],r.badges=e["x-badges"]?.map(({name:u,color:l,position:v})=>({name:u,color:l||"var(--color-info-base)",position:v||"after"}))||[],r.hasSamples=y?.hasSample||r.definitionSamples.length>0,r.hideReplay=e["x-hideReplay"]===!0;const S={userClaims:h,info:s.definition.info||{},operation:{operationId:r.operationId,name:r.name,path:r.path,href:r.href,method:r.httpVerb},servers:r.servers},b=q(S)||{},g=p||b.requestValues||{};return N(r,g),r}function T(s,e,t,a,m){let d=V(s,e.pathParameters,e.parameters,{pathPointer:O.dirName(t.pointer),operationPointer:t.pointer}).map(({paramOrRef:h,pointer:p})=>{const c=F(s,h,p,a,{operation:t,type:"request"});return W(c,m),c});return a.sortRequiredPropsFirst&&(d=A(d)),I(d)}function U(s,e){if(!e)return s;const t={url:e.url,description:e.description};switch(e.position){case"first":return[t,...s];case"last":return[...s,t];case"replace":return[t];default:return s}}export{i as getOperation,$ as isPayloadSample,U as mergeInMockServer};
|
package/lib/models/types.d.ts
CHANGED
|
@@ -155,6 +155,7 @@ export type OperationModel = {
|
|
|
155
155
|
extensions: GenericObject;
|
|
156
156
|
isCallback: boolean;
|
|
157
157
|
isWebhook: boolean;
|
|
158
|
+
isAdditionalOperation: boolean;
|
|
158
159
|
isEvent: boolean;
|
|
159
160
|
callbackId: string;
|
|
160
161
|
requestBody?: RequestBodyModel;
|
|
@@ -186,6 +187,7 @@ export type GroupModel = {
|
|
|
186
187
|
isSchema?: boolean;
|
|
187
188
|
type: MenuItemGroupType;
|
|
188
189
|
deprecated?: boolean;
|
|
190
|
+
isAdditionalOperation?: boolean;
|
|
189
191
|
badges?: OpenAPIXBadges[];
|
|
190
192
|
items: ContentItemModel[];
|
|
191
193
|
ast?: Node[];
|
|
@@ -210,6 +212,7 @@ export type OperationMenuItem = {
|
|
|
210
212
|
httpVerb: string;
|
|
211
213
|
path: string;
|
|
212
214
|
isWebhook: boolean;
|
|
215
|
+
isAdditionalOperation: boolean;
|
|
213
216
|
operationId?: string;
|
|
214
217
|
badges?: OpenAPIXBadges[];
|
|
215
218
|
[REDOCLY_TEAMS_RBAC]?: Record<string, string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{IS_BROWSER as q,isObject as
|
|
1
|
+
import{IS_BROWSER as q,isObject as A,isString as E,isUndefined as o}from"@redocly/theme/core/openapi";import{tryDecodeURIComponent as B,getDefinitionName as v}from"../utils/index.js";import{JsonPointer as x}from"../utils/JsonPointer.js";import{normalizeOptions as W}from"./config-options/normalizeOptions.js";function S(m,e){return e&&m[m.length-1]!==e?[...m,e]:m}function R(m,e){return e?m.concat(e):m}class V{options;definitionUrl;definition;allowMergeRefs=!1;constructor(e,t,l=W({})){this.options=l,this.definition=Object.assign({},e),this.validate(e),this.definition=e,this.allowMergeRefs=e.openapi.startsWith("3.1");const n=q?window.location.href:"";E(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=B(e);try{t=x.get(this.definition,e)}catch{}return t||{}}};isRef(e){return e?(e=e,e.$ref!==void 0&&e.$ref!==null):!1}deref(e,t=[],l=!1,n=0){const i=e?.["x-refsStack"];if(t=R(t,i),n>5)return{resolved:Object.assign({},e,{"x-complex":!0}),refsStack:t};if(this.isRef(e)){const r=v(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,l,n).resolved),this.allowMergeRefs&&(s=this.mergeRefs(e,s,l)),{resolved:s,refsStack:s.isPureRef?t:S(t,e.$ref)}}return{resolved:e,refsStack:R(t,i)}}mergeRefs(e,t,l){const{$ref:n,...i}=e,r=Object.keys(i);if(r.length===0)return{...t,$ref:n,isPureRef:!0};if(l&&r.some(s=>!["description","title","externalDocs","x-refsStack","x-parentRefs","readOnly","writeOnly","x-complex"].includes(s))){const{description:s,title:p,readOnly:u,writeOnly:d,...O}=i;return{allOf:[{description:s,title:p,readOnly:u,writeOnly:d},t,O]}}else return{...t,...i}}mergeAllOf(e,t,l,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:x.join(n,["allOf"]),allOf:void 0,title:i===0?e.title||v(t):e.title};!o(r.properties)&&A(r.properties)&&(r.properties={...r.properties}),!o(r.items)&&A(r.items)&&(r.items={...r.items});const s=e.allOf.map((p,u)=>{const{resolved:d,refsStack:O}=this.deref(p,l,!0,i),f=p.$ref,y=f||x.join(n,[String(u)]);if(d["x-complex"])return{$ref:f,refsStack:S(O,f),schema:{"x-complex":!0},absolutePointer:y};const a=this.mergeAllOf(d,f,O,y,i+1);if(!(a["x-circular-ref"]&&a.allOf))return f&&r["x-parentRefs"]?.push(...a["x-parentRefs"]||[],f),{$ref:f,refsStack:S(O,f),schema:a,absolutePointer:y}}).filter(Boolean);for(const[p,{schema:u,refsStack:d,absolutePointer:O}]of s.entries()){const{type:f,enum:y,properties:a,items:I,required:w,title:b,description:D,readOnly:C,writeOnly:M,oneOf:$,anyOf:P,"x-circular-ref":g,"x-complex":k,...N}=u||{};if(!(r.type!==f&&!o(r.type)&&!o(f)&&!i)){if(o(f)||(Array.isArray(f)&&Array.isArray(r.type)?r.type=[...f,...r.type]:r.type=f),o(y)||(Array.isArray(y)&&Array.isArray(r.enum)?r.enum=Array.from(new Set([...y,...r.enum])):r.enum=y),!o(a)&&A(a)){r.properties=r.properties||{};for(const c in a){const h=R(d,a[c]?.["x-refsStack"]);if(!r.properties[c])r.properties[c]={...a[c],absolutePointer:x.join(O,["properties",c]),"x-refsStack":h};else if(!g){const U=this.mergeAllOf({allOf:[r.properties[c],a[c]],"x-refsStack":h},t+"/properties/"+c,h,x.join(O,["allOf",String(p),"properties",c]),i+1);r.properties[c]=U}}}if(!o(I)&&!g&&!k){const c=typeof r.items=="boolean"?{}:Object.assign({},r.items),h=typeof u.items=="boolean"?{}:Object.assign({},u.items);r.items=this.mergeAllOf({allOf:[c,h]},t+"/items",d,"",i+1)}o($)||(r.oneOf=$),o(P)||(r.anyOf=P),Array.isArray(w)&&(r.required=[...r.required||[],...w]),r={...r,title:r.title||b,description:r.description||D,readOnly:o(r.readOnly)?C:r.readOnly,writeOnly:o(r.writeOnly)?M:r.writeOnly,"x-circular-ref":r["x-circular-ref"]||g,"x-complex":r["x-complex"]||k,...N}}}return r}findDerived(e){const t={},l=this.definition.components&&this.definition.components.schemas||{};for(const n in l){const{resolved:i}=this.deref(l[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,...l}=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),p=t.slice(n+1),u=Object.keys(r).length>0?[r]:[];return{...l,oneOf:i.map(d=>({allOf:[...s,...u,d,...p]}))}}}return e}}export{V as OpenAPIParser,R as concatRefStacks,S as pushRef};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{REDOCLY_TEAMS_RBAC as r}from"@redocly/config";import{encodeBackSlashes as d,getOperationId as c,getOperationName as m}from"../../utils/index.js";function
|
|
1
|
+
import{REDOCLY_TEAMS_RBAC as r}from"@redocly/config";import{encodeBackSlashes as d,getOperationId as c,getOperationName as m}from"../../utils/index.js";function N(o,i,s){if(i.operations.length===0)return[];const n=[],a=[];for(const e of i.operations){const t=c(e,o),p={id:t,type:"operation",parent:o,operationDefinition:e,depth:s,name:m(e),httpVerb:e.httpVerb,path:e.pathName,items:[],isAdditionalOperation:e.isAdditionalOperation,isWebhook:e.isWebhook,operationId:e.operationId,badges:e["x-badges"]||[],href:b({id:t}),deprecated:!!e.deprecated,[r]:e[r]||o?.[r]};e.isWebhook?a.push(p):n.push(p)}return[...n.sort((e,t)=>Number(e.deprecated)-Number(t.deprecated)||Number(e.isAdditionalOperation)-Number(t.isAdditionalOperation)),...a.sort((e,t)=>Number(e.deprecated)-Number(t.deprecated))]}function b({id:o}){return d(`/${o}`.toLowerCase())}export{b as getHref,N as getOperationsItems};
|
|
@@ -25,4 +25,5 @@ export declare function getTagGroupsItems(parser: OpenAPIParser, parent: GroupMo
|
|
|
25
25
|
* collects tags and maps each tag to list of operations belonging to this tag
|
|
26
26
|
*/
|
|
27
27
|
export declare function getTagsWithOperations(parser: OpenAPIParser, explicitTags: OpenAPITag[]): TagsInfoMap;
|
|
28
|
+
export declare function processOperation(parser: OpenAPIParser, operationName: string, operationInfo: any, pathName: string, path: any, tags: TagsInfoMap, isWebhook?: boolean, isAdditionalOperation?: boolean): void;
|
|
28
29
|
export declare function capitalize(input: string): string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{getTagOrGroup as d}from"../../models/group.js";import{DEFAULT_WEBHOOKS_TAG_NAME as l,GROUP_DEPTH as
|
|
2
|
-
{% mcp${t.slice(0,-1)} toolName="${i.name}" id="${
|
|
1
|
+
import{getTagOrGroup as d}from"../../models/group.js";import{DEFAULT_WEBHOOKS_TAG_NAME as l,GROUP_DEPTH as u}from"../../constants.js";import{getValueFromMdParsedExtension as g,isOperationName as w,JsonPointer as $,safeSlugify as k}from"../../utils/index.js";import{getOperationsItems as h}from"./operation.js";import{addMarkdownItems as T}from"./markdown.js";import{joinWithSeparator as b}from"../history/helpers.js";const x=["tools"];function v(s,f,n,o,r){let t;if(o===void 0?t=Object.keys(f):t=o.tags,!Array.isArray(t))return console.warn("Unexpected values of tags. Check tags or x-tagGroups in your definition."),[];const a=t.map(e=>f[e]?(f[e].used=!0,f[e]):(console.warn(`Non-existing tag "${e}" is added to the group "${o?.name}"`),null)),i=[];for(const e of a){if(!e)continue;const c=d("tag",e,n);if(c.depth=u+1,e.name===""){const S=[...T(g(e,"description")||"",c,c.depth+1),...h(void 0,e,c.depth+1)];i.push(...S);continue}const p=A({definition:s.definition,tag:e,parent:c,schemaDefinitionsTagName:r.schemaDefinitionsTagName}),P=E(s.definition,e,c);c.items=[...p,...P,...T(g(e,"description")||"",c,c.depth+1),...h(c,e,c.depth+1)],i.push(c)}return i.filter(({name:e,items:c})=>e!==l||c.length>0)}function I(s,f,n,o,r){const t=[];for(const a of n){const i=d("group",a,f);i.depth=u,i.items=v(s,o,i,a,r),t.push(i)}return t}function A({definition:s,tag:f,parent:n,schemaDefinitionsTagName:o}){const r=o?[o]:[];return Object.entries(s.components?.schemas||{}).map(([t,a])=>{if(!(a["x-tags"]||r).includes(f.name))return null;const e=d("schema",{name:t,"x-displayName":`${a.title||t}`,description:`{% schemaDefinition showWriteOnly="true" schemaRef="#/components/schemas/${t}" /%}`,isSchema:!0,level:2},n);return e.depth=n.depth+1,e}).filter(Boolean)}function E(s,f,n){const o=[];for(const r of x)if(s["x-mcp"]?.[r]){const t=y(r),a=[t];for(const i of s["x-mcp"]?.[r]||[])if((i.tags?.length?i.tags:a).includes(f.name)){const c=b(n.id,k(i.name)),p=d("mcp",{name:i.name,"x-displayName":i.title||i.name,description:`${i.description||""}
|
|
2
|
+
{% mcp${t.slice(0,-1)} toolName="${i.name}" id="${c}" /%}`,isSchema:!0,level:2},n);p.depth=n.depth+1,o.push(p)}}return o}function M(s,f){const{definition:n}=s,o={},r=n["x-webhooks"]||n.webhooks,t=n["x-mcp"];for(const a of f||[])o[a.name]={...a,operations:[]};return n.paths&&m(s,n.paths,o),r&&m(s,r,o,!0),t&&j(t,o),o}function j(s,f){for(const n of x)if(s[n])for(const o of s[n]){const r=o.tags&&o.tags.length?o.tags:[y(n)];for(const t of r){let a=f[t];a===void 0&&(a={name:t,operations:[],used:!0},f[t]=a)}}}function O(s,f,n,o,r,t,a,i){if(r.$ref){const{resolved:c}=s.deref(r);m(s,{[o]:c},t,a);return}let e=n?.tags;(!e||!e.length)&&(e=a?[l]:[""]);for(const c of e){let p=t[c];p===void 0&&(p={name:c,operations:[]},t[c]=p),!p["x-traitTag"]&&p.operations.push({...n,pathName:o,pointer:$.compile(["paths",o,f]),httpVerb:f,pathParameters:r.parameters||[],pathServers:r.servers,isWebhook:!!a,isAdditionalOperation:!!i,keywords:n["x-keywords"]})}}function m(s,f,n,o){for(const r of Object.keys(f||{})){const t=f[r],a=Object.keys(t).filter(w);for(const i of a){const e=t[i];O(s,i,e,r,t,n,o)}if(t.additionalOperations)for(const[i,e]of Object.entries(t.additionalOperations))O(s,i,e,r,t,n,o,!0)}}function y(s){return s.charAt(0).toUpperCase()+s.slice(1)}export{y as capitalize,I as getTagGroupsItems,v as getTagsItems,M as getTagsWithOperations,O as processOperation};
|
package/lib/services/types.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ export interface IMenuItem {
|
|
|
29
29
|
items: IMenuItem[];
|
|
30
30
|
parent?: IMenuItem;
|
|
31
31
|
deprecated?: boolean;
|
|
32
|
+
isAdditionalOperation?: boolean;
|
|
32
33
|
type: MenuItemType;
|
|
33
34
|
isSchema?: boolean;
|
|
34
35
|
httpVerb?: string;
|
|
@@ -50,6 +51,7 @@ export type ExtendedOpenAPIOperation = {
|
|
|
50
51
|
pathParameters: Array<Referenced<OpenAPIParameter>>;
|
|
51
52
|
pathServers: Array<OpenAPIServer> | undefined;
|
|
52
53
|
isWebhook: boolean;
|
|
54
|
+
isAdditionalOperation: boolean;
|
|
53
55
|
defaultSampleName?: string | false;
|
|
54
56
|
keywords?: unknown;
|
|
55
57
|
} & OpenAPIOperation;
|
package/lib/types/open-api.d.ts
CHANGED
|
@@ -81,6 +81,7 @@ export interface OpenAPIPath extends Partial<OpenAPIRef>, ParsedDescriptionWithS
|
|
|
81
81
|
head?: OpenAPIOperation;
|
|
82
82
|
patch?: OpenAPIOperation;
|
|
83
83
|
trace?: OpenAPIOperation;
|
|
84
|
+
additionalOperations?: Record<string, OpenAPIOperation>;
|
|
84
85
|
servers?: OpenAPIServer[];
|
|
85
86
|
parameters?: Array<Referenced<OpenAPIParameter>>;
|
|
86
87
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/openapi-docs",
|
|
3
|
-
"version": "3.16.0-next.
|
|
3
|
+
"version": "3.16.0-next.4",
|
|
4
4
|
"description": "Redocly OpenAPI Docs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -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.19.0-next.
|
|
39
|
+
"@redocly/config": "0.39.0",
|
|
40
|
+
"@redocly/replay": "0.19.0-next.4"
|
|
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.60.0-next.
|
|
78
|
+
"@redocly/theme": "0.60.0-next.3"
|
|
79
79
|
},
|
|
80
80
|
"scripts": {
|
|
81
81
|
"start": "npm run copy-highlight-hook && vite",
|
|
@@ -86,7 +86,8 @@
|
|
|
86
86
|
"prepare:community-source-only": "npm run prepare:community-source --ignore /src/* private-readme.md",
|
|
87
87
|
"prepare:community-dependencies": "npx tsx scripts/prepare-community-dependencies.ts",
|
|
88
88
|
"apply:community-source": "npx tsx scripts/apply-changes-from-community-source.ts",
|
|
89
|
-
"test": "jest -w 2",
|
|
89
|
+
"test": "npm run prepare:community-source && npm run redoc:use-workspace && npm run test:redoc && npm run redoc:revert-workspace && jest -w 2",
|
|
90
|
+
"test:redoc": "cd redoc && pnpm install && npm run lint && npm run unit",
|
|
90
91
|
"unit": "jest -w 2",
|
|
91
92
|
"test:update": "jest -u",
|
|
92
93
|
"test:watch": "jest --watch",
|
|
@@ -100,6 +101,8 @@
|
|
|
100
101
|
"license:check": "npx license-checker --production --onlyAllow 'MIT;ISC;Apache-2.0;Apache;CC0-1.0;BSD;BSD-2-Clause;BSD-3-Clause;UNKNOWN' --summary",
|
|
101
102
|
"precdn:serve": "mkdir -p playground/cdn-test/server-dist && cp -Rf dist/* playground/cdn-test/server-dist && cp -Rf playground/cdn-test/template-source/* playground/cdn-test/server-dist",
|
|
102
103
|
"cdn-serve": "http-server playground/cdn-test/server-dist",
|
|
103
|
-
"copy-highlight-hook": "cp -r ../portal/src/client/app/hooks/codeHighlight ./playground/hooks"
|
|
104
|
+
"copy-highlight-hook": "cp -r ../portal/src/client/app/hooks/codeHighlight ./playground/hooks",
|
|
105
|
+
"redoc:use-workspace": "node scripts/use-workspace-deps.js",
|
|
106
|
+
"redoc:revert-workspace": "node scripts/use-workspace-deps.js revert"
|
|
104
107
|
}
|
|
105
108
|
}
|