@redocly/api-docs 0.2.0-next.5 → 0.2.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/lib/RedocStandalone.d.ts +38 -0
- package/lib/RedocStandalone.js +1 -0
- package/lib/RedoclyApiDocs.js +1 -1
- package/lib/RedoclyApiDocsStandalone.d.ts +2 -0
- package/lib/adapters/asyncapi/items/overview/content.js +1 -1
- package/lib/adapters/graphql/utils/createApiItem.js +1 -1
- package/lib/adapters/openapi/build-code-sample-source.d.ts +1 -1
- package/lib/adapters/openapi/build-code-sample-source.js +1 -1
- package/lib/adapters/openapi/configure/merge-utils.d.ts +1 -1
- package/lib/adapters/openapi/index.js +1 -1
- package/lib/adapters/openapi/items/operation/content.js +1 -1
- package/lib/adapters/openapi/items/operation/item.js +1 -1
- package/lib/adapters/openapi/items/overview/content.js +1 -1
- package/lib/adapters/openapi/utils/merge-mock-server.d.ts +2 -2
- package/lib/adapters/utils/markdoc.d.ts +4 -1
- package/lib/adapters/utils/markdoc.js +1 -1
- package/lib/components/ErrorBoundary.d.ts +4 -2
- package/lib/components/ErrorBoundary.js +1 -1
- package/lib/components/Header/HeaderItem.js +1 -1
- package/lib/components/ItemContent/sections/MessagesSection.js +1 -1
- package/lib/components/Schema/styled.js +4 -4
- package/lib/components/Schema/views/ArrayRenderer.js +1 -1
- package/lib/components/Search/index.d.ts +15 -0
- package/lib/components/Search/index.js +1 -0
- package/lib/components/Security/styled.js +7 -7
- package/lib/components/StickySidebar/FloatingButton.d.ts +1 -0
- package/lib/components/StickySidebar/FloatingButton.js +32 -0
- package/lib/components/StickySidebar/RedoclyAttributionLogo.d.ts +5 -0
- package/lib/components/StickySidebar/RedoclyAttributionLogo.js +1 -0
- package/lib/components/StickySidebar/StickySidebar.js +33 -9
- package/lib/components/common/Breadcrumbs.js +2 -2
- package/lib/components/common/ResponseCodeTabs.js +1 -1
- package/lib/components/common/Tag.js +1 -1
- package/lib/components/common/ViewNested.js +2 -2
- package/lib/components/graphql/GraphQLFieldView.js +1 -1
- package/lib/components/graphql/RequiresScopesModal.js +3 -3
- package/lib/components/graphql/sections/GraphQLArgsSection.js +1 -1
- package/lib/components/panels/ExampleItem/CodeSampleItem.js +1 -1
- package/lib/components/panels/ExampleItem/SecuritySchemeSelector.d.ts +9 -0
- package/lib/components/panels/ExampleItem/SecuritySchemeSelector.js +1 -0
- package/lib/components/panels/ExampleItem/ServerDropdown.js +1 -1
- package/lib/components/panels/ExampleItem/generate-request-sample.d.ts +28 -0
- package/lib/components/panels/ExampleItem/generate-request-sample.js +1 -0
- package/lib/components/panels/ExampleItem/styled.d.ts +1 -49
- package/lib/components/panels/ExampleItem/useActiveServer.d.ts +17 -0
- package/lib/components/panels/ExampleItem/useActiveServer.js +1 -0
- package/lib/components/panels/ExampleItem/useCodeSampleLanguages.d.ts +23 -0
- package/lib/components/panels/ExampleItem/useCodeSampleLanguages.js +1 -0
- package/lib/components/panels/ExampleItem/useReplayRequestState.d.ts +18 -0
- package/lib/components/panels/ExampleItem/useReplayRequestState.js +1 -0
- package/lib/components/panels/ExampleItem/useTryItFooter.d.ts +3 -0
- package/lib/components/panels/ExampleItem/useTryItFooter.js +7 -0
- package/lib/components/panels/GroupPanelItem.js +1 -1
- package/lib/components/panels/McpPanelItem.js +2 -2
- package/lib/components/panels/ServerItem/ServerItem.js +1 -1
- package/lib/components/panels/asyncapi/BrokerItem/BrokerModal.js +1 -1
- package/lib/components/panels/asyncapi/BrokerItem/BrokerPanelItem.js +1 -1
- package/lib/components/panels/shared-panel-styles.js +1 -1
- package/lib/hoc/withStoreProvider.js +1 -1
- package/lib/hooks/useInitialTelemetry.d.ts +2 -0
- package/lib/hooks/useInitialTelemetry.js +1 -0
- package/lib/hooks/useScrollSpyUrlSync.js +1 -1
- package/lib/index.d.ts +3 -0
- package/lib/index.js +1 -1
- package/lib/jotai/app.d.ts +6 -0
- package/lib/jotai/app.js +1 -1
- package/lib/jotai/examples.js +1 -1
- package/lib/options/editionOverrides.d.ts +3 -0
- package/lib/options/editionOverrides.js +1 -0
- package/lib/options/helpers.d.ts +1 -1
- package/lib/options/normalizeOptions.d.ts +1 -1
- package/lib/options/normalizeOptions.js +1 -1
- package/lib/pages/ItemPage.js +4 -2
- package/lib/services/code-samples/apply-env-variables.d.ts +8 -0
- package/lib/services/code-samples/apply-env-variables.js +1 -0
- package/lib/services/code-samples/builder.js +1 -1
- package/lib/services/code-samples/language-availability.d.ts +4 -0
- package/lib/services/code-samples/language-availability.js +1 -0
- package/lib/services/code-samples/{replay/normalize-servers.d.ts → normalize-servers.d.ts} +1 -1
- package/lib/services/code-samples/normalize-servers.js +1 -0
- package/lib/services/code-samples/replay/from-openapi-document.js +1 -1
- package/lib/services/code-samples/replay/replay-predefined-env.d.ts +1 -2
- package/lib/services/code-samples/replay/replay-predefined-env.js +1 -1
- package/lib/services/code-samples/server-env.d.ts +3 -0
- package/lib/services/code-samples/server-env.js +1 -0
- package/lib/services/code-samples/source.d.ts +3 -3
- package/lib/services/operation-samples/index.js +1 -1
- package/lib/services/search/indexer.d.ts +9 -0
- package/lib/services/search/indexer.js +1 -0
- package/lib/services/search/types.d.ts +27 -0
- package/lib/services/search/types.js +0 -0
- package/lib/standalone.d.ts +19 -0
- package/lib/standalone.js +2 -0
- package/lib/standaloneThemeConfig.d.ts +3 -0
- package/lib/standaloneThemeConfig.js +1 -0
- package/lib/telemetry/RedocTelemetry.d.ts +3 -0
- package/lib/telemetry/RedocTelemetry.js +1 -1
- package/lib/telemetry/defaults.d.ts +2 -0
- package/lib/telemetry/defaults.js +1 -0
- package/lib/types/code-samples-config.d.ts +68 -0
- package/lib/types/code-samples-config.js +0 -0
- package/lib/types/common.d.ts +1 -1
- package/lib/types/content.d.ts +2 -1
- package/lib/types/edition-config.d.ts +4 -0
- package/lib/types/edition-config.js +0 -0
- package/lib/types/events.d.ts +2 -2
- package/lib/types/openapi.d.ts +2 -1
- package/lib/types/options.d.ts +27 -85
- package/lib/utils/deep-link.d.ts +1 -0
- package/lib/utils/deep-link.js +1 -1
- package/lib/utils/extract-extensions.js +1 -1
- package/lib/utils/x-logo.d.ts +13 -0
- package/lib/utils/x-logo.js +1 -0
- package/package.json +19 -7
- package/lib/services/code-samples/replay/normalize-servers.js +0 -1
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ReactElement, ReactNode } from 'react';
|
|
2
|
+
import type { ApiItem, ApiStore } from './types/store.js';
|
|
3
|
+
import type { ApiSpecType } from './types/common.js';
|
|
4
|
+
import type { RawApiDocsOptions } from './types/options.js';
|
|
5
|
+
import type { RedocTelemetryConfig } from './telemetry/RedocTelemetry.js';
|
|
6
|
+
import type { MarkdownAdapter } from './contexts/markdownAdapter.js';
|
|
7
|
+
import type { RedoclyApiDocsStandaloneProps } from './RedoclyApiDocsStandalone.js';
|
|
8
|
+
type RedocStandaloneProps = {
|
|
9
|
+
/** Parsed definition object, or a GraphQL SDL string when `specType` is `graphql`. */
|
|
10
|
+
definition?: Record<string, unknown> | string;
|
|
11
|
+
/** URL to fetch the definition from. Ignored when `definition` is provided. */
|
|
12
|
+
definitionUrl?: string;
|
|
13
|
+
/** Detected automatically when omitted (`.graphql`/`.gql` URL or document shape). */
|
|
14
|
+
specType?: ApiSpecType;
|
|
15
|
+
options?: Partial<RawApiDocsOptions>;
|
|
16
|
+
basePath?: string;
|
|
17
|
+
logo?: RedoclyApiDocsStandaloneProps['logo'];
|
|
18
|
+
markdownAdapter?: MarkdownAdapter;
|
|
19
|
+
telemetryConfig?: Partial<RedocTelemetryConfig>;
|
|
20
|
+
onLoaded?: (error?: Error) => void;
|
|
21
|
+
/** Rendered while the definition is loading. */
|
|
22
|
+
children?: ReactNode;
|
|
23
|
+
};
|
|
24
|
+
type PreparedApiDocs = {
|
|
25
|
+
items: ApiItem[];
|
|
26
|
+
store: ApiStore;
|
|
27
|
+
options: RawApiDocsOptions;
|
|
28
|
+
specType: ApiSpecType;
|
|
29
|
+
/** Bundled definition (OpenAPI/AsyncAPI only) — used for search deep links. */
|
|
30
|
+
document?: Record<string, unknown>;
|
|
31
|
+
};
|
|
32
|
+
export declare function detectSpecType({ definition, definitionUrl, specType, }: Pick<RedocStandaloneProps, 'definition' | 'definitionUrl' | 'specType'>): ApiSpecType | undefined;
|
|
33
|
+
declare function prepareApiDocs({ definition, definitionUrl, specType, options, basePath, }: Pick<RedocStandaloneProps, 'definition' | 'definitionUrl' | 'specType' | 'options' | 'basePath'>): Promise<PreparedApiDocs>;
|
|
34
|
+
/** Loads and bundles the definition, builds the item model, and renders `RedoclyApiDocsStandalone`. */
|
|
35
|
+
declare const RedocStandalone: ({ definition, definitionUrl, specType, options, basePath, logo, markdownAdapter, telemetryConfig, onLoaded, children, }: RedocStandaloneProps) => ReactElement | null;
|
|
36
|
+
export { RedocStandalone, prepareApiDocs };
|
|
37
|
+
export type { RedocStandaloneProps };
|
|
38
|
+
export default RedocStandalone;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Fragment as h,jsx as A,jsxs as E}from"react/jsx-runtime";import{useEffect as S,useMemo as j,useState as P}from"react";import{RedoclyApiDocsStandalone as I}from"./RedoclyApiDocsStandalone.js";import{buildItems as T}from"./adapters/build.js";import{markdocParser as v}from"./components/markdoc/markdocParser.js";import{loadAndBundleDefinition as D}from"./utils/loadAndBundleSpec.js";import{logoFromDefinition as F}from"./utils/x-logo.js";import{apiSpecType as s}from"./types/common.js";const G=/\.(graphql|gql)([?#]|$)/i;function H({definition:e,definitionUrl:t,specType:n}){if(n)return n;if(typeof e=="string"||G.test(t??""))return s.GRAPHQL;if(e&&typeof e=="object")return"asyncapi"in e?s.ASYNCAPI:s.OPENAPI}async function L({definition:e,definitionUrl:t,specType:n}){if(e===void 0&&t===void 0)throw new Error('Either "definition" or "definitionUrl" must be provided');const a=H({definition:e,definitionUrl:t,specType:n});if(a===s.GRAPHQL){const p=typeof e=="string"?e:await(await fetch(t)).text(),{parse:c}=await import("graphql");return{document:c(p),type:s.GRAPHQL}}const o=await D(e??t),r=a??(o&&typeof o=="object"&&"asyncapi"in o?s.ASYNCAPI:s.OPENAPI);return{document:o,type:r}}async function g({definition:e,definitionUrl:t,specType:n,options:a={},basePath:o="/"}){const r=await L({definition:e,definitionUrl:t,specType:n}),p={specType:r.type,metadata:{type:r.type},...a},{items:c,store:m}=await T({type:r.type,document:r.document,options:p,basePath:o,markdownParser:v});return{items:c,store:m,options:p,specType:r.type,document:r.type===s.GRAPHQL?void 0:r.document}}const w=({definition:e,definitionUrl:t,specType:n,options:a,basePath:o="/",logo:r,markdownAdapter:p,telemetryConfig:c,onLoaded:m,children:R})=>{const[i,l]=P(null),[f,y]=P(null),x=j(()=>({typeOfUsage:"react",...c}),[c]);return S(()=>{let d=!1;return l(null),y(null),g({definition:e,definitionUrl:t,specType:n,options:a,basePath:o}).then(u=>{d||(l(u),m?.())}).catch(u=>{d||(y(u),m?.(u))}),()=>{d=!0}},[e,t,n,o]),f?E("div",{role:"alert",style:{padding:"1em",fontFamily:"monospace",color:"#e53e3e"},children:["Failed to load API definition: ",f.message]}):i?A(I,{items:i.items,store:i.store,basePath:o,options:i.options,logo:r??F(i.document),markdownAdapter:p,telemetryConfig:x,definition:i.document}):A(h,{children:R??null})};var Y=w;export{w as RedocStandalone,Y as default,H as detectSpecType,g as prepareApiDocs};
|
package/lib/RedoclyApiDocs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as o,jsxs as f}from"react/jsx-runtime";import{memo as T,useMemo as v}from"react";import{useAtomValue as S}from"jotai";import{GlobalStyle as x}from"@redocly/theme/core/openapi";import{RedocTelemetry as R}from"./telemetry/RedocTelemetry.js";import{TelemetryContext as b}from"./contexts/telemetry.js";import{MarkdownAdapterProvider as P}from"./contexts/markdownAdapter.js";import{specTypeAtom as A}from"./jotai/store.js";import{useApiDocsRoutes as U}from"./hooks/useApiDocsRoutes.js";import{useVisitedChannelsTracker as w}from"./hooks/useVisitedChannelsTracker.js";import{useRouterHashBridge as C}from"./hooks/useRouterHashBridge.js";import{useScrollSpyUrlSync as D}from"./hooks/useScrollSpyUrlSync.js";import{useTelemetryPageMetrics as V}from"./hooks/useTelemetryPageMetrics.js";import{useInitialTelemetry as j}from"./hooks/useInitialTelemetry.js";import{EntryPage as I}from"./pages/EntryPage.js";import{ErrorBoundary as k}from"./components/ErrorBoundary.js";import{compose as B}from"./utils/compose.js";import{withRouter as M}from"./hoc/withRouter.js";import{withStoreProvider as N}from"./hoc/withStoreProvider.js";import{withReplayPrefetch as O}from"./hoc/withReplayPrefetch.js";const d=r=>{const{items:t=[],basePath:s,markdownAdapter:y,telemetryConfig:e}=r,{routeIndex:g}=U(t,s),m=S(A),c=e?.specType,i=e?.collectorUrl,p=e?.serviceName,n=e?.serviceVersion,l=e?.disabled,a=e?.typeOfUsage,h=v(()=>new R({specType:c??m,collectorUrl:i,serviceName:p,serviceVersion:n,disabled:l,typeOfUsage:a}),[m,c,i,p,n,l,a]);return o(P,{value:y,children:f(b.Provider,{value:h,children:[o(E,{}),o(H,{routeIndex:g,basePath:s})]})})};function E(){return w(),C(),D(),null}const H=({routeIndex:r,basePath:t})=>(V(),j(),f(k,{children:[o(x,{}),o(I,{routeIndex:r,basePath:t})]})),u=B(N,M,T,r=>O(r,{respectHideReplay:!0}))(d);var ce=u;export{u as RedoclyApiDocs,d as RedoclyApiDocsComponent,ce as default};
|
|
@@ -11,6 +11,8 @@ type RedoclyApiDocsStandaloneProps = {
|
|
|
11
11
|
logo?: RawLogo;
|
|
12
12
|
telemetryConfig?: Partial<RedocTelemetryConfig>;
|
|
13
13
|
markdownAdapter?: MarkdownAdapter;
|
|
14
|
+
/** Bundled definition — consumed only by the community fork (search `$ref` resolution). */
|
|
15
|
+
definition?: Record<string, unknown>;
|
|
14
16
|
};
|
|
15
17
|
declare const RedoclyApiDocsStandalone: import("react").FC<any>;
|
|
16
18
|
export { RedoclyApiDocsStandalone };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{extractContentUntilFirstHeading as u}from"../../../utils/markdoc.js";import{parseMarkdown as T}from"../../../utils/parseMarkdown.js";import{contentType as h,nodeTypes as n}from"../../../../types/common.js";import{buildDownloadPanelContent as C}from"../../panels/download.js";import{buildOverviewPanelContent as R}from"../../panels/overview.js";import{buildBrokersPanelContent as v}from"../../panels/brokers.js";import{buildInfoMetadataContentNode as I}from"../../../utils/infoMetadata.js";function V({document:t,options:o,protocol:a,sectionChildren:p,basePath:s}){const e=t.info,c=u(e?.description,o),f=[C(o.downloadUrls??[]),R(e),...t.servers?[v(t.servers,a,o)]:[]],r={nodeType:n.OVERVIEW_SECTION_WRAPPER,children:[{nodeType:n.HEADER,showPageActions:!0,level:1,label:`${e?.title??""} ${e?.version??""}`.trim()}],sectionId:s};c?.length&&r.children.push({nodeType:n.OVERVIEW_SECTION_WRAPPER,children:[{nodeType:n.MARKDOC,content:c}],sectionId:s});const i=e?.externalDocs;if(i?.url){const m=T(i.description,o)??[];r.children.push({nodeType:n.EXTERNAL_DOCS,url:i.url,description:m})}const l=I(e,o.hideInfoMetadata)
|
|
1
|
+
import{extractContentUntilFirstHeading as u}from"../../../utils/markdoc.js";import{parseMarkdown as T}from"../../../utils/parseMarkdown.js";import{contentType as h,nodeTypes as n}from"../../../../types/common.js";import{buildDownloadPanelContent as C}from"../../panels/download.js";import{buildOverviewPanelContent as R}from"../../panels/overview.js";import{buildBrokersPanelContent as v}from"../../panels/brokers.js";import{buildInfoMetadataContentNode as I}from"../../../utils/infoMetadata.js";function V({document:t,options:o,protocol:a,sectionChildren:p,basePath:s}){const e=t.info,c=u(e?.description,o),f=[C(o.downloadUrls??[]),R(e),...t.servers?[v(t.servers,a,o)]:[]],r={nodeType:n.OVERVIEW_SECTION_WRAPPER,children:[{nodeType:n.HEADER,showPageActions:!0,level:1,label:`${e?.title??""} ${e?.version??""}`.trim()}],sectionId:s};c?.length&&r.children.push({nodeType:n.OVERVIEW_SECTION_WRAPPER,children:[{nodeType:n.MARKDOC,content:c}],sectionId:s});const i=e?.externalDocs;if(i?.url){const m=T(i.description,o)??[];r.children.push({nodeType:n.EXTERNAL_DOCS,url:i.url,description:m})}const d=[r],l=I(e,o.hideInfoMetadata);l&&d.push(l),d.push(...p);const E={nodeType:n.CONTAINER,panels:f,children:d};return{contentType:h.OVERVIEW,children:[E]}}export{V as buildOverviewContent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{itemVariant as n}from"../../../types/common.js";import{safeSlugify as d}from"../../../utils/string.js";import{joinWithSeparator as f
|
|
1
|
+
import{itemVariant as n}from"../../../types/common.js";import{safeSlugify as d}from"../../../utils/string.js";import{joinWithSeparator as f}from"../../../utils/url.js";import{normalizePath as m,toRelativePath as C}from"../../../utils/url.js";import{shouldIncludeItem as a}from"../utils/shouldIncludeItem.js";import{appendGraphqlItemFeedback as s}from"./appendGraphqlItemFeedback.js";import{buildDirectiveContent as I}from"../items/directive/content.js";import{buildQueryContent as T}from"../items/query/content.js";import{buildMutationContent as b}from"../items/mutation/content.js";import{buildSubscriptionContent as N}from"../items/subscription/content.js";import{buildUnionContent as E}from"../items/union/content.js";import{buildEnumContent as p}from"../items/enum/content.js";import{buildScalarContent as h}from"../items/scalar/content.js";import{buildInputContent as P}from"../items/input/content.js";import{buildObjectContent as S}from"../items/object/content.js";import{buildInterfaceContent as U}from"../items/interface/content.js";import{graphqlContext as A}from"../buildContext.js";const R={[n.QUERY]:"queries",[n.MUTATION]:"mutations",[n.SUBSCRIPTION]:"subscriptions",[n.DIRECTIVE]:"directives",[n.OBJECT]:"objects",[n.INTERFACE]:"interfaces",[n.UNION]:"unions",[n.ENUM]:"enums",[n.INPUT]:"inputs",[n.SCALAR]:"scalars"};function z(t){const e=A.get(),r=`${t.variant}:${t.name}`;if(t.processedItems?.has(r)||(t.filter||t.menuCommonFilter)&&!a(t.name,t.filter,t.menuCommonFilter))return null;const o=t.parentPath?t.parentPath:f(e.basePath,R[t.variant]),u=f(o,d(t.name.toLowerCase())),l=t.label??t.name;if(t.processedItems?.add(r),!e.processContent)return{type:"link",label:l,link:u,routeSlug:u,...t.deprecated&&{deprecated:!0},content:null};let i=g({variant:t.variant,source:t.source,name:t.name,markdownOptions:e.options});e.options.feedback?.hide!==!0&&i&&(i=s(i,m(C(u,e.basePath))));const c=v(t.source);return c&&i?.meta&&(i.meta.position=c),{type:"link",label:l,link:u,routeSlug:u,...t.deprecated&&{deprecated:!0},content:i}}function g({variant:t,source:e,name:r,markdownOptions:o}){switch(t){case n.DIRECTIVE:return I(e,o);case n.QUERY:return T(e,r,o);case n.MUTATION:return b(e,r,o);case n.SUBSCRIPTION:return N(e,r,o);case n.UNION:return E(e,o);case n.ENUM:return p(e,o);case n.SCALAR:return h(e,o);case n.INPUT:return P(e,o);case n.OBJECT:return S(e,o);case n.INTERFACE:return U(e,o);default:return}}function v(t){const e=t?.astNode?.loc;if(e?.startToken)return{start:{lineNumber:e.startToken.line,column:e.startToken.column},end:e.endToken?{lineNumber:e.endToken.line,column:e.endToken.column}:void 0}}export{z as createApiItem};
|
|
@@ -2,4 +2,4 @@ import type { OperationInfo } from '../../types/openapi.js';
|
|
|
2
2
|
import type { StoreContext } from '../../types/store.js';
|
|
3
3
|
import type { ApiDocsOptions } from '../../types/options.js';
|
|
4
4
|
import type { CodeSampleSource } from '../../services/code-samples/index.js';
|
|
5
|
-
export declare function buildCodeSampleSource(operationInfo: OperationInfo, storeCtx: StoreContext,
|
|
5
|
+
export declare function buildCodeSampleSource(operationInfo: OperationInfo, storeCtx: StoreContext, ignoreNamedSchemas?: Set<string>, isWebhook?: boolean, href?: string, options?: ApiDocsOptions): CodeSampleSource;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{REDOCLY_TEAMS_RBAC as w}from"@redocly/config";import{registerExample as O,pickRenderableDescription as M,registerSchema as R,resolveContent as A,resolveRef as S,readRbacScope as q,rbacProp as P}from"../helpers.js";import{panelKind as T,schemaKind as j}from"../../types/common.js";import{isStatusCode as C}from"../../utils/status-code.js";import{encodeJsonPointerSegment as B}from"../../utils/refPointer.js";import{applyIgnoreNamedSchemasDeep as U}from"./utils/applyIgnoreNamedSchemasDeep.js";import{
|
|
1
|
+
import{REDOCLY_TEAMS_RBAC as w}from"@redocly/config";import{registerExample as O,pickRenderableDescription as M,registerSchema as R,resolveContent as A,resolveRef as S,readRbacScope as q,rbacProp as P}from"../helpers.js";import{panelKind as T,schemaKind as j}from"../../types/common.js";import{isStatusCode as C}from"../../utils/status-code.js";import{encodeJsonPointerSegment as B}from"../../utils/refPointer.js";import{applyIgnoreNamedSchemasDeep as U}from"./utils/applyIgnoreNamedSchemasDeep.js";import{pickOperationServers as L}from"./utils/merge-mock-server.js";import{mergeInMockServer as _}from"./utils/merge-mock-server.js";import{mergeSecurityIntoScheme as E}from"./configure/merge-utils.js";import{hasOpenApiExampleValue as $,resolveOpenApiExampleValue as g}from"./resolve-openapi-example-value.js";function D(r,n,a){const u=S(n,r,a)??r;return U(u,a)}function te(r,n,a,u,l,i){const s=n?.document??{},m=F(r,s,i),t=K(r,s,n,a),e=N(r,n),o=G(r,s,n,a),y=J(r),c=r.responses,p=c?Object.keys(c).filter(C):void 0,f=r.security;return{kind:T.CODE_SAMPLE,operationType:u?"webhook":"http",method:r.httpVerb?.toUpperCase()??"GET",path:r.pathName??"/",servers:m,parameters:t,security:e,requestBody:o,responseCodes:p,requestValues:y,pointer:r.pathName,...l&&{href:l},...r.operationId&&{openApiOperationId:r.operationId},...r.summary&&{summary:r.summary},...f&&f.length>1&&{securityGroups:f}}}function F(r,n,a){const u=n.servers;let l=L(r.servers,u);l=_(l.filter(s=>typeof s?.url=="string"),a?.mockServer);const i=l.map(s=>({url:s.url??"",name:s.name,description:typeof s.description=="string"?s.description:void 0,...s.isMockServer&&{isMockServer:!0},variables:s.variables&&Object.keys(s.variables).length>0?Object.fromEntries(Object.entries(s.variables).map(([m,t])=>[m,{default:t.default,enum:t.enum}])):void 0}));return i.length>0?i:[{url:"/"}]}function K(r,n,a,u){const i=(r.parameters??[]).map(t=>D(t,n,u)),s={path:[],query:[],querystring:[],header:[],cookie:[]},m=r.requestValues?.serverRequestValues;for(const t of i){const e=t.in;if(!e||!s[e])continue;const o=t.content,y=o?Object.keys(o)[0]:void 0,c=y&&o?o[y]?.schema:t.schema,p=c&&typeof c=="object"?S(n,c,u)??c:c;let f;p&&a&&(f=R(a.schemaStore,a.hashIndex,{kind:j.JSON_SCHEMA,data:p}));const V=p&&typeof p=="object"&&"example"in p?p.example:void 0;let v;if(t.examples&&typeof t.examples=="object")for(const d of Object.values(t.examples)){if(!d||typeof d!="object")continue;const x=S(n,d,u)??d;if($(x)){v=g(x);break}}const b={};if(m&&t.name)for(const[d,x]of Object.entries(m)){const k=x?.[e==="querystring"?"queryString":e==="header"?"headers":e==="cookie"?"cookies":e]?.[t.name];k!=null&&(b[d]={example:k})}s[e].push({name:t.name??"",in:e,required:t.required,example:t.example??v??V,schemaId:f,serializationMime:y,style:t.style,explode:t.explode,...Object.keys(b).length>0&&{serverValues:b}})}return s}function N(r,n){const a=r.requestValues?.security,u=r.requestValues?.serverRequestValues,l=r.security,i=[];if(!l||!n)return i;for(const s of l){const m=Object.keys(s),t=m.map(e=>n.securitySchemeStore[e]).filter(Boolean).map(e=>{let o={id:e.id,type:e.type,name:e.paramName,in:e.in,scheme:e.scheme,bearerFormat:e.bearerFormat,openIdConnectUrl:e.openIdConnectUrl,flows:e.flows,"x-defaultClientId":e["x-defaultClientId"],"x-defaultAccessToken":e["x-defaultAccessToken"],"x-defaultTokenType":e["x-defaultTokenType"],"x-defaultClientSecret":e["x-defaultClientSecret"],"x-defaultUsername":e["x-defaultUsername"],"x-defaultPassword":e["x-defaultPassword"],serverValues:e.serverValues?{...e.serverValues}:void 0};if(a&&(o=E(o,a)),u)for(const[y,c]of Object.entries(u))c?.security&&(o=E(o,c.security,y));return o});if(t.length>0){const e=m.flatMap(o=>s[o]??[]);i.push({schemes:t,scopes:e})}}return i}function G(r,n,a,u){const l=r.requestBody,i=l?S(n,l,u)??l:void 0,s=A(n,i,u);if(!s||!a)return;const m={};for(const[t,e]of Object.entries(s)){let o;const y=e.itemSchema,c=e.schema??y;if(c){const V=S(n,c,u)??c;o=R(a.schemaStore,a.hashIndex,{kind:j.JSON_SCHEMA,data:V})}const p=r.pointer?`${r.pointer}/requestBody/content/${B(t)}`.replace(/^\//,""):void 0,f=[];if(e.example!==void 0&&f.push(O(a.exampleStore,{value:e.example,...p&&{id:`${p}/example`}})),e.examples){const V=q(e.examples);for(const[v,b]of Object.entries(e.examples)){if(v===w)continue;const d=S(n,b,u);if(d){const x=q(b)??q(d)??V,h=O(a.exampleStore,{value:g(d),key:v,summary:typeof d.summary=="string"?d.summary:v,description:M(d.description),externalValue:typeof d.externalValue=="string"?d.externalValue:void 0,...P(x),...p&&{id:`${p}/examples/${B(v)}`}});f.push(h)}}}m[t]={schemaId:o,...f.length>0&&{exampleIds:f}}}return m}function J(r){const n=r.requestValues?.serverRequestValues,a=r.requestValues?.envVariables;let u,l;if(a&&typeof a=="object")if("values"in a){const t=a;u=t.values,l=t.serverValues}else u=a;const i=r.requestValues?.body;let s;if(n)for(const[t,e]of Object.entries(n))e?.body!==void 0&&(s=s??{},s[t]=e.body),e?.envVariables&&(l=l??{},l[t]={...l[t],...e.envVariables});return u||l||r.requestValues?.security||i!==void 0||s?{...r.requestValues?.security&&{security:r.requestValues.security},...u&&{envVariables:u},...l&&{serverEnvVariables:l},...i!==void 0&&{body:i},...s&&{serverBody:s}}:void 0}export{te as buildCodeSampleSource};
|
|
@@ -21,7 +21,7 @@ export declare function mergeSecurityIntoScheme<S extends SchemeForCredentials>(
|
|
|
21
21
|
serverValues: Record<string, SecuritySchemeCredentials>;
|
|
22
22
|
};
|
|
23
23
|
export declare function applyServerVariableDefaults(servers: OpenAPIServer[] | undefined, serverVariables: Record<string, string> | undefined, targetServerUrl?: string): void;
|
|
24
|
-
/** Immutable variant of {@link applyServerVariableDefaults} for
|
|
24
|
+
/** Immutable variant of {@link applyServerVariableDefaults} for runtime callers that must not mutate. */
|
|
25
25
|
export declare function withServerVariableDefaults<T extends {
|
|
26
26
|
url: string;
|
|
27
27
|
variables?: Record<string, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createStoreContext as s,toRecord as l}from"../helpers.js";import{populateOpenApiStore as p}from"./store.js";import{createBuildContext as u}from"./build/context.js";import{buildOverviewItems as
|
|
1
|
+
import{createStoreContext as s,toRecord as l}from"../helpers.js";import{populateOpenApiStore as p}from"./store.js";import{createBuildContext as u}from"./build/context.js";import{buildOverviewItems as S}from"./items/overview/item.js";import{addTagItems as f}from"./group/item.js";import{openApiContext as c}from"./buildContext.js";import{mergeInMockServer as v}from"./utils/merge-mock-server.js";import{toSidebarLogo as g}from"../../utils/logo.js";function x(){return new Promise(r=>setTimeout(r,0))}function d(r,t){let o=(r.servers??[]).filter(e=>typeof e?.url=="string");return o=v(o,t.mockServer),o.map(e=>({url:e.url,...e.name&&{name:e.name},...e.isMockServer&&{isMockServer:!0},...typeof e.description=="string"&&e.description&&{description:e.description},...e.variables&&Object.keys(e.variables).length>0&&{variables:e.variables}}))}async function M({document:r,basePath:t="/",options:i,processContent:o=!0}){const e=s(l(r));o&&(p(r,e,i),await x());const m=u({document:r,options:i,basePath:t,storeCtx:e,processContent:o}),n=d(r,i),a=g(r.info?.["x-logo"],r.info?.contact?.url);return c.run(m,()=>({items:b(),store:{schemaStore:e.schemaStore,exampleStore:e.exampleStore,securitySchemeStore:e.securitySchemeStore,mcp:e.document["x-mcp"],schemaCatalogLink:r["x-schema-catalog-link"],...n.length>0&&{servers:n},...a&&{logo:a}}}))}function b(){const r=c.get(),t=[...S(r.document)];return f(r.document,t),t}export{b as buildOpenApiItems,M as processOpenApiDocument};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{REDOCLY_TEAMS_RBAC as U}from"@redocly/config";import{contentType as le,itemVariant as me,nodeTypes as f,panelKind as Y,schemaKind as B}from"../../../../types/common.js";import{readRbacScope as E,rbacProp as A,registerExample as J,pickRenderableDescription as ee,registerSchema as H,resolveContent as z,resolveRef as P}from"../../../helpers.js";import{applyIgnoreNamedSchemasDeep as te}from"../../utils/applyIgnoreNamedSchemasDeep.js";import{isStatusCode as ue}from"../../../../utils/status-code.js";import{parseMarkdown as K}from"../../../utils/parseMarkdown.js";import{extractDescriptionSegments as ye,resolveMarkdocHeadingIds as W}from"../../../utils/markdoc.js";import{getExtensionsForDisplay as G}from"../../../../utils/extract-extensions.js";import{openApiContext as $}from"../../buildContext.js";import{buildCodeSampleSource as he}from"../../build-code-sample-source.js";import{mergeInMockServer as fe,pickOperationServers as be}from"../../utils/merge-mock-server.js";import{normalizePath as xe,toRelativePath as se}from"../../../../utils/url.js";import{encodeJsonPointerSegment as N}from"../../../../utils/refPointer.js";import{hasOpenApiExampleValue as ne,resolveOpenApiExampleValue as Z}from"../../resolve-openapi-example-value.js";const Q="request",re="responses",oe="callbacks";function Se(){const e=new Map;return(r,s)=>{const o=`${r}/${s}`,n=e.get(o)??0;return e.set(o,n+1),n===0?o:`${o}~${n}`}}function Le(e,r){const{options:s,storeCtx:o,basePath:n}=$.get(),t=e.summary||e.operationId||e.pathName||"Unknown Operation",c=[],{feedback:l}=s,i=e.isWebhook||!1,p=[{nodeType:f.HEADER,level:2,label:t,badges:e["x-badges"],isWebhook:i,deprecated:e.deprecated,showPageActions:!0}],a=G(e,s.showExtensions);Object.keys(a).length>0&&p.push({nodeType:f.EXTENSIONS,extensions:a}),c.push({nodeType:f.CONTAINER,children:p,panels:[]});const u=s.ignoreNamedSchemas,h=e["x-codeSamples"]?.map(({lang:m,label:v,source:D})=>({lang:m,label:v,source:D})),b=be(e.servers,o?.document?.servers),x=fe(b.filter(m=>typeof m?.url=="string"),s.mockServer).map(m=>{const v=E(m);return{url:m.url??"",name:m.name,description:typeof m.description=="string"?m.description:void 0,...m.isMockServer&&{isMockServer:!0},variables:m.variables&&Object.keys(m.variables).length>0?Object.fromEntries(Object.entries(m.variables).map(([D,L])=>[D,{default:L.default}])):void 0,...A(v)}}),y=ce(e,u),S=se(r,n);let d=[];e.description&&(W(e.description,S,Q),d=ye(e.description,s));const g=d.some(m=>m.kind==="schemaDefinition"),T=y.find(m=>m.nodeType===f.ITEM&&m.variant==="body"),C=ve(e,u,i,S||void 0),q=T?.schemaId,R=T?.mediaTypes,k=T?.mediaTypeSchemas,M=E(T),O=[{children:[{kind:Y.CODE_SAMPLE,source:C,definitionSamples:h?.length?h:void 0,isWebhook:i,hideReplay:e["x-hideReplay"]===!0,servers:x?.length?x:void 0,schemaId:q,exampleIds:T?.exampleIds,mediaTypes:R,mediaTypeSchemas:k,examples:T?.exampleIds?.map(()=>({}))??[]}],...A(M)}];if(y.length>0||d.length>0)if(g){c.push({nodeType:f.CONTAINER,children:[{nodeType:f.HEADER,level:4,label:"Request",labelTranslationKey:"request",deepLinkSuffix:Q}],panels:[]});for(const m of d)m.kind==="schemaDefinition"?c.push(m.node):c.push({nodeType:f.CONTAINER,children:[m.node],panels:[]});c.push({nodeType:f.CONTAINER,children:[...y],panels:O})}else c.push({nodeType:f.CONTAINER,children:[{nodeType:f.HEADER,level:4,label:"Request",labelTranslationKey:"request",deepLinkSuffix:Q},...d.map(m=>m.node),...y],panels:O});else c.push({nodeType:f.CONTAINER,children:[{nodeType:f.HEADER,level:4,label:"Request",labelTranslationKey:"request",deepLinkSuffix:Q},{nodeType:f.EMPTY_MESSAGE,label:"No request data",labelTranslationKey:"noRequestData"}],panels:O});if(e.responses){const m=ae(e,s,S,u);if(m){const v=m.responses?.some(j=>j.schemaId||(j.exampleIds?.length??0)>0),D=m?.responses?.map(j=>{const pe=j[U];return{code:j.code,schemaId:j.schemaId,exampleIds:j.exampleIds,mediaTypes:j.mediaTypes,mediaTypeContent:j.mediaTypeContent,...A(pe)}}),L=[];v&&L.push({children:[{kind:Y.RESPONSE,headerTitle:"Response",responseCodes:D,examples:[]}]});const de=E(e.responses);c.push({nodeType:f.CONTAINER,children:[{nodeType:f.HEADER,level:4,label:"Responses",labelTranslationKey:"responses",deepLinkSuffix:"responses"},m],panels:L.length>0?L:[],...A(de)})}}Array.isArray(e.callbacks)&&e.callbacks.length>0&&c.push(...Te(e,S,u)),l?.hide!==!0&&c.push({nodeType:f.CONTAINER,children:[{nodeType:f.FEEDBACK,pageSlug:xe(se(r,n))}],panels:[]});const _=y.some(m=>{const v=m;return v.variant==="body"&&((v.exampleIds?.length??0)>0||!!v.schemaId)})||(h?.length??0)>0;return{contentType:le.ITEM,itemVariant:me.HTTP_ITEM,seo:e["x-seo"],meta:{sourceId:e.operationId,name:t,deprecated:e.deprecated,isWebhook:e.isWebhook||!1,pointer:e.pointer,hasSamples:_},children:c}}function Te(e,r,s){const o=[{nodeType:f.CONTAINER,children:[{nodeType:f.HEADER,level:4,label:"Callbacks",labelTranslationKey:"callbacks",deepLinkSuffix:oe}],panels:[]}],n=Se();for(const t of e.callbacks??[])if(t.operations)for(const c of t.operations){const l=c.httpVerb??"post",i=n(t.name,l);o.push(Ee(e,t,c,i,r,s))}return o}function Ee(e,r,s,o,n,t){const{options:c}=$.get(),l=s.httpVerb??"post",i={pointer:e.pointer+"/callbacks/"+r.name+"/"+l,pathName:s.pathName??r.url??"",httpVerb:l,summary:s.summary,deprecated:s.deprecated,isWebhook:!1,isAdditionalOperation:!1,tags:[],parameters:s.parameters,requestBody:s.requestBody,responses:s.responses,servers:s.servers,security:s.security},p=ce(i,t),a=ae(i,c,`${n}/callbacks/${o}`,t),u=[...p];a&&u.push(a);const h=s.externalDocs,b=G(s,c.showExtensions);let x;s.description&&(x=K(s.description,c),W(x??[],n,`${oe}/${o}`));const y={httpVerb:l,pathName:i.pathName,summary:i.summary,operationId:typeof s.operationId=="string"?s.operationId:void 0,description:x,deprecated:i.deprecated,callbackName:r.name,callbackId:o,externalDocs:h?{url:h.url,description:h.description}:void 0,extensions:Object.keys(b).length>0?b:void 0,contentChildren:u.length>0?u:void 0},S=Ce(s,i,o,t),d=E(r);return{nodeType:f.CONTAINER,children:[{nodeType:f.ITEM,variant:"callback",callback:y,pointer:e.pointer+"/callbacks"}],panels:S,...A(d)}}function Ce(e,r,s,o){const{storeCtx:n}=$.get(),t=[];if(!e.requestBody||!("content"in e.requestBody))return t;const c=n?.document??{},l=P(c,e.requestBody,o)??e.requestBody,i=z(c,l,o);if(!i)return t;const p=Object.keys(i);let a=!1;const u={};for(const[y,S]of Object.entries(i)){let d;if(S.schema){const C=S.schema;d=H(n.schemaStore,n.hashIndex,{kind:B.JSON_SCHEMA,data:C})}const g=`${r.pointer}/requestBody/content/${N(y)}`.replace(/^\//,""),T=[];if(S.example!==void 0){const C=J(n.exampleStore,{value:S.example,id:`${g}/example`});T.push(C),a=!0}if(S.examples)for(const[C,q]of Object.entries(S.examples)){const R=P(c,q,o);if(R&&ne(R)){const k=J(n.exampleStore,{value:Z(R),summary:R.summary??C,description:ee(R.description),id:`${g}/examples/${N(C)}`});T.push(k),a=!0}}u[y]={schemaId:d,exampleIds:T.length>0?T:void 0},d&&(a=!0)}const h=e["x-codeSamples"];if(!(a||(h?.length??0)>0))return t;const x=e.servers?.filter(y=>y.url).map(({url:y,name:S,description:d,variables:g})=>({url:y,name:S,description:d,variables:g}));return t.push({children:[{kind:Y.CALLBACK_PAYLOAD,callbackName:s,path:r.pathName,httpVerb:r.httpVerb,servers:x?.length?x:void 0,definitionSamples:h,mediaTypes:p.length>0?p:void 0,mediaTypeSchemas:Object.keys(u).length>0?u:void 0,examples:[]}]}),t}function ge(e,r,s){const o=P(r,e,s)??e,{$ref:n,...t}=e,c=typeof n=="string"?{...o,...t}:o;return te(c,s)}function V(e,r,s){if(!e||typeof e!="object")return;const o=e,n=P(r,o,s)??o;return te(n,s)}function Re(e,r,s){if(!e||typeof e!="object")return;const o=E(e),n={},t=[];for(const[c,l]of Object.entries(e)){if(c===U)continue;const i=P(r,l,s)??l,p=i.content,a=p?p[Object.keys(p)[0]]:void 0,u=i.schema??a?.schema??a?.itemSchema,h=V(u,r,s);if(!h)continue;const b=ie(i.examples,r,s),x=E(l)??E(i)??o;n[c]={...h,...i.description!==void 0&&{description:i.description},...i.example!==void 0&&{example:i.example},...b&&{examples:b},...A(x)},i.required&&t.push(c)}if(Object.keys(n).length!==0)return{type:"object",properties:n,...t.length>0?{required:t}:{}}}function Oe(e){if(typeof e=="string"||e&&typeof e=="object"&&"$$mdtype"in e||Array.isArray(e)&&e.length>0&&e.every(r=>!!r&&typeof r=="object"&&"$$mdtype"in r))return e}function F(e,r){const{storeCtx:s,options:o}=$.get(),n=s.document;return e.map(t=>{const c=t.schema;let l={};if(c&&typeof c=="object")l=c;else if(t.content&&typeof t.content=="object"){const b=t.content,x=Object.keys(b)[0],y=x?b[x]?.schema:void 0;y&&typeof y=="object"&&(l=y)}const i=H(s.schemaStore,s.hashIndex,{kind:B.JSON_SCHEMA,data:l}),p=t["x-badges"],a=l["x-badges"],u=Array.isArray(p)?p:Array.isArray(a)?a:void 0,h=G(t,o.showExtensions);return{name:String(t.name??""),in:typeof t.in=="string"?t.in:void 0,schemaId:i,description:Oe(t.description),required:t.required===!0?!0:void 0,deprecated:t.deprecated===!0?!0:void 0,example:t.example,examples:ie(t.examples,n,r),...u?.length?{badges:u}:{},...Object.keys(h).length?{extensions:h}:{},...A(E(t))}})}function ie(e,r,s){if(!e||typeof e!="object")return;const o={};for(const[n,t]of Object.entries(e)){if(!t||typeof t!="object")continue;const c=P(r,t,s)??t;if(!ne(c))continue;const l=Z(c);o[n]={...typeof c.summary=="string"&&{summary:c.summary},...typeof c.description=="string"&&{description:c.description},...l!==void 0&&{value:typeof l=="string"?l:JSON.stringify(l)}}}return Object.keys(o).length>0?o:void 0}function ce(e,r){const{storeCtx:s,options:o}=$.get(),n=[],t=s.document,c=Ae(e);if(c&&n.push(c),e.parameters&&Array.isArray(e.parameters)){const i=e.parameters.map(d=>ge(d,t,r)),p=i.filter(d=>d.in==="header"),a=i.filter(d=>d.in==="query"),u=i.filter(d=>d.in==="path"),h=i.filter(d=>d.in==="cookie"),b=i.filter(d=>d.in==="querystring"),x=b.filter(d=>!d.content||typeof d.content!="object"),y=b.filter(d=>d.content&&typeof d.content=="object"),S=b.length>0;u.length>0&&n.push({nodeType:f.ITEM,variant:"path",label:"Path",labelTranslationKey:"path",parameters:F(u,r),pointer:e.pointer+"/parameters"}),a.length>0&&!S&&n.push({nodeType:f.ITEM,variant:"query",label:"Query",labelTranslationKey:"query",parameters:F(a,r),pointer:e.pointer+"/parameters"}),x.length>0&&n.push({nodeType:f.ITEM,variant:"querystring",label:"Query String",labelTranslationKey:"querystring",parameters:F(x,r),pointer:e.pointer+"/parameters"});for(const d of y){const g=d.content,T=Object.keys(g),C={};for(const M of T){const O=g[M];if(!O)continue;let I;const w=O.itemSchema,_=O.schema??w,m=V(_,t,r);m&&(I=H(s.schemaStore,s.hashIndex,{kind:B.JSON_SCHEMA,data:m}));const v=X(O,r);C[M]={schemaId:I,exampleIds:v,...A(E(_))}}const q=T[0],R=q?C[q]:void 0,k=K(d.description,o);n.push({nodeType:f.ITEM,variant:"querystring-body",label:String(d.name??""),required:d.required===!0?!0:void 0,mediaTypes:T.length>0?T:void 0,mediaTypeSchemas:Object.keys(C).length>0?C:void 0,schemaId:R?.schemaId,exampleIds:R?.exampleIds,pointer:e.pointer+"/parameters",...k!==void 0?{description:k}:{},...A(E(d))})}h.length>0&&n.push({nodeType:f.ITEM,variant:"cookies",label:"Cookies",labelTranslationKey:"cookie",parameters:F(h,r),pointer:e.pointer+"/parameters"}),p.length>0&&n.push({nodeType:f.ITEM,variant:"headers",label:"Headers",labelTranslationKey:"header",parameters:F(p,r),pointer:e.pointer+"/parameters"})}if(e.requestBody){const l=P(t,e.requestBody,r)??e.requestBody,i=z(t,l,r),p=i?Object.keys(i):void 0;let a,u,h;if(i&&p){h={};for(const d of p){const g=i[d];if(!g)continue;let T;const C=g.itemSchema,q=g.schema??C,R=V(q,t,r);R&&(T=H(s.schemaStore,s.hashIndex,{kind:B.JSON_SCHEMA,data:R}));const k=X(g,r,`${e.pointer}/requestBody/content/${N(d)}`);h[d]={schemaId:T,exampleIds:k,...A(E(q))}}const y=p[0],S=y?h[y]:void 0;a=S?.schemaId,u=S?.exampleIds}const b=K(l.description,o),x=E(e.requestBody)??E(l);n.push({nodeType:f.ITEM,variant:"body",label:"Request Body",labelTranslationKey:"body",required:l.required,mediaTypes:p,mediaTypeSchemas:h,schemaId:a,exampleIds:u,pointer:e.pointer+"/requestBody",...b!==void 0?{description:b}:{},...A(x)})}return n}function ae(e,r,s,o){if(!e.responses)return;const{storeCtx:n}=$.get(),t=n?.document??{},c=e.responses,i=Object.entries(c).filter(([p])=>ue(p)).map(([p,a])=>{const u=P(t,a,o)??a;let h=E(a)??E(u);const b=z(t,u,o),x=b?Object.keys(b):[],y=x[0],S=y&&b?b[y]:void 0;let d,g,T,C;if(b&&x.length>0){C={};for(const O of x){const I=b[O];if(!I)continue;let w;const _=I.itemSchema,m=I.schema??_,v=V(m,t,o);v&&(w=H(n.schemaStore,n.hashIndex,{kind:B.JSON_SCHEMA,data:v}));const D=X(I,o,`${e.pointer}/responses/${N(p)}/content/${N(O)}`);C[O]={schemaId:w,exampleIds:D,...A(E(m))}}const M=y?C[y]:void 0;d=M?.schemaId,g=M?.exampleIds}else if(S){const M=S.itemSchema,O=S.schema??M,I=V(O,t,o);I&&(h=h??E(O),d=H(n.schemaStore,n.hashIndex,{kind:B.JSON_SCHEMA,data:I})),g=X(S,o,y?`${e.pointer}/responses/${N(p)}/content/${N(y)}`:void 0)}const q=Re(u.headers,t,o);q&&(T=H(n.schemaStore,n.hashIndex,{kind:B.JSON_SCHEMA,data:q}));let R;u.description&&(R=K(u.description,r),W(R??[],s,`${re}/${p}`));const k=u["x-summary"]?K(u["x-summary"],r):void 0;return k&&W(k,s,`${re}/${p}/summary`),{code:p,summary:k,description:R,mediaType:y,mediaTypes:x.length>0?x:void 0,mediaTypeContent:C,schemaId:d,exampleIds:g,headers:u.headers,headerSchemaId:T,...A(h)}});return{nodeType:f.ITEM,variant:"responses",responses:i,pointer:e.pointer+"/responses"}}function X(e,r,s){const{storeCtx:o}=$.get(),n=[],t=o.document,c=s?.replace(/^\//,"");if(e.example!==void 0){const l=J(o.exampleStore,{value:e.example,...c&&{id:`${c}/example`}});n.push(l)}if(e.examples&&typeof e.examples=="object"){const l=E(e.examples);for(const[i,p]of Object.entries(e.examples)){if(i===U||!p||typeof p!="object")continue;const a=P(t,p,r)??p,u=E(p)??E(a)??l,h=J(o.exampleStore,{value:Z(a),key:i,summary:typeof a.summary=="string"?a.summary:i,description:ee(a.description),externalValue:typeof a.externalValue=="string"?a.externalValue:void 0,...A(u),...c&&{id:`${c}/examples/${N(i)}`}});n.push(h)}}return n.length>0?n:void 0}function Ae(e){const{storeCtx:r,options:s}=$.get();if(!e.security||!Array.isArray(e.security)||e.security.length===0)return;const o=e.security.map(n=>{const t=Object.entries(n);if(t.length===0)return null;const c=r?.document?.components?.securitySchemes,l=t.map(([i,p])=>{const a=r?.securitySchemeStore[i],u=E(c?.[i])??a?.[U];return{name:i,scopes:Array.isArray(p)?p:void 0,type:a?.type,scheme:a?.scheme,bearerFormat:a?.bearerFormat,in:a?.in,paramName:a?.paramName,description:a?.description?K(a.description,s):a?.description,openIdConnectUrl:a?.openIdConnectUrl,oauth2MetadataUrl:a?.oauth2MetadataUrl,deprecated:a?.deprecated,flows:a?.flows,...A(u)}}).filter(i=>i.name);return l.length>0?{schemes:l}:null}).filter(n=>n!==null);if(o.length!==0)return{nodeType:f.SECURITY,requirements:o}}function ve(e,r,s,o){const{storeCtx:n,options:t}=$.get();if(!n)throw new Error("OpenAPI store context is not initialized");return he(e,n,t,r,s,o)}export{Le as buildItemContent,Se as createCallbackIdFactory};
|
|
1
|
+
import{REDOCLY_TEAMS_RBAC as J}from"@redocly/config";import{contentType as me,itemVariant as ue,nodeTypes as h,panelKind as z,schemaKind as B}from"../../../../types/common.js";import{readRbacScope as C,rbacProp as O,registerExample as W,pickRenderableDescription as te,registerSchema as H,resolveContent as G,resolveRef as $}from"../../../helpers.js";import{applyIgnoreNamedSchemasDeep as se}from"../../utils/applyIgnoreNamedSchemasDeep.js";import{isStatusCode as ye}from"../../../../utils/status-code.js";import{parseMarkdown as _}from"../../../utils/parseMarkdown.js";import{extractDescriptionSegments as he,resolveMarkdocHeadingIds as Q}from"../../../utils/markdoc.js";import{getExtensionsForDisplay as Z}from"../../../../utils/extract-extensions.js";import{openApiContext as M}from"../../buildContext.js";import{buildCodeSampleSource as fe}from"../../build-code-sample-source.js";import{pickOperationServers as be}from"../../utils/merge-mock-server.js";import{mergeInMockServer as xe}from"../../utils/merge-mock-server.js";import{normalizePath as Se}from"../../../../utils/url.js";import{toRelativePath as ne}from"../../../../utils/url.js";import{encodeJsonPointerSegment as N}from"../../../../utils/refPointer.js";import{hasOpenApiExampleValue as re,resolveOpenApiExampleValue as ee}from"../../resolve-openapi-example-value.js";const X="request",oe="responses",ie="callbacks";function Te(){const e=new Map;return(r,s)=>{const o=`${r}/${s}`,n=e.get(o)??0;return e.set(o,n+1),n===0?o:`${o}~${n}`}}function Ue(e,r){const{options:s,storeCtx:o,basePath:n}=M.get(),t=e.summary||e.operationId||e.pathName||"Unknown Operation",c=[],{feedback:l}=s,i=e.isWebhook||!1,p=[{nodeType:h.HEADER,level:2,label:t,badges:e["x-badges"],isWebhook:i,deprecated:e.deprecated,showPageActions:!0}],a=Z(e,s.showExtensions);Object.keys(a).length>0&&p.push({nodeType:h.EXTENSIONS,extensions:a}),c.push({nodeType:h.CONTAINER,children:p,panels:[]});const m=s.ignoreNamedSchemas,y=e["x-codeSamples"]?.map(({lang:u,label:I,source:L})=>({lang:u,label:I,source:L}));let b=be(e.servers,o?.document?.servers).filter(u=>typeof u?.url=="string");b=xe(b,s.mockServer);const f=b.map(u=>{const I=C(u);return{url:u.url??"",name:u.name,description:typeof u.description=="string"?u.description:void 0,...u.isMockServer&&{isMockServer:!0},variables:u.variables&&Object.keys(u.variables).length>0?Object.fromEntries(Object.entries(u.variables).map(([L,V])=>[L,{default:V.default}])):void 0,...O(I)}}),x=ae(e,m),d=ne(r,n);let E=[];e.description&&(Q(e.description,d,X),E=he(e.description,s));const g=E.some(u=>u.kind==="schemaDefinition"),S=x.find(u=>u.nodeType===h.ITEM&&u.variant==="body"),q=qe(e,m,i,d||void 0),R=S?.schemaId,k=S?.mediaTypes,j=S?.mediaTypeSchemas,v=C(S),A=[{children:[{kind:z.CODE_SAMPLE,source:q,definitionSamples:y?.length?y:void 0,isWebhook:i,hideReplay:e["x-hideReplay"]===!0,servers:f?.length?f:void 0,schemaId:R,exampleIds:S?.exampleIds,mediaTypes:k,mediaTypeSchemas:j,examples:S?.exampleIds?.map(()=>({}))??[]}],...O(v)}];if(x.length>0||E.length>0)if(g){c.push({nodeType:h.CONTAINER,children:[{nodeType:h.HEADER,level:4,label:"Request",labelTranslationKey:"request",deepLinkSuffix:X}],panels:[]});for(const u of E)u.kind==="schemaDefinition"?c.push(u.node):c.push({nodeType:h.CONTAINER,children:[u.node],panels:[]});c.push({nodeType:h.CONTAINER,children:[...x],panels:A})}else c.push({nodeType:h.CONTAINER,children:[{nodeType:h.HEADER,level:4,label:"Request",labelTranslationKey:"request",deepLinkSuffix:X},...E.map(u=>u.node),...x],panels:A});else c.push({nodeType:h.CONTAINER,children:[{nodeType:h.HEADER,level:4,label:"Request",labelTranslationKey:"request",deepLinkSuffix:X},{nodeType:h.EMPTY_MESSAGE,label:"No request data",labelTranslationKey:"noRequestData"}],panels:A});if(e.responses){const u=de(e,s,d,m);if(u){const I=u.responses?.some(P=>P.schemaId||(P.exampleIds?.length??0)>0),L=u?.responses?.map(P=>{const le=P[J];return{code:P.code,schemaId:P.schemaId,exampleIds:P.exampleIds,mediaTypes:P.mediaTypes,mediaTypeContent:P.mediaTypeContent,...O(le)}}),V=[];I&&V.push({children:[{kind:z.RESPONSE,headerTitle:"Response",responseCodes:L,examples:[]}]});const pe=C(e.responses);c.push({nodeType:h.CONTAINER,children:[{nodeType:h.HEADER,level:4,label:"Responses",labelTranslationKey:"responses",deepLinkSuffix:"responses"},u],panels:V.length>0?V:[],...O(pe)})}}Array.isArray(e.callbacks)&&e.callbacks.length>0&&c.push(...Ee(e,d,m)),l?.hide!==!0&&c.push({nodeType:h.CONTAINER,children:[{nodeType:h.FEEDBACK,pageSlug:Se(ne(r,n))}],panels:[]});const D=x.some(u=>{const I=u;return I.variant==="body"&&((I.exampleIds?.length??0)>0||!!I.schemaId)})||(y?.length??0)>0;return{contentType:me.ITEM,itemVariant:ue.HTTP_ITEM,seo:e["x-seo"],meta:{sourceId:e.operationId,name:t,deprecated:e.deprecated,isWebhook:e.isWebhook||!1,pointer:e.pointer,hasSamples:D},children:c}}function Ee(e,r,s){const o=[{nodeType:h.CONTAINER,children:[{nodeType:h.HEADER,level:4,label:"Callbacks",labelTranslationKey:"callbacks",deepLinkSuffix:ie}],panels:[]}],n=Te();for(const t of e.callbacks??[])if(t.operations)for(const c of t.operations){const l=c.httpVerb??"post",i=n(t.name,l);o.push(Ce(e,t,c,i,r,s))}return o}function Ce(e,r,s,o,n,t){const{options:c}=M.get(),l=s.httpVerb??"post",i={pointer:e.pointer+"/callbacks/"+r.name+"/"+l,pathName:s.pathName??r.url??"",httpVerb:l,summary:s.summary,deprecated:s.deprecated,isWebhook:!1,isAdditionalOperation:!1,tags:[],parameters:s.parameters,requestBody:s.requestBody,responses:s.responses,servers:s.servers,security:s.security},p=ae(i,t),a=de(i,c,`${n}/callbacks/${o}`,t),m=[...p];a&&m.push(a);const y=s.externalDocs,T=Z(s,c.showExtensions);let b;s.description&&(b=_(s.description,c),Q(b??[],n,`${ie}/${o}`));const f={httpVerb:l,pathName:i.pathName,summary:i.summary,operationId:typeof s.operationId=="string"?s.operationId:void 0,description:b,deprecated:i.deprecated,callbackName:r.name,callbackId:o,externalDocs:y?{url:y.url,description:y.description}:void 0,extensions:Object.keys(T).length>0?T:void 0,contentChildren:m.length>0?m:void 0},x=ge(s,i,o,t),d=C(r);return{nodeType:h.CONTAINER,children:[{nodeType:h.ITEM,variant:"callback",callback:f,pointer:e.pointer+"/callbacks"}],panels:x,...O(d)}}function ge(e,r,s,o){const{storeCtx:n}=M.get(),t=[];if(!e.requestBody||!("content"in e.requestBody))return t;const c=n?.document??{},l=$(c,e.requestBody,o)??e.requestBody,i=G(c,l,o);if(!i)return t;const p=Object.keys(i);let a=!1;const m={};for(const[f,x]of Object.entries(i)){let d;if(x.schema){const S=x.schema;d=H(n.schemaStore,n.hashIndex,{kind:B.JSON_SCHEMA,data:S})}const E=`${r.pointer}/requestBody/content/${N(f)}`.replace(/^\//,""),g=[];if(x.example!==void 0){const S=W(n.exampleStore,{value:x.example,id:`${E}/example`});g.push(S),a=!0}if(x.examples)for(const[S,q]of Object.entries(x.examples)){const R=$(c,q,o);if(R&&re(R)){const k=W(n.exampleStore,{value:ee(R),summary:R.summary??S,description:te(R.description),id:`${E}/examples/${N(S)}`});g.push(k),a=!0}}m[f]={schemaId:d,exampleIds:g.length>0?g:void 0},d&&(a=!0)}const y=e["x-codeSamples"];if(!(a||(y?.length??0)>0))return t;const b=e.servers?.filter(f=>f.url).map(({url:f,name:x,description:d,variables:E})=>({url:f,name:x,description:d,variables:E}));return t.push({children:[{kind:z.CALLBACK_PAYLOAD,callbackName:s,path:r.pathName,httpVerb:r.httpVerb,servers:b?.length?b:void 0,definitionSamples:y,mediaTypes:p.length>0?p:void 0,mediaTypeSchemas:Object.keys(m).length>0?m:void 0,examples:[]}]}),t}function Re(e,r,s){const o=$(r,e,s)??e,{$ref:n,...t}=e,c=typeof n=="string"?{...o,...t}:o;return se(c,s)}function F(e,r,s){if(!e||typeof e!="object")return;const o=e,n=$(r,o,s)??o;return se(n,s)}function Oe(e,r,s){if(!e||typeof e!="object")return;const o=C(e),n={},t=[];for(const[c,l]of Object.entries(e)){if(c===J)continue;const i=$(r,l,s)??l,p=i.content,a=p?p[Object.keys(p)[0]]:void 0,m=i.schema??a?.schema??a?.itemSchema,y=F(m,r,s);if(!y)continue;const T=ce(i.examples,r,s),b=C(l)??C(i)??o;n[c]={...y,...i.description!==void 0&&{description:i.description},...i.example!==void 0&&{example:i.example},...T&&{examples:T},...O(b)},i.required&&t.push(c)}if(Object.keys(n).length!==0)return{type:"object",properties:n,...t.length>0?{required:t}:{}}}function Ae(e){if(typeof e=="string"||e&&typeof e=="object"&&"$$mdtype"in e||Array.isArray(e)&&e.length>0&&e.every(r=>!!r&&typeof r=="object"&&"$$mdtype"in r))return e}function U(e,r){const{storeCtx:s,options:o}=M.get(),n=s.document;return e.map(t=>{const c=t.schema;let l={};if(c&&typeof c=="object")l=c;else if(t.content&&typeof t.content=="object"){const T=t.content,b=Object.keys(T)[0],f=b?T[b]?.schema:void 0;f&&typeof f=="object"&&(l=f)}const i=H(s.schemaStore,s.hashIndex,{kind:B.JSON_SCHEMA,data:l}),p=t["x-badges"],a=l["x-badges"],m=Array.isArray(p)?p:Array.isArray(a)?a:void 0,y=Z(t,o.showExtensions);return{name:String(t.name??""),in:typeof t.in=="string"?t.in:void 0,schemaId:i,description:Ae(t.description),required:t.required===!0?!0:void 0,deprecated:t.deprecated===!0?!0:void 0,example:t.example,examples:ce(t.examples,n,r),...m?.length?{badges:m}:{},...Object.keys(y).length?{extensions:y}:{},...O(C(t))}})}function ce(e,r,s){if(!e||typeof e!="object")return;const o={};for(const[n,t]of Object.entries(e)){if(!t||typeof t!="object")continue;const c=$(r,t,s)??t;if(!re(c))continue;const l=ee(c);o[n]={...typeof c.summary=="string"&&{summary:c.summary},...typeof c.description=="string"&&{description:c.description},...l!==void 0&&{value:typeof l=="string"?l:JSON.stringify(l)}}}return Object.keys(o).length>0?o:void 0}function ae(e,r){const{storeCtx:s,options:o}=M.get(),n=[],t=s.document,c=ve(e);if(c&&n.push(c),e.parameters&&Array.isArray(e.parameters)){const i=e.parameters.map(d=>Re(d,t,r)),p=i.filter(d=>d.in==="header"),a=i.filter(d=>d.in==="query"),m=i.filter(d=>d.in==="path"),y=i.filter(d=>d.in==="cookie"),T=i.filter(d=>d.in==="querystring"),b=T.filter(d=>!d.content||typeof d.content!="object"),f=T.filter(d=>d.content&&typeof d.content=="object"),x=T.length>0;m.length>0&&n.push({nodeType:h.ITEM,variant:"path",label:"Path",labelTranslationKey:"path",parameters:U(m,r),pointer:e.pointer+"/parameters"}),a.length>0&&!x&&n.push({nodeType:h.ITEM,variant:"query",label:"Query",labelTranslationKey:"query",parameters:U(a,r),pointer:e.pointer+"/parameters"}),b.length>0&&n.push({nodeType:h.ITEM,variant:"querystring",label:"Query String",labelTranslationKey:"querystring",parameters:U(b,r),pointer:e.pointer+"/parameters"});for(const d of f){const E=d.content,g=Object.keys(E),S={};for(const j of g){const v=E[j];if(!v)continue;let A;const K=v.itemSchema,w=v.schema??K,D=F(w,t,r);D&&(A=H(s.schemaStore,s.hashIndex,{kind:B.JSON_SCHEMA,data:D}));const u=Y(v,r);S[j]={schemaId:A,exampleIds:u,...O(C(w))}}const q=g[0],R=q?S[q]:void 0,k=_(d.description,o);n.push({nodeType:h.ITEM,variant:"querystring-body",label:String(d.name??""),required:d.required===!0?!0:void 0,mediaTypes:g.length>0?g:void 0,mediaTypeSchemas:Object.keys(S).length>0?S:void 0,schemaId:R?.schemaId,exampleIds:R?.exampleIds,pointer:e.pointer+"/parameters",...k!==void 0?{description:k}:{},...O(C(d))})}y.length>0&&n.push({nodeType:h.ITEM,variant:"cookies",label:"Cookies",labelTranslationKey:"cookie",parameters:U(y,r),pointer:e.pointer+"/parameters"}),p.length>0&&n.push({nodeType:h.ITEM,variant:"headers",label:"Headers",labelTranslationKey:"header",parameters:U(p,r),pointer:e.pointer+"/parameters"})}if(e.requestBody){const l=$(t,e.requestBody,r)??e.requestBody,i=G(t,l,r),p=i?Object.keys(i):void 0;let a,m,y;if(i&&p){y={};for(const d of p){const E=i[d];if(!E)continue;let g;const S=E.itemSchema,q=E.schema??S,R=F(q,t,r);R&&(g=H(s.schemaStore,s.hashIndex,{kind:B.JSON_SCHEMA,data:R}));const k=Y(E,r,`${e.pointer}/requestBody/content/${N(d)}`);y[d]={schemaId:g,exampleIds:k,...O(C(q))}}const f=p[0],x=f?y[f]:void 0;a=x?.schemaId,m=x?.exampleIds}const T=_(l.description,o),b=C(e.requestBody)??C(l);n.push({nodeType:h.ITEM,variant:"body",label:"Request Body",labelTranslationKey:"body",required:l.required,mediaTypes:p,mediaTypeSchemas:y,schemaId:a,exampleIds:m,pointer:e.pointer+"/requestBody",...T!==void 0?{description:T}:{},...O(b)})}return n}function de(e,r,s,o){if(!e.responses)return;const{storeCtx:n}=M.get(),t=n?.document??{},c=e.responses,i=Object.entries(c).filter(([p])=>ye(p)).map(([p,a])=>{const m=$(t,a,o)??a;let y=C(a)??C(m);const T=G(t,m,o),b=T?Object.keys(T):[],f=b[0],x=f&&T?T[f]:void 0;let d,E,g,S;if(T&&b.length>0){S={};for(const v of b){const A=T[v];if(!A)continue;let K;const w=A.itemSchema,D=A.schema??w,u=F(D,t,o);u&&(K=H(n.schemaStore,n.hashIndex,{kind:B.JSON_SCHEMA,data:u}));const I=Y(A,o,`${e.pointer}/responses/${N(p)}/content/${N(v)}`);S[v]={schemaId:K,exampleIds:I,...O(C(D))}}const j=f?S[f]:void 0;d=j?.schemaId,E=j?.exampleIds}else if(x){const j=x.itemSchema,v=x.schema??j,A=F(v,t,o);A&&(y=y??C(v),d=H(n.schemaStore,n.hashIndex,{kind:B.JSON_SCHEMA,data:A})),E=Y(x,o,f?`${e.pointer}/responses/${N(p)}/content/${N(f)}`:void 0)}const q=Oe(m.headers,t,o);q&&(g=H(n.schemaStore,n.hashIndex,{kind:B.JSON_SCHEMA,data:q}));let R;m.description&&(R=_(m.description,r),Q(R??[],s,`${oe}/${p}`));const k=m["x-summary"]?_(m["x-summary"],r):void 0;return k&&Q(k,s,`${oe}/${p}/summary`),{code:p,summary:k,description:R,mediaType:f,mediaTypes:b.length>0?b:void 0,mediaTypeContent:S,schemaId:d,exampleIds:E,headers:m.headers,headerSchemaId:g,...O(y)}});return{nodeType:h.ITEM,variant:"responses",responses:i,pointer:e.pointer+"/responses"}}function Y(e,r,s){const{storeCtx:o}=M.get(),n=[],t=o.document,c=s?.replace(/^\//,"");if(e.example!==void 0){const l=W(o.exampleStore,{value:e.example,...c&&{id:`${c}/example`}});n.push(l)}if(e.examples&&typeof e.examples=="object"){const l=C(e.examples);for(const[i,p]of Object.entries(e.examples)){if(i===J||!p||typeof p!="object")continue;const a=$(t,p,r)??p,m=C(p)??C(a)??l,y=W(o.exampleStore,{value:ee(a),key:i,summary:typeof a.summary=="string"?a.summary:i,description:te(a.description),externalValue:typeof a.externalValue=="string"?a.externalValue:void 0,...O(m),...c&&{id:`${c}/examples/${N(i)}`}});n.push(y)}}return n.length>0?n:void 0}function ve(e){const{storeCtx:r,options:s}=M.get();if(!e.security||!Array.isArray(e.security)||e.security.length===0)return;const o=e.security.map(n=>{const t=Object.entries(n);if(t.length===0)return null;const c=r?.document?.components?.securitySchemes,l=t.map(([i,p])=>{const a=r?.securitySchemeStore[i],m=C(c?.[i])??a?.[J];return{name:i,scopes:Array.isArray(p)?p:void 0,type:a?.type,scheme:a?.scheme,bearerFormat:a?.bearerFormat,in:a?.in,paramName:a?.paramName,description:a?.description?_(a.description,s):a?.description,openIdConnectUrl:a?.openIdConnectUrl,oauth2MetadataUrl:a?.oauth2MetadataUrl,deprecated:a?.deprecated,flows:a?.flows,...O(m)}}).filter(i=>i.name);return l.length>0?{schemes:l}:null}).filter(n=>n!==null);if(o.length!==0)return{nodeType:h.SECURITY,requirements:o}}function qe(e,r,s,o){const{storeCtx:n}=M.get(),{options:t}=M.get();if(!n)throw new Error("OpenAPI store context is not initialized");return fe(e,n,r,s,o,t)}export{Ue as buildItemContent,Te as createCallbackIdFactory};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{REDOCLY_TEAMS_RBAC as h}from"@redocly/config";import{WEBHOOKS_GROUP_TITLE as k}from"../../../../constants/openapi.js";import{buildItemContent as v}from"./content.js";import{getOperationData as y}from"../../utils/operation.js";import{resolveRequestValues as R,applyRequestValuesToOperationInfo as
|
|
1
|
+
import{REDOCLY_TEAMS_RBAC as h}from"@redocly/config";import{WEBHOOKS_GROUP_TITLE as k}from"../../../../constants/openapi.js";import{buildItemContent as v}from"./content.js";import{getOperationData as y}from"../../utils/operation.js";import{resolveRequestValues as R,applyRequestValuesToOperationInfo as S}from"../../configure/index.js";import{openApiContext as d}from"../../buildContext.js";import{mergeInMockServer as C}from"../../utils/merge-mock-server.js";import{pickOperationServers as I}from"../../utils/merge-mock-server.js";function A({operations:t,result:o,basePath:a,parentRbac:r}){const{basePath:s}=d.get(),e=a??s,{regular:p,regularDeprecated:m,webhooks:n,webhooksDeprecated:i}=w(t);for(const c of[...p,...m])O(c,e,o,r);const f=n.length>0||i.length>0,u=p.length>0||m.length>0;f&&u&&o.push({type:"separator",label:k,variant:"secondary",content:null});for(const c of[...n,...i])O(c,e,o,r)}function w(t){const o=[],a=[],r=[],s=[];for(const e of t)e.isWebhook?(e.deprecated?s:r).push(e):(e.deprecated?a:o).push(e);return{regular:o,regularDeprecated:a,webhooks:r,webhooksDeprecated:s}}function O(t,o,a,r){const{document:s,options:e,processContent:p}=d.get();let n=I(t.servers,s.servers).filter(l=>typeof l?.url=="string");if(n=C(n,e.mockServer),p){const l=R({operationInfo:t,info:s.info??{},servers:n,basePath:o,userClaims:e.userClaims,dynamicRequestValues:e.dynamicRequestValues});l&&Object.keys(l).length>0&&S(t,l,n)}const{slug:i,badges:f,httpPath:u,seo:c,...b}=y(t,o),g={...b,type:"link",link:i,routeSlug:i,metadata:{...c?{seo:c}:{}},[h]:t[h]??r,content:p?v(t,i):null};f&&Object.assign(g,{badges:f}),u&&Object.assign(g,{httpPath:u}),a.push(g)}export{A as addOperationItems};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{contentType as
|
|
1
|
+
import{contentType as M,nodeTypes as o}from"../../../../types/common.js";import{asString as y}from"../../../../utils/string.js";import{parseMarkdown as p}from"../../../utils/parseMarkdown.js";import{buildDownloadPanelContent as N}from"../../panels/download.js";import{buildOverviewPanelContent as x}from"../../panels/overview.js";import{buildInfoMetadataContentNode as V}from"../../../utils/infoMetadata.js";import{buildLanguagesPanelContent as W}from"../../panels/languages.js";import{mergeInMockServer as _}from"../../utils/merge-mock-server.js";import{buildMcpPanelContent as k}from"../../panels/mcp.js";import{buildServersPanelContent as L}from"../../panels/servers.js";function G({document:i,description:S,sectionChildren:g,options:n}){const{downloadUrls:m,hideDownloadButtons:D,basePath:u}=n,{hideInfoMetadata:I}=n,f=n.codeSamples?.languages??[],e=i.info,h=e?.["x-seo"],c=y(h?.title)??y(e?.title)??"API Documentation",O=e?.version?`${c} (${e.version})`:c,t=[];!D&&m&&t.push(N(m)),t.push(x(e)),f.length&&t.push(W(f));const C=k(i);C&&t.push(C);let a=i.servers??[];a=_(a,n.mockServer);const R=a.map(r=>({...r,description:typeof r.description=="string"?r.description:void 0})),E=L(R);E&&t.push(E);const s={nodeType:o.OVERVIEW_SECTION_WRAPPER,children:[{nodeType:o.HEADER,level:1,label:O,showPageActions:!0}],sectionId:u},v=p(e.summary,n);v&&s.children.push({nodeType:o.MARKDOC,content:v});const P=p(S,n);P&&s.children.push({nodeType:o.OVERVIEW_SECTION_WRAPPER,children:[{nodeType:o.MARKDOC,content:P}],sectionId:u});const b=n,d=i.externalDocs||e?.externalDocs;if(d?.url){const r=p(d.description,b)??[];s.children.push({nodeType:o.EXTERNAL_DOCS,url:d.url,description:r})}const l=[s],T=V(e,I);T&&l.push(T),l.push(...g);const w={nodeType:o.CONTAINER,panels:t,children:l},A={name:c};return{contentType:M.OVERVIEW,seo:h,meta:A,children:[w]}}export{G as buildOverviewContent};
|
|
@@ -8,8 +8,8 @@ export declare function mergeInMockServer(servers: OpenAPIServer[], mockServerOp
|
|
|
8
8
|
/** Operation servers win when non-empty; an empty array falls through to the
|
|
9
9
|
* document servers (see the empty-array test — a `??` fallback would not). */
|
|
10
10
|
export declare function pickOperationServers<T>(operationServers: T[] | undefined, documentServers: T[] | undefined): T[];
|
|
11
|
-
/** Strips servers
|
|
12
|
-
*
|
|
11
|
+
/** Strips servers flagged as mock servers. Returns the same reference when
|
|
12
|
+
* nothing is flagged. */
|
|
13
13
|
export declare function excludeMockServers<T extends {
|
|
14
14
|
isMockServer?: boolean;
|
|
15
15
|
}>(servers: T[]): T[];
|
|
@@ -5,7 +5,10 @@ import type { ApiDocsOptions } from '../../types/options.js';
|
|
|
5
5
|
import type { MarkdownHeading } from '../../types/openapi.js';
|
|
6
6
|
import type { ParseMarkdownOptions } from './parseMarkdown.js';
|
|
7
7
|
export type { MarkdownHeading };
|
|
8
|
-
export type MarkdownSanitizeOptions =
|
|
8
|
+
export type MarkdownSanitizeOptions = {
|
|
9
|
+
sanitize?: ApiDocsOptions['sanitize'];
|
|
10
|
+
unstable_hooks?: ApiDocsOptions['unstable_hooks'];
|
|
11
|
+
};
|
|
9
12
|
export type DescriptionSegment = {
|
|
10
13
|
kind: 'markdoc';
|
|
11
14
|
node: ContentNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{contentType as v,itemVariant as N,nodeTypes as u}from"../../types/common.js";import{safeSlugify as x}from"../../utils/string.js";import{parseMarkdown as p}from"./parseMarkdown.js";import{isPlainText as k}from"./isPlainText.js";import{joinWithSeparator as a}from"../../utils/url.js";import{buildDeepLinkUrl as O}from"../../utils/deep-link.js";import{getDOMPurify as E}from"./dompurify.js";function L(t){return t.type==="tag"&&t.tag==="schemaDefinition"}const W=/^[ \t]{0,3}#{1,6}[ \t]/m;function M(t){const r=t.search(W);return r===-1?t:t.slice(0,r)}function X(t,r){if(typeof t=="string"){const n=M(t).trim();if(k(n))return n}const e=p(t,r);if(!e)return;if(typeof e=="string")return e;if(Array.isArray(e)){const n=e.findIndex(o=>o.type==="heading");return n===-1?e:e.slice(0,n)}if(!e.children||!Array.isArray(e.children))return;const i=e.children.findIndex(n=>n.type==="heading");return i===-1?[e]:(e.children=e.children.slice(0,i),[e])}function Y(t,r,{sliceAtFirstHeading:e=!1}={}){if(typeof t=="string"&&e){const f=M(t).trim();if(k(f))return[{kind:"markdoc",node:{nodeType:u.MARKDOC,content:f}}]}const i=p(t,r);if(!i)return[];if(typeof i=="string")return[{kind:"markdoc",node:{nodeType:u.MARKDOC,content:i}}];let n=Array.isArray(i)?i:i.children??[];if(e){const f=n.findIndex(d=>d.type==="heading");f!==-1&&(n=n.slice(0,f))}const o=[];let c=[];const l=()=>{c.length>0&&(o.push({kind:"markdoc",node:{nodeType:u.MARKDOC,content:c}}),c=[])};for(const f of n)L(f)?(l(),o.push({kind:"schemaDefinition",node:{nodeType:u.MARKDOC,content:[f]}})):c.push(f);return l(),o}function _(t,r,e){const i=t.toLowerCase(),n=i.startsWith("section/")?i.slice(8):i,o=r.toLowerCase();let c=n!==o?n:"";return e&&(c=a(e,c)),c}function S(t,...r){let e=t.toLowerCase();for(const i of r){const n=i?`${i.toLowerCase()}/`:"";n&&`${e}/`.startsWith(n)&&(e=e.slice(n.length))}return e}function J(t,r,e){if(typeof t=="string")return;const i=n=>{if(n.type==="heading"&&n.attributes?.level){const o=n.attributes.id?S(n.attributes.id,r,e):x(m(n).trim()).toLowerCase();if(o){const c=_(o,r,e);n.attributes.id=a(r,c).toLowerCase(),n.attributes.deepLinkHash=O("",r,c)}}for(const o of n.children??[])i(o)};if(Array.isArray(t))for(const n of t)i(n);else i(t)}function H(t,r,e,i){const n=p(t,r);if(!n)return[];if(typeof n=="string")return[];const o=[];let c;const l=(s,h,R=o,y,A)=>{s=z(s);const T=A!==void 0,C=T?A:e;let g;y.attributes.id?g=S(y.attributes.id,C):T||i?g=x(s):g=`section/${x(s)}`;const I=a(C,g).toLowerCase();y.attributes.id=I;const b={id:I,name:s,level:h,items:[],ast:[y]};return R.push(b),b},f=s=>{if(typeof s?.attributes?.content=="string")return s.attributes.content;if(s?.children)return f(s.children[0])},d=s=>{const h=f(s)||"";s.type==="heading"&&s.attributes?.level===1?c=l(h,s.attributes.level,void 0,s):s.attributes?.level?l(h,s.attributes.level,c?.items,s,c?.id):c?.items?.length?c.items[c.items.length-1]?.ast?.push(s):o.length&&o[o.length-1]?.ast?.push(s)};if(Array.isArray(n))for(const s of n)d(s);else if(n.children)for(const s of n.children)d(s);return o}function K({heading:t,basePath:r}){const e=t.items.length>0,i=a(r,t.id).toLowerCase(),n=e?t.items.map(o=>K({heading:o,basePath:r})):[];return{type:e?"group":"link",label:t.name,link:i,routeSlug:i,items:e?n:void 0,content:P(t)}}function Q(t,r,e){const i=[],n=[];for(const o of H(t,e,"")){const{item:c,children:l}=w(o,r);i.push(c),n.push(...l)}return{sectionItems:i,sectionChildren:n}}function w(t,r){const e=a(r,t.id),i=t.items.length>0,n=t.ast?.length?[V(t.ast,a(r,t.id))]:[],o=[];for(const l of t.items){const{item:f,children:d}=w(l,r);o.push(f);const s=a(r,l.id);n.push({nodeType:u.OVERVIEW_SECTION_WRAPPER,children:d,sectionId:s})}return{item:{type:i?"group":"link",label:t.name,link:e,routeSlug:e,items:i?o:void 0,content:null},children:n}}function Z(t){return typeof t=="string"?t.trim():Array.isArray(t)?t.map(r=>m(r)).filter(Boolean).join(" ").trim():m(t).trim()}function D(t,r=50){if(typeof t=="string"){const o=t.split(/\n[ \t]*\n/)[0].replace(/\s+/g," ").trim();return o?o.substring(0,r):void 0}const i=(Array.isArray(t)?t:t.children??[t])[0];if(!i)return;const n=m(i);return n?n.substring(0,r):void 0}function tt(t,r){if(!t)return;const e=p(t,r);if(!e)return;const i=D(e);return i?i.length===50?i+"\u2026":i:void 0}function et(t,r){if(!t)return;const e=p(t,r);if(e)return D(e,Number.POSITIVE_INFINITY)}function m(t){const r=[];function e(i){typeof i.attributes?.content=="string"&&r.push(i.attributes.content);for(const n of i.children??[])e(n)}return e(t),r.join("")}function nt(t){return typeof t=="string"?t.trim():(Array.isArray(t)?t:[t]).map(e=>m(e)).join("").trim()}function z(t){return t.replace(/&#(\d+);/g,(r,e)=>String.fromCharCode(parseInt(e,10))).replace(/"/g,'"').replace(/&/g,"&")}function rt(t,r){const{
|
|
1
|
+
import{contentType as v,itemVariant as N,nodeTypes as u}from"../../types/common.js";import{safeSlugify as x}from"../../utils/string.js";import{parseMarkdown as p}from"./parseMarkdown.js";import{isPlainText as k}from"./isPlainText.js";import{joinWithSeparator as a}from"../../utils/url.js";import{buildDeepLinkUrl as O}from"../../utils/deep-link.js";import{getDOMPurify as E}from"./dompurify.js";function L(t){return t.type==="tag"&&t.tag==="schemaDefinition"}const W=/^[ \t]{0,3}#{1,6}[ \t]/m;function M(t){const r=t.search(W);return r===-1?t:t.slice(0,r)}function X(t,r){if(typeof t=="string"){const n=M(t).trim();if(k(n))return n}const e=p(t,r);if(!e)return;if(typeof e=="string")return e;if(Array.isArray(e)){const n=e.findIndex(o=>o.type==="heading");return n===-1?e:e.slice(0,n)}if(!e.children||!Array.isArray(e.children))return;const i=e.children.findIndex(n=>n.type==="heading");return i===-1?[e]:(e.children=e.children.slice(0,i),[e])}function Y(t,r,{sliceAtFirstHeading:e=!1}={}){if(typeof t=="string"&&e){const f=M(t).trim();if(k(f))return[{kind:"markdoc",node:{nodeType:u.MARKDOC,content:f}}]}const i=p(t,r);if(!i)return[];if(typeof i=="string")return[{kind:"markdoc",node:{nodeType:u.MARKDOC,content:i}}];let n=Array.isArray(i)?i:i.children??[];if(e){const f=n.findIndex(d=>d.type==="heading");f!==-1&&(n=n.slice(0,f))}const o=[];let c=[];const l=()=>{c.length>0&&(o.push({kind:"markdoc",node:{nodeType:u.MARKDOC,content:c}}),c=[])};for(const f of n)L(f)?(l(),o.push({kind:"schemaDefinition",node:{nodeType:u.MARKDOC,content:[f]}})):c.push(f);return l(),o}function _(t,r,e){const i=t.toLowerCase(),n=i.startsWith("section/")?i.slice(8):i,o=r.toLowerCase();let c=n!==o?n:"";return e&&(c=a(e,c)),c}function S(t,...r){let e=t.toLowerCase();for(const i of r){const n=i?`${i.toLowerCase()}/`:"";n&&`${e}/`.startsWith(n)&&(e=e.slice(n.length))}return e}function J(t,r,e){if(typeof t=="string")return;const i=n=>{if(n.type==="heading"&&n.attributes?.level){const o=n.attributes.id?S(n.attributes.id,r,e):x(m(n).trim()).toLowerCase();if(o){const c=_(o,r,e);n.attributes.id=a(r,c).toLowerCase(),n.attributes.deepLinkHash=O("",r,c)}}for(const o of n.children??[])i(o)};if(Array.isArray(t))for(const n of t)i(n);else i(t)}function H(t,r,e,i){const n=p(t,r);if(!n)return[];if(typeof n=="string")return[];const o=[];let c;const l=(s,h,R=o,y,A)=>{s=z(s);const T=A!==void 0,C=T?A:e;let g;y.attributes.id?g=S(y.attributes.id,C):T||i?g=x(s):g=`section/${x(s)}`;const I=a(C,g).toLowerCase();y.attributes.id=I;const b={id:I,name:s,level:h,items:[],ast:[y]};return R.push(b),b},f=s=>{if(typeof s?.attributes?.content=="string")return s.attributes.content;if(s?.children)return f(s.children[0])},d=s=>{const h=f(s)||"";s.type==="heading"&&s.attributes?.level===1?c=l(h,s.attributes.level,void 0,s):s.attributes?.level?l(h,s.attributes.level,c?.items,s,c?.id):c?.items?.length?c.items[c.items.length-1]?.ast?.push(s):o.length&&o[o.length-1]?.ast?.push(s)};if(Array.isArray(n))for(const s of n)d(s);else if(n.children)for(const s of n.children)d(s);return o}function K({heading:t,basePath:r}){const e=t.items.length>0,i=a(r,t.id).toLowerCase(),n=e?t.items.map(o=>K({heading:o,basePath:r})):[];return{type:e?"group":"link",label:t.name,link:i,routeSlug:i,items:e?n:void 0,content:P(t)}}function Q(t,r,e){const i=[],n=[];for(const o of H(t,e,"")){const{item:c,children:l}=w(o,r);i.push(c),n.push(...l)}return{sectionItems:i,sectionChildren:n}}function w(t,r){const e=a(r,t.id),i=t.items.length>0,n=t.ast?.length?[V(t.ast,a(r,t.id))]:[],o=[];for(const l of t.items){const{item:f,children:d}=w(l,r);o.push(f);const s=a(r,l.id);n.push({nodeType:u.OVERVIEW_SECTION_WRAPPER,children:d,sectionId:s})}return{item:{type:i?"group":"link",label:t.name,link:e,routeSlug:e,items:i?o:void 0,content:null},children:n}}function Z(t){return typeof t=="string"?t.trim():Array.isArray(t)?t.map(r=>m(r)).filter(Boolean).join(" ").trim():m(t).trim()}function D(t,r=50){if(typeof t=="string"){const o=t.split(/\n[ \t]*\n/)[0].replace(/\s+/g," ").trim();return o?o.substring(0,r):void 0}const i=(Array.isArray(t)?t:t.children??[t])[0];if(!i)return;const n=m(i);return n?n.substring(0,r):void 0}function tt(t,r){if(!t)return;const e=p(t,r);if(!e)return;const i=D(e);return i?i.length===50?i+"\u2026":i:void 0}function et(t,r){if(!t)return;const e=p(t,r);if(e)return D(e,Number.POSITIVE_INFINITY)}function m(t){const r=[];function e(i){typeof i.attributes?.content=="string"&&r.push(i.attributes.content);for(const n of i.children??[])e(n)}return e(t),r.join("")}function nt(t){return typeof t=="string"?t.trim():(Array.isArray(t)?t:[t]).map(e=>m(e)).join("").trim()}function z(t){return t.replace(/&#(\d+);/g,(r,e)=>String.fromCharCode(parseInt(e,10))).replace(/"/g,'"').replace(/&/g,"&")}function rt(t,r){const{sanitize:e}=r??{},{unstable_hooks:i}=r??{};return i?.sanitize?i.sanitize(t):e?E().sanitize(t):t}function P(t){const r=[];return t.ast&&t.ast.length>0&&r.push({nodeType:u.MARKDOC,content:t.ast}),{contentType:v.ITEM,itemVariant:N.MARKDOWN,meta:{name:t.name},children:[{nodeType:u.CONTAINER,children:r,panels:[]}]}}function V(t,r){return{nodeType:u.OVERVIEW_SECTION_WRAPPER,children:[{nodeType:u.MARKDOC,content:t}],sectionId:r}}export{K as buildMarkdownSectionItem,nt as collectMarkdownPlainText,Q as collectMarkdownSections,X as extractContentUntilFirstHeading,Y as extractDescriptionSegments,D as extractFirstParagraphText,Z as extractFullText,H as extractMarkdownSections,et as extractSeoDescriptionText,tt as extractSummaryText,_ as resolveMarkdocHeadingDeepSuffix,J as resolveMarkdocHeadingIds,rt as sanitizeMarkdownSource,z as unescapeHTMLChars};
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { Component } from 'react';
|
|
2
|
-
import type { ReactNode, ErrorInfo } from 'react';
|
|
2
|
+
import type { ReactNode, ErrorInfo, ContextType } from 'react';
|
|
3
|
+
import { TelemetryContext } from '../contexts/telemetry.js';
|
|
3
4
|
type ErrorBoundaryProps = {
|
|
4
5
|
children: ReactNode;
|
|
5
6
|
fallback?: ReactNode;
|
|
6
|
-
onError?: (error: Error, errorInfo: ErrorInfo) => void;
|
|
7
7
|
};
|
|
8
8
|
type ErrorBoundaryState = {
|
|
9
9
|
hasError: boolean;
|
|
10
10
|
error: Error | null;
|
|
11
11
|
};
|
|
12
12
|
export declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
|
13
|
+
static contextType: import("react").Context<import("../index.js").RedocTelemetry>;
|
|
14
|
+
context: ContextType<typeof TelemetryContext>;
|
|
13
15
|
constructor(props: ErrorBoundaryProps);
|
|
14
16
|
static getDerivedStateFromError(error: Error): ErrorBoundaryState;
|
|
15
17
|
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as o,jsxs as s}from"react/jsx-runtime";import{Component as a}from"react";import{TelemetryContext as i}from"../contexts/telemetry.js";class h extends a{static contextType=i;constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error("[api-docs] Rendering error:",e,t.componentStack);const r=this.context;try{r.sendErrorMessage([{id:"errorBoundaryCatch",object:"error",uri:typeof window<"u"?window.location.href:"",...r.typeOfUsage?{typeOfUsage:r.typeOfUsage}:{},details:{message:e.message,stack:t.componentStack??void 0}}])}catch(n){console.error("[api-docs] error telemetry failed:",n)}}render(){return this.state.hasError?this.props.fallback?this.props.fallback:s("div",{role:"alert",style:{padding:"20px",color:"#c00"},children:[o("h2",{children:"Something went wrong rendering the API documentation."}),s("details",{style:{whiteSpace:"pre-wrap",marginTop:"10px"},children:[o("summary",{children:"Error details"}),this.state.error?.message]})]}):this.props.children}}export{h as ErrorBoundary};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Fragment as B,jsx as r,jsxs as l}from"react/jsx-runtime";import{useMemo as d,memo as Q,useContext as U}from"react";import{useAtomValue as E}from"jotai";import{styled as t,css as c}from"styled-components";import{apiSpecType as I}from"../../types/common.js";import{H1 as V}from"@redocly/theme/components/Typography/H1";import{H2 as Y}from"@redocly/theme/components/Typography/H2";import{H3 as J}from"@redocly/theme/components/Typography/H3";import{H4 as X}from"@redocly/theme/components/Typography/H4";import{PageActions as Z}from"@redocly/theme/components/PageActions/PageActions";import{breakpoints as ee}from"@redocly/theme/core/
|
|
1
|
+
import{Fragment as B,jsx as r,jsxs as l}from"react/jsx-runtime";import{useMemo as d,memo as Q,useContext as U}from"react";import{useAtomValue as E}from"jotai";import{styled as t,css as c}from"styled-components";import{apiSpecType as I}from"../../types/common.js";import{H1 as V}from"@redocly/theme/components/Typography/H1";import{H2 as Y}from"@redocly/theme/components/Typography/H2";import{H3 as J}from"@redocly/theme/components/Typography/H3";import{H4 as X}from"@redocly/theme/components/Typography/H4";import{PageActions as Z}from"@redocly/theme/components/PageActions/PageActions";import{breakpoints as ee}from"@redocly/theme/core/openapi";import{useSpecTranslate as re}from"../../hooks/useTranslate.js";import{resolveText as te}from"../../utils/resolveText.js";import{routingBasePathAtom as oe,specTypeAtom as ae}from"../../jotai/store.js";import{GraphQLHeaderExtras as ne}from"../graphql/GraphQLHeaderExtras.js";import{StyledBadge as D,TextBadge as ie,renderPropertyBadge as W}from"../common/Badge.js";import{DeepLinkAnchor as se,deepLinkHoverReveal as le}from"../common/DeepLinkAnchor.js";import{joinWithSeparator as pe,toRelativePath as de}from"../../utils/url.js";import{encodeBackSlashes as ce}from"../../utils/string.js";import{buildDeepLinkUrl as me,getDeepLinkId as ge}from"../../utils/deep-link.js";import{useNavigationUrlNormalizer as he}from"../../hooks/useNormalizeUrl.js";import{ItemIdContext as fe}from"../../hooks/useDeepLinkSection.js";import{ArgsCollapsed as be}from"../graphql/styled.js";import{ResponsesDeepLinkAnchor as ue}from"./ResponseDeepLinkAnchor.js";import{HeaderResponseCodeTabs as xe}from"./HeaderResponseCodeTabs.js";import{ExpandAllButton as ve}from"../common/ExpandAllButton.js";import{useHeaderExpandableKeys as He,useResponseCodes as we,useHeaderHasRenderedCollapsibles as ke}from"./hooks.js";function ye({node:e,path:m,parentNode:_}){const{level:g,label:q,badges:u,deprecated:z,graphqlReturnType:j,graphqlArgs:x,graphqlDeprecated:G,graphqlOperationType:N,showPageActions:F=!1,deepLinkSuffix:a,protocolTag:w,isWebhook:y}=e,$=E(ae),v=re(),o=$===I.GRAPHQL,A=z||o&&G,i=E(oe),k=he(),h=U(fe),s=we(_,a),K=s?.[0]||"",f=te(v,e.labelTranslationKey,e.label),p=d(()=>m?de(m,i):"",[m,i]),H=d(()=>p?k(a?me(i,p,a):pe(i,ce(p.toLowerCase()))):"",[p,i,a,k]),R=a==="responses"&&!!s&&s.length>0&&!!m,T=He(a),M=ke(a),C=d(()=>u?.filter(n=>n.position==="before")??[],[u]),L=d(()=>u?.filter(n=>n.position!=="before")??[],[u]),P=d(()=>!H||g<=1?null:R?r(ue,{routingBasePath:i,relativePath:p,itemId:h??"",label:`link to ${f}`}):r(se,{to:H,label:`link to ${f}`}),[H,g,R,i,p,h,f]),S=d(()=>{const n=l(B,{children:[P,C.map(W),f,L.map(W)]});switch(g){case 1:return r(Be,{$inline:o,children:n});case 2:return l(Ee,{$inline:o,children:[n,A&&r(D,{$deprecated:!0,children:v("badges.deprecated","deprecated")}),y&&r(D,{webhook:!0,children:v("badges.webhook","Webhook")})]});case 3:return r(Ie,{$inline:o,children:n});case 4:return r(De,{$inline:o,children:n});case 5:return r(We,{$inline:o,children:n});default:return null}},[P,C,f,L,g,A,v,y,o]),O=!o&&g===4&&a==="responses";return l(B,{children:[w&&r(Pe,{color:w.color,borderless:!0,children:w.label}),l($e,{id:a?ge(H):void 0,$spacingBeforeResponses:O,$isAsyncApi:$===I.ASYNCAPI,children:[l(Te,{$badgeCount:s?.length??0,children:[o?l(Se,{children:[S,x&&x.length>0&&l(Ce,{"data-testid":"collapsed-args",$size:"lg",children:["(",x.length===1?x[0].name:"...args",")"]})]}):S,s&&s.length>0&&r(xe,{codes:s,itemId:h??"",firstCode:K}),T.length>0&&M&&h&&r(ve,{itemId:h,deepLinkKeys:T})]}),F&&r(Le,{children:r(Z,{pageSlug:m||i})})]}),o&&r(ne,{returnType:j,operationName:q,operationType:N})]})}const $e=t.div`
|
|
2
2
|
container-type: inline-size;
|
|
3
3
|
container-name: api-docs-heading;
|
|
4
4
|
position: relative;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Fragment as g,jsx as n,jsxs as l}from"react/jsx-runtime";import{styled as a}from"styled-components";import{useCallback as N,useContext as W,useEffect as K,useMemo as r,useRef as z,useState as q}from"react";import{useAtomValue as G,useSetAtom as U}from"jotai";import{Segmented as Q}from"@redocly/theme/components/Segmented/Segmented";import{breakpoints as S}from"@redocly/theme/core/
|
|
1
|
+
import{Fragment as g,jsx as n,jsxs as l}from"react/jsx-runtime";import{styled as a}from"styled-components";import{useCallback as N,useContext as W,useEffect as K,useMemo as r,useRef as z,useState as q}from"react";import{useAtomValue as G,useSetAtom as U}from"jotai";import{Segmented as Q}from"@redocly/theme/components/Segmented/Segmented";import{breakpoints as S}from"@redocly/theme/core/openapi";import{collectMarkdownPlainText as X}from"../../../adapters/utils/markdoc.js";import{SECTION_ATTR as Y}from"../../../constants/openapi.js";import{SchemaView as f}from"../../Schema/SchemaView.js";import{VariantDropdown as Z}from"../../Schema/views/VariantDropdown.js";import{Markdown as ee}from"../../common/Markdown.js";import{ExternalDocumentation as ne}from"../../common/ExternalDocumentation.js";import{DeepLinkAnchor as D,deepLinkHoverReveal as C}from"../../common/DeepLinkAnchor.js";import{buildAsyncApiSuffix as b,getDeepLinkId as w}from"../../../utils/deep-link.js";import{DeepLinkSectionContext as E,ItemIdContext as te,useDeepLinkUrl as M}from"../../../hooks/useDeepLinkSection.js";import{isRecord as $}from"../../../adapters/helpers.js";import{itemStoreAtom as oe,itemStoreFieldAtom as ae}from"../../../jotai/itemStore.js";import{useSpecTranslate as re}from"../../../hooks/useTranslate.js";import{useTelemetry as ie}from"../../../hooks/useTelemetry.js";import{useKeyFromHash as se}from"../hooks.js";const ce=3;function je({node:e}){const o=e.messages;return!o||o.length===0?n(g,{}):n(le,{messages:o})}function le({messages:e}){const o=W(te),d=U(oe(o??"")),h=G(r(()=>ae({itemId:o??"",key:"activeMessageKey"}),[o])),y=r(()=>e.map(t=>t.name),[e]),i=se(o??void 0,y,"m"),m=z(void 0),s=i!==void 0&&i!==m.current?i:h||e[0].name,c=r(()=>e.find(t=>t.name===s)??e[0],[e,s]);K(()=>{i&&d({activeMessageKey:i}),m.current=i},[i,d]);const u=ie(),v=r(()=>e.map(t=>({value:t.name,label:t.label||t.name})),[e]),I=z(null),[P,R]=q(!1);K(()=>{const t=()=>{const A=I.current;if(!A)return;const O=A.querySelectorAll('[role="tab"]'),V=Array.from(O).some(J=>{const T=J;return T.offsetWidth<T.scrollWidth});R(V)};return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[v]);const _=e.length>ce||e.length>1&&P,k=N(t=>{u.sendSwitchMessageClickedMessage([{id:"switchMessageButton",object:"button",uri:"urn:redocly:redoc:ui:button:switchMessageButton",message:t}]),d({activeMessageKey:t})},[u,d]),j=r(()=>c?.name?b({section:"messages",messageKey:c.name}):"",[c?.name]),x=M(j),L=r(()=>o?`${o}/messages`:void 0,[o]),H=L?{[Y]:L}:{};return l("div",{...H,children:[n(me,{children:e.length>1?l(g,{children:["Accepts ",n(pe,{children:"one of"})," the following messages:"]}):n(g,{children:"Accepts the following message:"})}),l(ue,{id:w(x),children:[x&&n(fe,{children:n(D,{to:x,label:"link to Message selector"})}),_?n(Z,{value:s,options:v,onChange:t=>{t.value!==void 0&&k(t.value)}}):n(Q,{ref:I,size:"small",value:s,options:v,onChange:t=>{t.value!==void 0&&k(t.value)}})]}),c&&n(de,{message:c})]})}function de({message:e}){const o=re(),d=o("header","Headers"),h=r(()=>e.name?{asyncSection:"messages",messageKey:e.name,t:"headers"}:null,[e.name]),y=r(()=>e.name?{asyncSection:"messages",messageKey:e.name,t:"payload"}:null,[e.name]),i=r(()=>e.name?b({section:"messages",messageKey:e.name,subsection:"headers"}):"",[e.name]),m=r(()=>e.name?b({section:"messages",messageKey:e.name,subsection:"payload"}):"",[e.name]),p=M(i),s=M(m),c=e.payloadLabel??o("payload","Payload"),u=e.externalDocs?.description!=null?X(e.externalDocs.description):void 0;return l(he,{children:[e.summary&&n(ye,{children:e.summary}),e.description&&n(ve,{children:n(ee,{source:e.description})}),e.externalDocs?.url&&n(xe,{children:n(ne,{externalDocs:{url:e.externalDocs.url,description:u||void 0},compact:!0})}),(e.headerSchemaId||$(e.headers))&&l(B,{id:w(p),children:[l(F,{children:[p&&n(D,{to:p,label:`link to ${d}`}),d]}),n(E.Provider,{value:h,children:e.headerSchemaId?n(f,{schemaId:e.headerSchemaId,expandByDefault:!0}):n(f,{schema:e.headers,expandByDefault:!0})})]}),(e.schemaId||$(e.payload))&&l(B,{id:w(s),children:[l(F,{children:[s&&n(D,{to:s,label:`link to ${c}`}),c,e.contentType&&n(ge,{children:e.contentType})]}),n(E.Provider,{value:y,children:e.schemaId?n(f,{schemaId:e.schemaId,expandByDefault:!0}):n(f,{schema:e.payload,expandByDefault:!0})})]})]})}const me=a.p`
|
|
2
2
|
margin: 0 0 var(--spacing-sm, 12px);
|
|
3
3
|
color: var(--text-color-secondary, #666);
|
|
4
4
|
font-size: var(--font-size-base, 14px);
|
|
@@ -97,7 +97,7 @@ import{styled as r}from"styled-components";import{Link as i}from"react-router";i
|
|
|
97
97
|
font-family: var(--font-family-monospaced);
|
|
98
98
|
font-size: var(--font-size-sm);
|
|
99
99
|
line-height: var(--line-height-sm);
|
|
100
|
-
border-radius: var(--border-radius);
|
|
100
|
+
border-radius: var(--tag-border-radius);
|
|
101
101
|
color: var(--text-color-secondary);
|
|
102
102
|
display: inline-flex;
|
|
103
103
|
word-break: var(--code-word-break);
|
|
@@ -173,7 +173,7 @@ import{styled as r}from"styled-components";import{Link as i}from"react-router";i
|
|
|
173
173
|
flex-basis: 100%;
|
|
174
174
|
min-width: 0;
|
|
175
175
|
border: 1px solid var(--border-color-secondary);
|
|
176
|
-
border-radius: var(--border-radius);
|
|
176
|
+
border-radius: var(--border-radius-xl);
|
|
177
177
|
overflow: hidden;
|
|
178
178
|
`,F=r.div`
|
|
179
179
|
display: flex;
|
|
@@ -270,7 +270,7 @@ import{styled as r}from"styled-components";import{Link as i}from"react-router";i
|
|
|
270
270
|
width: 100%;
|
|
271
271
|
`,Y=r.span`
|
|
272
272
|
padding: 0 var(--spacing-xs);
|
|
273
|
-
border-radius: var(--border-radius);
|
|
273
|
+
border-radius: var(--tag-border-radius);
|
|
274
274
|
border: 1px solid var(--border-color-secondary);
|
|
275
275
|
background-color: var(--bg-color);
|
|
276
276
|
font-size: var(--font-size-sm);
|
|
@@ -305,7 +305,7 @@ import{styled as r}from"styled-components";import{Link as i}from"react-router";i
|
|
|
305
305
|
color: var(--tag-basic-content-color);
|
|
306
306
|
padding: 0 var(--spacing-xs);
|
|
307
307
|
border: 1px solid var(--border-color-secondary);
|
|
308
|
-
border-radius: var(--border-radius);
|
|
308
|
+
border-radius: var(--tag-border-radius);
|
|
309
309
|
margin: var(--spacing-xxs) 0 var(--spacing-xs);
|
|
310
310
|
position: relative;
|
|
311
311
|
width: fit-content;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as r,jsxs as
|
|
1
|
+
import{jsx as r,jsxs as n}from"react/jsx-runtime";import{useAtomValue as I}from"jotai";import{ArrayWrapper as u,ArrayLabel as A,ArrayClosingLabel as b,ArrayLabelValue as o,ArrayLine as l,SchemaTypeLabel as N,PropertyList as L}from"../styled.js";import{globalOptionsAtom as O}from"../../../jotai/store.js";import{appendArraySuffix as P}from"../../../utils/deep-link.js";import{isWithinExpansionLevel as C}from"../../../utils/expansion.js";import{PropertyRenderer as x}from"./PropertyRenderer.js";import{ObjectRenderer as F}from"./ObjectRenderer.js";import{PropertyFieldRow as R}from"./PropertyFieldRow.js";function $({property:j,level:s,fieldParentsName:d,skipReadOnly:p,skipWriteOnly:c,onOneOfChange:m}){const{schemasExpansionLevel:w}=I(O),i=j.items;if(!i||i.length===0)return r(N,{children:"array"});const g=C(s,w,1),h=d&&P(d),y=s===1,f=i.some(e=>e.isTupleItem||e.isAdditionalItems),t=i[0];if(!f&&i.length===1&&t&&t.switcher){const e=r(x,{property:t,level:s+1,fieldParentsName:h,skipReadOnly:p,skipWriteOnly:c,onOneOfChange:m});return y?n(u,{children:[n(A,{children:[r(o,{children:"Array ["}),r(l,{})]}),e,n(b,{className:"array-closing-label",children:[r(l,{}),r(o,{children:"]"})]})]}):e}if(!f&&i.length===1&&t&&t.properties){const e=r(F,{property:t,level:s,fieldParentsName:h,skipReadOnly:p,skipWriteOnly:c,onOneOfChange:m});return y?n(u,{children:[n(A,{children:[r(o,{children:"Array ["}),r(l,{})]}),e,n(b,{className:"array-closing-label",children:[r(l,{}),r(o,{children:"]"})]})]}):e}return f||i.length>1?r(L,{children:i.map((e,a)=>r(R,{name:e.isAdditionalItems?`[${a}...]`:`[${a}]`,property:e,level:s,expandByDefault:g,isFirst:a===0,fieldParentsName:d,skipReadOnly:p,skipWriteOnly:c,onOneOfChange:m},a))}):t&&!t.switcher&&!t.properties&&!y?r(L,{children:r(R,{name:"[i]",property:t,level:s,expandByDefault:g,isFirst:!0,fieldParentsName:d,skipReadOnly:p,skipWriteOnly:c,onOneOfChange:m})}):n(u,{children:[n(A,{children:[r(o,{children:"Array ["}),r(l,{})]}),i.map((e,a)=>r(x,{property:e,level:s+1,fieldParentsName:h,skipReadOnly:p,skipWriteOnly:c,onOneOfChange:m},a)),n(b,{className:"array-closing-label",children:[r(l,{}),r(o,{children:"]"})]})]})}export{$ as ArrayRenderer};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { ApiItem, ApiStore } from '../../types/store.js';
|
|
3
|
+
export type SearchProps = {
|
|
4
|
+
items: ApiItem[];
|
|
5
|
+
store: ApiStore;
|
|
6
|
+
basePath: string;
|
|
7
|
+
/** Bundled definition — enables `$ref` resolution for schema-field results. */
|
|
8
|
+
document?: Record<string, unknown>;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Search ships only in the open-source Redoc (`index.ce.ts` and the `.ce`
|
|
12
|
+
* files it re-exports replace this stub there); enterprise search is provided
|
|
13
|
+
* by the portal.
|
|
14
|
+
*/
|
|
15
|
+
export declare function Search(_props: SearchProps): ReactElement | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function n(r){return null}export{n as Search};
|
|
@@ -7,7 +7,7 @@ import{styled as r}from"styled-components";import{Panel as a}from"@redocly/theme
|
|
|
7
7
|
&&& {
|
|
8
8
|
margin-bottom: var(--spacing-lg);
|
|
9
9
|
}
|
|
10
|
-
`,
|
|
10
|
+
`,g=r.div`
|
|
11
11
|
display: flex;
|
|
12
12
|
align-items: center;
|
|
13
13
|
justify-content: space-between;
|
|
@@ -18,7 +18,7 @@ import{styled as r}from"styled-components";import{Panel as a}from"@redocly/theme
|
|
|
18
18
|
border-bottom: var(--panel-border, 1px solid var(--border-color-primary));
|
|
19
19
|
border-radius: var(--panel-border-radius, var(--border-radius))
|
|
20
20
|
var(--panel-border-radius, var(--border-radius)) 0 0;
|
|
21
|
-
`,
|
|
21
|
+
`,d=r(e)`
|
|
22
22
|
margin-left: auto;
|
|
23
23
|
font-size: var(--font-size-sm);
|
|
24
24
|
`,v=r.span`
|
|
@@ -53,14 +53,14 @@ import{styled as r}from"styled-components";import{Panel as a}from"@redocly/theme
|
|
|
53
53
|
position: fixed;
|
|
54
54
|
width: 100vw;
|
|
55
55
|
height: 100vh;
|
|
56
|
-
z-index: var(--z-index-popover,
|
|
56
|
+
z-index: var(--z-index-popover, 200);
|
|
57
57
|
left: 0;
|
|
58
58
|
top: 0;
|
|
59
59
|
pointer-events: auto;
|
|
60
60
|
`,y=r.div`
|
|
61
61
|
background: var(--bg-color);
|
|
62
62
|
box-shadow: var(--bg-raised-shadow, 0 8px 32px rgba(0, 0, 0, 0.15));
|
|
63
|
-
border-radius: var(--border-radius-lg
|
|
63
|
+
border-radius: var(--border-radius-lg);
|
|
64
64
|
padding: var(--spacing-lg);
|
|
65
65
|
display: flex;
|
|
66
66
|
flex-direction: column;
|
|
@@ -170,7 +170,7 @@ import{styled as r}from"styled-components";import{Panel as a}from"@redocly/theme
|
|
|
170
170
|
font-size: var(--font-size-sm);
|
|
171
171
|
font-family: var(--font-family-monospaced);
|
|
172
172
|
padding: 0 var(--spacing-xxs);
|
|
173
|
-
border-radius: var(--border-radius);
|
|
173
|
+
border-radius: var(--tag-border-radius);
|
|
174
174
|
background: var(--tag-bg-color, var(--border-color-secondary));
|
|
175
175
|
color: var(--text-color-secondary);
|
|
176
176
|
`,V=r.button`
|
|
@@ -199,7 +199,7 @@ import{styled as r}from"styled-components";import{Panel as a}from"@redocly/theme
|
|
|
199
199
|
transform: ${o=>o.isOpen?"rotate(90deg)":"rotate(0deg)"};
|
|
200
200
|
transition: transform 0.3s ease-in-out;
|
|
201
201
|
`,i=r.div`
|
|
202
|
-
border-radius: var(--border-radius);
|
|
202
|
+
border-radius: var(--tag-border-radius);
|
|
203
203
|
padding: 0 var(--spacing-xxs);
|
|
204
204
|
font-family: var(--font-family-monospaced);
|
|
205
205
|
font-size: var(--font-size-sm);
|
|
@@ -216,4 +216,4 @@ import{styled as r}from"styled-components";import{Panel as a}from"@redocly/theme
|
|
|
216
216
|
display: inline-flex;
|
|
217
217
|
align-items: center;
|
|
218
218
|
gap: var(--spacing-xxs);
|
|
219
|
-
`;export{u as CloseButton,f as Conjunction,A as DeprecatedBadge,T as FlowDescription,F as FlowProperties,S as FlowTitle,k as FlowTitleWrapper,O as FlowTypeBody,L as FlowTypeName,B as FlowTypeSection,R as FlowTypeTag,z as FlowWrapper,h as ModalBackground,w as ModalTitle,y as ModalWrapper,I as OptionalScopesChevron,H as OptionalScopesList,V as OptionalScopesToggle,j as PropertyLabel,P as PropertyRow,$ as PropertyValue,C as SchemeLink,m as SchemeName,b as ScopeInline,N as ScopeTag,M as ScopesLabel,W as ScopesList,D as ScopesSection,
|
|
219
|
+
`;export{u as CloseButton,f as Conjunction,A as DeprecatedBadge,T as FlowDescription,F as FlowProperties,S as FlowTitle,k as FlowTitleWrapper,O as FlowTypeBody,L as FlowTypeName,B as FlowTypeSection,R as FlowTypeTag,z as FlowWrapper,h as ModalBackground,w as ModalTitle,y as ModalWrapper,I as OptionalScopesChevron,H as OptionalScopesList,V as OptionalScopesToggle,j as PropertyLabel,P as PropertyRow,$ as PropertyValue,C as SchemeLink,m as SchemeName,b as ScopeInline,N as ScopeTag,M as ScopesLabel,W as ScopesList,D as ScopesSection,g as SecurityHeader,x as SecurityList,c as SecurityPanel,i as Tag,v as Title,d as ViewDetailsButton};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const FloatingButton: () => React.JSX.Element;
|