@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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import{jsx as r,jsxs as e}from"react/jsx-runtime";import{styled as o}from"styled-components";const s=o.div`
|
|
2
2
|
border: 1px solid var(--border-color-secondary, var(--border-color-primary));
|
|
3
|
-
border-radius: var(--border-radius);
|
|
3
|
+
border-radius: var(--panel-border-radius);
|
|
4
4
|
background-color: var(--panel-bg-color, var(--bg-color));
|
|
5
5
|
margin-top: var(--spacing-base);
|
|
6
6
|
`,l=o.div`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as p}from"react/jsx-runtime";import{memo as x,useMemo as h,useEffect as L}from"react";import{createStore as A,Provider as E,useStore as j,getDefaultStore as N}from"jotai";import{LayoutVariant as _}from"@redocly/config";import{createStoreContext as k,toRecord as M}from"../adapters/helpers.js";import{populateOpenApiStore as T}from"../adapters/openapi/store.js";import{DEFAULT_MAX_DISPLAYED_ENUM_VALUES as F}from"../options/constants.js";import{normalizeOptions as U}from"../options/normalizeOptions.js";import{globalStoreAtom as d}from"../jotai/store.js";import{appStore as O,environmentAtom as V,layoutAtom as v,userClaimsAtom as y}from"../jotai/app.js";import{buildServerEnvValues as w}from"../services/code-samples/
|
|
1
|
+
import{jsx as p}from"react/jsx-runtime";import{memo as x,useMemo as h,useEffect as L}from"react";import{createStore as A,Provider as E,useStore as j,getDefaultStore as N}from"jotai";import{LayoutVariant as _}from"@redocly/config";import{createStoreContext as k,toRecord as M}from"../adapters/helpers.js";import{populateOpenApiStore as T}from"../adapters/openapi/store.js";import{DEFAULT_MAX_DISPLAYED_ENUM_VALUES as F}from"../options/constants.js";import{normalizeOptions as U}from"../options/normalizeOptions.js";import{globalStoreAtom as d}from"../jotai/store.js";import{appStore as O,environmentAtom as V,layoutAtom as v,userClaimsAtom as y}from"../jotai/app.js";import{buildServerEnvValues as w}from"../services/code-samples/server-env.js";const z={ignoreNamedSchemas:["java.io.ObjectStreamField"],maxDisplayedEnumValues:F};function P(e,n){const t={...z,...e,basePath:n};return U(t)}const C=new WeakSet;function g(e){C.has(e)||(C.add(e),e.sub(O,()=>{}))}function b(e,n){if(!n?.servers?.length)return;g(e);const t=w(n.servers),i=e.get(O).environments??{},m={};for(const[s,a]of Object.entries(t)){const c=i[s],r=c?Object.fromEntries(Object.entries(a).filter(([o])=>!(o in c))):a;Object.keys(r).length>0&&(m[s]=r)}Object.keys(m).length!==0&&e.set(V,{environments:m})}function Z(e){const n=x(t=>{const{items:i,options:m,store:s,layout:a,basePath:c=""}=t,r=j(),o=r!==N()?r:void 0,u=h(()=>P(m,c),[m,c]),S=a??u.layout;L(()=>{if(o){const f=o.get(d);b(o,s??f.store),o.set(v,S),o.set(y,u.userClaims??{}),o.set(d,{items:i,store:s??f.store,options:u,replayDefinition:f.replayDefinition})}},[S,u,o,i,s]);const D=h(()=>{if(o)return null;const f={items:i,store:s,options:u,replayDefinition:null},l=A();return l.set(d,f),g(l),l.set(v,S),u.userClaims&&l.set(y,u.userClaims),b(l,s),l},[o,i,s,u,S]);return o||!D?p(e,{...t}):p(E,{store:D,children:p(e,{...t})})});return n.displayName=`WithStoreProvider(${I(e)})`,n}function I(e){return e.displayName||e.name||"Component"}function q(e,n){const t=k(M(e));return T(e,t,n),{schemaStore:t.schemaStore,exampleStore:t.exampleStore,securitySchemeStore:t.securitySchemeStore,mcp:t.document["x-mcp"],schemaCatalogLink:t.document["x-schema-catalog-link"]}}const ee=x(function({children:n,definition:t,apiStore:i,options:m}){const s=h(()=>{const a=P({specType:"openapi",...m},m?.basePath??"");let c;if(i)c=i;else if(t)c=q(t,a);else throw new Error("StoreProvider requires either apiStore or definition");const r=A();return r.set(d,{items:[],store:c,options:a,replayDefinition:null}),g(r),r.set(v,_.STACKED),a.userClaims&&r.set(y,a.userClaims),b(r,c),r},[i,t,m]);return p(E,{store:s,children:n})});export{ee as StoreProvider,Z as withStoreProvider};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(){}export{e as useInitialTelemetry};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useEffect as
|
|
1
|
+
import{useEffect as c}from"react";import{useAtomValue as s,useSetAtom as l}from"jotai";import{useHref as m,useLocation as a}from"react-router";import{IS_BROWSER as f,useActiveSectionId as u}from"@redocly/theme/core/openapi";import{activeScrollSectionAtom as p}from"../jotai/app.js";import{routingBasePathAtom as S}from"../jotai/store.js";import{encodeBackSlashes as d}from"../utils/string.js";import{normalizePath as h}from"../utils/url.js";import{useUserScrollIntent as w}from"./useUserScrollIntent.js";import{URL_REPLACE_EVENT as E}from"./useRouterHashBridge.js";function A(t){window.history.replaceState({},"",t),window.dispatchEvent(new Event(E))}function k(){const t=a(),e=l(p),r=s(S),o=u(t,!1,!1),n=m(h(d(o||"/"))),i=w(t.key);c(()=>{e(null)},[t.pathname,e]),c(()=>{!f||!o||(e(o),i.current&&(o===r||!window.location.pathname.includes(o)&&!window.location.hash.includes(o))&&A(n))},[o,n,r,e,i])}export{k as useScrollSpyUrlSync};
|
package/lib/index.d.ts
CHANGED
|
@@ -33,6 +33,9 @@ export { RedoclyApiDocs } from './RedoclyApiDocs.js';
|
|
|
33
33
|
export type { RedoclyApiDocsProps } from './RedoclyApiDocs.js';
|
|
34
34
|
export { RedoclyApiDocsStandalone } from './RedoclyApiDocsStandalone.js';
|
|
35
35
|
export type { RedoclyApiDocsStandaloneProps } from './RedoclyApiDocsStandalone.js';
|
|
36
|
+
export type { RedocStandaloneProps } from './RedocStandalone.js';
|
|
37
|
+
export { ApiDocsSearchIndexer } from './services/search/indexer.js';
|
|
38
|
+
export type { SearchDocument, SearchItemData } from './services/search/types.js';
|
|
36
39
|
export { RedocTelemetry } from './telemetry/RedocTelemetry.js';
|
|
37
40
|
export type { RedocTelemetryConfig, SpecType } from './telemetry/RedocTelemetry.js';
|
|
38
41
|
export { Replay, EmbeddedReplay } from './components/Replay/index.js';
|
package/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./types/common.js";import{buildItems as t,buildNavItems as p}from"./adapters/build.js";import{buildGraphqlStoreFromSdl as m}from"./adapters/graphql/buildStoreFromSdl.js";import{simplifyAstStructure as d}from"./adapters/utils/simplifyAstStructure.js";import{extractFullText as f}from"./adapters/utils/markdoc.js";import{normalizeOptions as l}from"./options/normalizeOptions.js";import{excludeMockServers as c}from"./adapters/openapi/utils/merge-mock-server.js";import{appendUndeclaredConfigureParameters as S}from"./services/code-samples/replay/merge-configure-into-source.js";import{isGraphqlDocsSidebarHidden as y}from"./options/helpers.js";import{findFirstBinding as
|
|
1
|
+
export*from"./types/common.js";import{buildItems as t,buildNavItems as p}from"./adapters/build.js";import{buildGraphqlStoreFromSdl as m}from"./adapters/graphql/buildStoreFromSdl.js";import{simplifyAstStructure as d}from"./adapters/utils/simplifyAstStructure.js";import{extractFullText as f}from"./adapters/utils/markdoc.js";import{normalizeOptions as l}from"./options/normalizeOptions.js";import{excludeMockServers as c}from"./adapters/openapi/utils/merge-mock-server.js";import{appendUndeclaredConfigureParameters as S}from"./services/code-samples/replay/merge-configure-into-source.js";import{isGraphqlDocsSidebarHidden as y}from"./options/helpers.js";import{findFirstBinding as D}from"./adapters/asyncapi/build/utils.js";import{resolveRequestValues as M,applyRequestValuesToOperationInfo as P}from"./adapters/openapi/configure/index.js";import{updateObjectProperties as A,isDirectRequestValues as b,getEffectiveRequestValues as h,createSecurityUpdates as k,mergeSecurityIntoScheme as E,applyServerVariableDefaults as O}from"./adapters/openapi/configure/merge-utils.js";import{MarkdownAdapterProvider as q,useMarkdownAdapter as V}from"./contexts/markdownAdapter.js";import{markdocParser as C}from"./components/markdoc/markdocParser.js";import{createMarkdocAdapter as N}from"./components/markdoc/markdocAdapter.js";import{parseMarkdown as B}from"./adapters/utils/parseMarkdown.js";import{isPlainText as H}from"./adapters/utils/isPlainText.js";import{buildMarkdocOptions as J}from"./components/markdoc/buildMarkdocOptions.js";import{apiDocsMarkdocTags as Y,apiDocsMarkdocNodes as j}from"./components/markdoc/defaultMarkdocConfig.js";import{apiDocsMarkdocComponents as K}from"./components/markdoc/apiDocsMarkdocComponents.js";import{RedoclyApiDocs as W}from"./RedoclyApiDocs.js";import{RedoclyApiDocsStandalone as Z}from"./RedoclyApiDocsStandalone.js";import{ApiDocsSearchIndexer as ee}from"./services/search/indexer.js";import{RedocTelemetry as oe}from"./telemetry/RedocTelemetry.js";import{Replay as pe,EmbeddedReplay as ae}from"./components/Replay/index.js";import{REPLAY_TRY_IT_LOADING_STATE as ie}from"./services/code-samples/index.js";import{findExampleIdByKey as se}from"./services/code-samples/example-key.js";import{RedocSchema as xe,RedocExample as le,RedocResponseSamples as ne,RedocCodeSample as ce}from"./components/pluggable/index.js";import{StoreProvider as Se}from"./hoc/withStoreProvider.js";import{GraphQLTypeViewByName as ye}from"./components/graphql/GraphQLTypeView.js";import{mcpTagSchemas as De}from"./components/markdoc/tags/mcp-tag-schemas.js";import{schemaDefinitionTag as Me}from"./components/markdoc/tags/schema-definition-tag.js";import{withReplayPrefetch as ve,useOpenApiDefinition as Ae}from"./hoc/withReplayPrefetch.js";import{mergeEnvData as he}from"./utils/environments.js";import{buildReplayPredefinedEnvValues as Ee}from"./services/code-samples/replay/replay-predefined-env.js";import{encodeJsonPointerSegment as Ie}from"./utils/refPointer.js";import{JsonPointer as Ve}from"./adapters/openapi/utils/JsonPointer.js";import{langFromMime as Ce,encodeExampleForMediaType as Fe}from"./utils/media-type.js";import{isOperationName as _e,HTTP_METHODS as Be}from"./utils/http-methods.js";import{convertSampleToString as He}from"./services/code-samples/convertSampleToString.js";import{resolveOperationSampleContext as Je,buildCodeSamples as Ue,getRequestBodySamples as Ye,getResponseSamples as je}from"./services/operation-samples/index.js";export{ee as ApiDocsSearchIndexer,ae as EmbeddedReplay,ye as GraphQLTypeViewByName,Be as HTTP_METHODS,Ve as JsonPointer,q as MarkdownAdapterProvider,ie as REPLAY_TRY_IT_LOADING_STATE,ce as RedocCodeSample,le as RedocExample,ne as RedocResponseSamples,xe as RedocSchema,oe as RedocTelemetry,W as RedoclyApiDocs,Z as RedoclyApiDocsStandalone,pe as Replay,Se as StoreProvider,K as apiDocsMarkdocComponents,j as apiDocsMarkdocNodes,Y as apiDocsMarkdocTags,S as appendUndeclaredConfigureParameters,P as applyRequestValuesToOperationInfo,O as applyServerVariableDefaults,Ue as buildCodeSamples,m as buildGraphqlStoreFromSdl,t as buildItems,J as buildMarkdocOptions,p as buildNavItems,Ee as buildReplayPredefinedEnvValues,He as convertSampleToString,N as createMarkdocAdapter,k as createSecurityUpdates,Fe as encodeExampleForMediaType,Ie as encodeJsonPointerSegment,c as excludeMockServers,f as extractFullText,se as findExampleIdByKey,D as findFirstBinding,h as getEffectiveRequestValues,Ye as getRequestBodySamples,je as getResponseSamples,b as isDirectRequestValues,y as isGraphqlDocsSidebarHidden,_e as isOperationName,H as isPlainText,Ce as langFromMime,C as markdocParser,De as mcpTagSchemas,he as mergeEnvData,E as mergeSecurityIntoScheme,l as normalizeOptions,B as parseMarkdown,Je as resolveOperationSampleContext,M as resolveRequestValues,Me as schemaDefinitionTag,d as simplifyAstStructure,A as updateObjectProperties,V as useMarkdownAdapter,Ae as useOpenApiDefinition,ve as withReplayPrefetch};
|
package/lib/jotai/app.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export type AppSessionStore = {
|
|
|
15
15
|
export type AppStore = {
|
|
16
16
|
activeMimeName: string;
|
|
17
17
|
layout: LayoutVariant;
|
|
18
|
+
colorMode: string;
|
|
18
19
|
language: string;
|
|
19
20
|
environment: string;
|
|
20
21
|
environments: Record<string, Record<string, string>>;
|
|
@@ -47,6 +48,11 @@ export declare const allowedEnvironmentsAtom: import("jotai").WritableAtom<strin
|
|
|
47
48
|
* appSessionStore saved to session storage
|
|
48
49
|
*/
|
|
49
50
|
export declare const appSessionStore: import("jotai").WritableAtom<AppSessionStore, [typeof import("jotai/utils").RESET | AppSessionStore | ((prev: AppSessionStore) => typeof import("jotai/utils").RESET | AppSessionStore)], void>;
|
|
51
|
+
/** Mobile sidebar drawer — open state is per-view, never persisted. */
|
|
52
|
+
export declare const isSidebarOpenedAtom: import("jotai").PrimitiveAtom<boolean> & {
|
|
53
|
+
init: boolean;
|
|
54
|
+
};
|
|
55
|
+
export declare const colorModeAtom: import("jotai").WritableAtom<string, string[], void>;
|
|
50
56
|
export declare const collapsedSidebarAtom: import("jotai").WritableAtom<boolean, boolean[], void>;
|
|
51
57
|
export declare const languageAtom: import("jotai").WritableAtom<LanguageAtom, [string], void>;
|
|
52
58
|
export declare const selectedSecuritySchemeIdxAtom: import("jotai").PrimitiveAtom<number> & {
|
package/lib/jotai/app.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{atom as r}from"jotai";import{atomWithStorage as
|
|
1
|
+
import{atom as r}from"jotai";import{atomWithStorage as g,createJSONStorage as y}from"jotai/utils";import{LayoutVariant as O}from"@redocly/config";import{DEFAULT_COLOR_MODES as c}from"@redocly/theme/core/constants";import{getCookie as E,removeCookie as L,setCookie as k}from"../utils/cookies.js";import{mergeEnvData as p,IS_BROWSER as d}from"../utils/environments.js";import{keepReadingSectionAnchored as C}from"../utils/scroll-anchoring.js";import{safeJsonParse as S}from"../utils/string.js";import{fromSessionStorage as M,toSessionStorage as h}from"../utils/session-storage.js";import{DEFAULT_LAYOUT as N}from"../options/constants.js";import{globalOptionsAtom as T}from"./store.js";const f={activeMimeName:"",layout:N,colorMode:"",language:"",environment:"",environments:{},userClaims:{},allowedEnvironments:null},b={getItem:e=>{const o=S(E(e,globalThis.redoclyCookieStorage?.getStore?.())),t=S(M(e));return{...f,...t,...o}},setItem:(e,o)=>{const{environments:t,...n}=o,a={environments:t};k(e,JSON.stringify(n)),h(e,JSON.stringify(a))},removeItem:e=>{L(e),sessionStorage.removeItem(e)}},s=g("redoc.appStore",f,b),H=r(e=>{const o=e(s);return p(o.environments,{})}),W=r(e=>{const o=e(s),t=p(o.environments,{}),n=o.environment,a=Object.keys(t).find(l=>t[l]?.server===n),i=t[n]?n:a??Object.keys(t)[0];let m=t[i]||{};return!m.server&&a&&(m={...t[a],...m}),[m,i||""]},(e,o,{environment:t,environments:n})=>{const a=e(s);o(s,{...a,environment:t||a.environment,environments:p(a.environments||{},n)})}),B=r(e=>e(s).environment),u=r(e=>e(s).activeMimeName,(e,o,t)=>{const n=e(s);o(s,{...n,activeMimeName:t})}),A=r(void 0),P=r(e=>e(A)??(e(u)||void 0),(e,o,t)=>{o(A,void 0),(t??"")!==e(u)&&C(),o(u,t??"")}),Y=r(e=>e(s).layout,(e,o,t=O.STACKED)=>{const n=e(s);o(s,{...n,layout:t})}),z=r(e=>e(s).userClaims,(e,o,t)=>{const n=e(s);o(s,{...n,userClaims:t})}),Q=r(e=>e(s).allowedEnvironments,(e,o,t)=>{const n=e(s);o(s,{...n,allowedEnvironments:t})}),v=g("redoc.appSessionStore",{collapsedSidebar:!1,unsupportedFeatureScreen:!1},d?y(()=>sessionStorage):void 0),X=r(!1),D=[c.LIGHT,c.DARK];function I(e){const o=document.documentElement;D.forEach(t=>o.classList.remove(t)),o.classList.add(e,"notransition"),window.requestAnimationFrame(()=>{o.classList.remove("notransition")})}const Z=r(e=>{const o=e(s).colorMode||(d&&window.matchMedia?.("(prefers-color-scheme: dark)").matches?c.DARK:c.LIGHT);return d&&I(o),o},(e,o,t)=>{const n=e(s);o(s,{...n,colorMode:t})}),$=r(e=>e(v).collapsedSidebar,(e,o,t)=>{const n=e(v);o(v,{...n,collapsedSidebar:t})}),ee=r(e=>{const o=e(T),{codeSamples:t}=o;if(!t?.languages)return{languages:[],activeLanguage:e(s).language||""};const n=t.languages.map(({key:i,label:m,lang:l},x)=>({key:i,lang:l,title:m,order:x})),a=e(s).language||n[0]?.key;return{languages:n,activeLanguage:n.find(({key:i})=>i===a)?.key||n[0]?.key}},(e,o,t)=>{const n=e(s);o(s,{...n,language:t})}),oe=r(0),te=r({}),ne=r(null),se=r([]);export{P as activeMediaTypeAtom,u as activeMimeNameAtom,ne as activeScrollSectionAtom,Q as allowedEnvironmentsAtom,v as appSessionStore,s as appStore,$ as collapsedSidebarAtom,Z as colorModeAtom,W as environmentAtom,H as environmentsAtom,X as isSidebarOpenedAtom,ee as languageAtom,Y as layoutAtom,A as mediaTypeOverrideAtom,te as requestValuesAtom,B as savedEnvironmentNameAtom,oe as selectedSecuritySchemeIdxAtom,z as userClaimsAtom,se as visitedChannelsAtom};
|
package/lib/jotai/examples.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{atom as m}from"jotai";import{atomFamily as f}from"jotai-family";import*as
|
|
1
|
+
import{atom as m}from"jotai";import{atomFamily as f}from"jotai-family";import*as E from"openapi-sampler";import{schemaKind as g}from"../types/common.js";import{convertSampleToString as y}from"../services/code-samples/index.js";import{applyActiveVariantsToStore as h}from"../services/code-samples/discriminator.js";import{isSequentialMediaType as M}from"../utils/media-type.js";import{storeAtom as j,globalOptionsAtom as x}from"./store.js";import{schemaStoreAtom as l}from"./schema.js";import{activeDiscriminatorSelectAtom as F,activeOneOfSelectAtom as N}from"./itemStore.js";const G=m(t=>t(j).exampleStore??{});function A(t){const e={};for(const[n,r]of Object.entries(t)){const o=n.startsWith("components/schemas/")?n.replace("components/schemas/",""):n;e[o]=r}return{openapi:"3.0.0",info:{title:"",version:""},paths:{},components:{schemas:e}}}function R(t,e){return!!t&&Object.keys(t).length>0||!!e&&Object.keys(e).length>0}const u=m(t=>h(t(l))),O=f(t=>m(e=>{if(!t)return e(u);const n=e(F(t)),r=e(N(t));return R(n,r)?h(e(l),n,r):e(u)})),V=m(t=>A(t(u))),C=f(t=>m(e=>{const n=e(O(t));return n===e(u)?e(V):A(n)})),D="";function Q(t,e,n,r){return t?JSON.stringify({itemId:r??"",schemaId:t,context:e??"",mediaType:n??""}):D}function J(t){if(t)try{const e=JSON.parse(t);if(!e||typeof e.schemaId!="string"||!e.schemaId)return;const n=typeof e.itemId=="string"?e.itemId:"",r=typeof e.context=="string"?e.context:"",o=typeof e.mediaType=="string"?e.mediaType:"";return{itemId:n,schemaId:e.schemaId,context:r==="request"||r==="response"?r:void 0,mediaType:o||void 0}}catch{return}}const U=f(t=>{const e=J(t);return m(n=>{if(!e)return;const{itemId:r,schemaId:o,context:i,mediaType:p}=e,s=n(l)[o];if(!s||s.kind!==g.JSON_SCHEMA)return;const d=n(C(r)),v=n(O(r))[o]??s.data,{onlyRequiredInSamples:I,generatedSamplesMaxDepth:T}=n(x),{unstable_skipSamples:k}=n(x);if(k)return;const a=p?.toLowerCase(),q=a?a.includes("xml"):!1;try{const S={context:i,skipNonRequired:i==="request"&&I,maxSampleDepth:T,isXml:q},c=b(v,d,S);return c==null?c:a&&M(a)?K(s.data,c,d,S,a):c}catch{return}})});function K(t,e,n,r,o){const i=_(t);if(i.length>0){const p=i.map(s=>b(s,n,r)).filter(s=>s!=null);if(p.length>0)return y(p,o,t,!1)}return y(e,o,t,!0)}function _(t){const e=t.oneOf;return Array.isArray(e)?e.filter(n=>typeof n=="object"&&n!==null):[]}function b(t,e,{context:n,skipNonRequired:r,maxSampleDepth:o,isXml:i}){return E.sample(t,{skipReadOnly:n==="request",skipWriteOnly:n==="response",quiet:!0,skipNonRequired:r,maxSampleDepth:o,...i&&{format:"xml"}},e)}export{Q as buildExampleAtomKey,G as exampleStoreAtom,U as generatedExampleAtom,C as itemSpecForSamplerAtom};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { RawApiDocsOptions } from '../types/options.js';
|
|
2
|
+
/** Option overrides applied on top of host options in `normalizeOptions`. The community edition forces enterprise options off here. */
|
|
3
|
+
export declare const EDITION_OPTION_OVERRIDES: Partial<RawApiDocsOptions>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const I={};export{I as EDITION_OPTION_OVERRIDES};
|
package/lib/options/helpers.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LayoutVariant, type RedocConfig } from '@redocly/config';
|
|
2
2
|
import type { ApiSpecType } from '../types/common.js';
|
|
3
3
|
import type { RawApiDocsOptions } from '../types/options.js';
|
|
4
|
-
import type { CodeSamplesConfig } from '../types/
|
|
4
|
+
import type { CodeSamplesConfig } from '../types/code-samples-config.js';
|
|
5
5
|
export declare function argValueToBoolean(val?: string | boolean, defaultValue?: boolean): boolean;
|
|
6
6
|
export declare function argValueToNumber(value: number | string | undefined, defaultValue?: number): number;
|
|
7
7
|
export declare function argValueToInt(value: number | string | undefined, defaultValue?: number): number;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { ApiDocsOptions, RawApiDocsOptions } from '../types/options.js';
|
|
2
|
-
export declare function normalizeOptions(
|
|
2
|
+
export declare function normalizeOptions(rawOptions: RawApiDocsOptions): ApiDocsOptions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{addTrailingSlash as
|
|
1
|
+
import{addTrailingSlash as r}from"@redocly/theme/core/openapi";import{WindowReferenceOptions as n}from"../constants/openapi.js";import{argValueToBoolean as a,argValueToExpandLevel as o,argValueToInt as s,argValueToNumber as t,normalizeCodeSamples as d,normalizeDownloadUrls as m,normalizeIgnoreNamedSchemas as p,normalizeLayout as S,normalizePath as E,normalizeScrollYOffset as h,normalizeShowExtensions as c}from"./helpers.js";import{ASYNCAPI_DEFAULT_JSON_SAMPLES_DEPTH as _,DEFAULT_FEEDBACK as u,DEFAULT_MAX_DISPLAYED_ENUM_VALUES as L,GENERATED_SAMPLES_MAX_DEPTH_DEFAULT as f,GRAPHQL_DEFAULT_FIELD_EXPAND_LEVEL as P,GRAPHQL_DEFAULT_JSON_SAMPLES_DEPTH as A,GRAPHQL_DEFAULT_SAMPLES_MAX_INLINE_ARGS as D,JSON_SAMPLES_EXPAND_LEVEL_DEFAULT as i,MOCK_SERVER_DEFAULT_DESCRIPTION as T,MOCK_SERVER_DEFAULT_POSITION as I,DEFAULT_ROUTING_BASE_PATH as R}from"./constants.js";import{apiSpecType as x}from"../types/common.js";import{EDITION_OPTION_OVERRIDES as N}from"./editionOverrides.js";function b(l){const e={...l,...N};return{specType:e.specType,licenseKey:e.licenseKey,metadata:e.metadata??{},downloadUrls:m(e.downloadUrls??[],e.specType),userClaims:e.userClaims,dynamicRequestValues:e.dynamicRequestValues,schemaDefinitionsTagName:e.schemaDefinitionsTagName,corsProxyUrl:e.corsProxyUrl?r(e.corsProxyUrl):void 0,hideSidebar:a(e.hideSidebar,!1),hideSearch:a(e.hideSearch,!1),jsonSamplesExpandLevel:o(e.jsonSamplesExpandLevel,i)??i,generatedSamplesMaxDepth:s(e.generatedSamplesMaxDepth,f),hideDownloadButtons:a(e.hideDownloadButtons,!1),hideInfoMetadata:a(e.hideInfoMetadata,!1),hideLoading:a(e.hideLoading,!1),hideSchemaTitles:a(e.hideSchemaTitles,!1),hideSchemaPattern:a(e.hideSchemaPattern,!1),maxDisplayedEnumValues:t(e.maxDisplayedEnumValues,L),mockServer:e.mockServer?.url?{url:e.mockServer.url,position:e.mockServer.position||I,description:e.mockServer.description||T}:void 0,hideReplay:a(e.hideReplay,!1),oAuth2RedirectURI:e.oAuth2RedirectURI,onlyRequiredInSamples:a(e.onlyRequiredInSamples,!1),[n.ON_DEEP_LINK_CLICK]:e.onDeepLinkClick??null,basePath:e.basePath?E(e.basePath):R,schemasExpansionLevel:o(e.schemasExpansionLevel),feedback:e.feedback??u,sortRequiredPropsFirst:a(e.sortRequiredPropsFirst??e.requiredPropsFirst,!1),scrollYOffset:h(e.scrollYOffset),showExtensions:c(e.showExtensions),sanitize:a(e.sanitize,!1),skipBundle:a(e.skipBundle,!1),ignoreNamedSchemas:new Set(p(e.ignoreNamedSchemas)),markdocOptions:e.markdocOptions,markdownParser:e.markdownParser,codeSamples:d(e.codeSamples),layout:S(e.layout),events:e.events??{},unstable_hooks:e.unstable_hooks??{},unstable_skipSamples:a(e.unstable_skipSamples,!1),unstable_externalCodeSamples:e.unstable_externalCodeSamples??[],hidePropertiesPrefix:a(e?.hidePropertiesPrefix,!1),showSchemaCatalogLinks:a(e?.showSchemaCatalogLinks,!1),baseUrlPath:e.baseUrlPath,jsonSamplesDepth:s(e.jsonSamplesDepth,e.specType===x.ASYNCAPI?_:A),samplesMaxInlineArgs:s(e.samplesMaxInlineArgs,D),fieldExpandLevel:s(e.fieldExpandLevel,P),menu:e.menu,sidebar:e.sidebar,showBuiltInScalars:e.showBuiltInScalars,showBuiltInDirectives:e.showBuiltInDirectives,info:e.info,markdown:e.markdown,apiLogo:e.apiLogo,protocol:e.protocol}}export{b as normalizeOptions};
|
package/lib/pages/ItemPage.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{jsx as r,jsxs as
|
|
1
|
+
import{jsx as r,jsxs as d}from"react/jsx-runtime";import{Fragment as v,memo as u}from"react";import{styled as p}from"styled-components";import{useAtomValue as s}from"jotai";import{ComponentMapper as k}from"../components/Mapper.js";import{SchemaCatalogLink as y}from"../components/SchemaCatalogLink.js";import{RenderHook as c}from"../components/RenderHook.js";import{ContentWrapper as l}from"../components/common/ContentWrapper.js";import{globalOptionsAtom as I}from"../jotai/store.js";import{routingBasePathAtom as x}from"../jotai/store.js";import{compose as A}from"../utils/compose.js";import{toElementId as O}from"../utils/url.js";import{withItemId as C}from"../hoc/withItemId.js";import{SECTION_ATTR as T}from"../constants/openapi.js";function j({content:o,itemPath:e,sectionId:i}){const{children:f}=o||{},a=o?.meta?.pointer,{unstable_hooks:n}=s(I),g=s(x),b=i?{[T]:i}:{},h=e?O(e,g):void 0;return d(P,{id:h,...b,"data-item-kind":o.itemVariant,"data-has-divider":o.showDivider||void 0,children:[r(c,{Hook:n?.BeforeOperation,props:{operation:o}}),f?.map((t,m)=>d(v,{children:[r(k,{type:t.nodeType,node:t,itemPath:e}),m===0&&a&&r(l,{children:r(y,{schemaRef:"#"+a})})]},`${e}-${t.nodeType}-${m}`)),r(c,{Hook:n?.AfterOperation,props:{operation:o}}),o.showDivider&&r(l,{children:r(w,{})})]})}const q=A(C,u)(j),w=p.div`
|
|
2
2
|
border-bottom: 1px solid var(--border-color-secondary);
|
|
3
3
|
`,P=p.div`
|
|
4
4
|
padding-top: calc(var(--spacing-unit) * 16);
|
|
@@ -10,9 +10,11 @@ import{jsx as r,jsxs as m}from"react/jsx-runtime";import{Fragment as v,memo as u
|
|
|
10
10
|
padding-top: calc(var(--spacing-unit) * 16);
|
|
11
11
|
padding-bottom: 0;
|
|
12
12
|
|
|
13
|
+
// @community-ignore
|
|
13
14
|
[data-component-name='FeedbackItem'] {
|
|
14
15
|
margin: 0;
|
|
15
16
|
}
|
|
17
|
+
// @community-ignore-end
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
&[data-item-kind='channel'],
|
|
@@ -23,4 +25,4 @@ import{jsx as r,jsxs as m}from"react/jsx-runtime";import{Fragment as v,memo as u
|
|
|
23
25
|
&[data-item-kind='channelOperation']:not([data-has-divider]) {
|
|
24
26
|
border-bottom: 1px solid var(--border-color-secondary);
|
|
25
27
|
}
|
|
26
|
-
`;export{
|
|
28
|
+
`;export{q as ItemPage};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CodeSampleRequestValues } from './source.js';
|
|
2
|
+
/**
|
|
3
|
+
* Substitutes `{{name}}` environment-variable placeholders in a sample using
|
|
4
|
+
* the base env variables plus the active server's scoped overrides.
|
|
5
|
+
* `requestValues.serverEnvVariables` is keyed by the raw (templated) spec
|
|
6
|
+
* server URL.
|
|
7
|
+
*/
|
|
8
|
+
export declare function applyEnvVariables(sample: string, requestValues: CodeSampleRequestValues | undefined, activeServerSpecUrl: string | undefined): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function o(a,n,r){const l={...n?.envVariables,...r&&n?.serverEnvVariables?.[r]};let e=a;for(const[s,t]of Object.entries(l))e=e.replaceAll(`{{${s}}}`,t);return e}export{o as applyEnvVariables};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import $ from"url-template";import{SecurityVariablesEnvSuffix as g}from"@redocly/theme/core/openapi";import{mergeBodyValue as F}from"../../adapters/openapi/configure/merge-utils.js";import{formUrlEncodeValue as K,stringifyFormFieldValue as E}from"../../utils/form-urlencoded.js";import{isSequentialMediaType as H}from"../../utils/media-type.js";import{parseMultipartFormData as M}from"../../utils/multipart.js";import{objectToHarParams as J}from"../../utils/serialize-querystring.js";import{jsonToXml as L}from"../../utils/xml.js";import{MediaTypes as k}from"../../constants/openapi.js";import{convertSampleToString as Y}from"./convertSampleToString.js";import{findExampleIdByKey as Q,mediaTypeContainingKey as X}from"./example-key.js";import{resolveServerUrl as G}from"./replay/normalize-servers.js";import{serverMatchesUrl as W}from"./server-variables.js";function Ie(e,n,a,r){const o=e.servers.find(f=>W(f,n.serverUrl))||e.servers[0],u=o?.url?.replace(/\/$/,"")??"",c=u?G(u).replace(/\/$/,""):"",t={};if(o?.variables)for(const[f,A]of Object.entries(o.variables))t[f]=n.environment?.[f]||A.default||"";const l=e.path.replace(/^\//,""),s=`${c}/${l}`,d={skipReadOnly:!0,maxDepth:a.generatedPayloadSamplesMaxDepth??8,format:"json"},i=o?.url??n.serverUrl??"",p=n.requestValues??{},m=Z(e.security,n.activeSecuritySchemeIds),y=ee(m,n,a,i),S=b(e.parameters.header,"header",i,p,a,r,d).concat(y.headers),h=n.mediaType||X(e.requestBody,n.exampleName,r.resolveExample)||(e.requestBody?Object.keys(e.requestBody)[0]:void 0);let R=!1;for(const f of S)f.name.toLowerCase()==="content-type"&&h&&(f.value=h,R=!0);!R&&h&&S.unshift({name:"Content-Type",value:h});const v=b(e.parameters.cookie,"cookie",i,p,a,r,d).concat(y.cookies),O=e.parameters.querystring.length>0,C=b(O?e.parameters.querystring:e.parameters.query,O?"querystring":"query",i,p,a,r,d).concat(y.queries),U={};for(const f of e.parameters.path)U[f.name]=p.path?.[f.name]||f.serverValues?.[i]?.example||f.example||"";let x;if(h&&e.requestBody?.[h]){const f=e.requestBody[h],A=e.requestValues?.serverBody?.[i]??e.requestValues?.body;x=le(f,h,n,r,d,i,A)}const w={};for(const f of S)w[f.name]=f.value;const I={};v.length&&(I.cookie=v.map(f=>`${encodeURIComponent(f.name)}=${encodeURIComponent(f.value)}`).join("; ")),Object.assign(I,w);const j={};for(const f of C)V(j,f.name,f.value);const B=x?.text?ue(x.text):void 0;let _;if(x?.params?.length){_={};for(const f of x.params)V(_,f.name,f.value??"")}const P=C.map(f=>`${encodeURIComponent(f.name)}=${encodeURIComponent(f.value)}`).join("&"),q=P?`${s}?${P}`:s;return{method:e.method.toUpperCase(),url:s,pathname:q,httpVersion:"HTTP/1.1",cookies:v,headers:S,queryString:C,postData:x,headersSize:-1,bodySize:-1,fullUrl:q,headersObj:w,allHeaders:I,queryObj:j,jsonObj:B,paramsObj:_,basicAuth:y.basicAuth,pathParameters:U,serverVariables:t,responseCodes:e.responseCodes,allResponseCodes:e.responseCodes,oAuth2PreRequests:y.oAuth2PreRequests}}function V(e,n,a){const r=e[n];r===void 0?e[n]=a:Array.isArray(r)?r.push(a):e[n]=[r,a]}function Z(e,n){if(e.length){if(n?.length){const a=e.find(r=>{const o=r.schemes.map(u=>u.id);return o.length===n.length&&o.every(u=>n.includes(u))});if(a)return a}return e[0]}}function ee(e,n,a,r){const o={headers:[],cookies:[],queries:[]};if(!e)return o;for(const u of e.schemes)ne(u,o,n,a,r,e.scopes);return o}const te={"x-defaultUsername":g.Username,"x-defaultPassword":g.Password,"x-defaultClientId":g.ClientId,"x-defaultClientSecret":g.ClientSecret};function ne(e,n,a,r,o,u=[]){const c=a.requestValues?.security,t=l=>{const s=e.serverValues?.[o];if(s){const y=s[l];if(y!=null)return String(y)}const d=e[l];if(d!=null&&typeof d=="string")return d;const i=c?.[l];if(i!=null)return String(i);const p=l==="x-defaultAccessToken"?e.type==="apiKey"?g.APIKey:g.Token:te[l],m=p!==void 0?a.environment?.[e.id+p]:void 0;if(m)return m};if(e.type==="http"&&e.scheme==="basic")n.basicAuth={username:t("x-defaultUsername")||c?.username||"<username>",password:t("x-defaultPassword")||c?.password||"<password>"};else if(e.type==="http"){const l=t("x-defaultAccessToken"),s=e.scheme||"bearer",d=s.charAt(0).toUpperCase()+s.slice(1),i=e.bearerFormat?`<YOUR_${e.bearerFormat}_HERE>`:"<YOUR_TOKEN_HERE>";n.headers.push({name:"Authorization",value:l?`${d} ${l}`:`${d} ${i}`})}else if(e.type==="apiKey"&&e.name){const l=t("x-defaultAccessToken")||"YOUR_API_KEY_HERE",s={name:e.name,value:l};e.in==="header"?n.headers.push(s):e.in==="cookie"?n.cookies.push({name:e.name,value:l}):(e.in==="query"||e.in==="querystring"||e.in===void 0)&&n.queries.push({name:e.name,value:l})}else if(e.type==="oauth2"){const l=t("x-defaultAccessToken"),s=t("x-defaultTokenType")||"Bearer";if(n.headers.push({name:"Authorization",value:l?`${s} ${l}`:"Bearer <YOUR_TOKEN_HERE>"}),r.withOAuth2Call&&e.flows){const d=[];if(e.flows.deviceAuthorization){const i=e.flows.deviceAuthorization;d.push(ae(i.deviceAuthorizationUrl,i.tokenUrl,e,o,u))}else if(e.flows.clientCredentials){const i=e.flows.clientCredentials;d.push(z("clientCredentials",i.tokenUrl,e,o,u))}else if(e.flows.password){const i=e.flows.password;d.push(z("password",i.tokenUrl,e,o,u))}d.length>0&&(n.oAuth2PreRequests=(n.oAuth2PreRequests??[]).concat(d))}}else if(e.type==="openIdConnect"){const l=t("x-defaultAccessToken"),s=t("x-defaultTokenType")||"Bearer";n.headers.push({name:"Authorization",value:l?`${s} ${l}`:"Bearer <YOUR_TOKEN_HERE>"})}}function ae(e,n,a,r,o=[]){const u=a.serverValues?.[r]?.["x-defaultClientId"]||a["x-defaultClientId"]||"YOUR_CLIENT_ID",c=[{name:"client_id",value:u}];return o.length>0&&c.push({name:"scope",value:o.join(" ")}),{flowType:"deviceAuthorization",tokenUrl:n,clientId:u,scopes:o.length>0?o:void 0,method:"POST",url:e,httpVersion:"HTTP/1.1",cookies:[],headers:[{name:"Content-Type",value:"application/x-www-form-urlencoded"},{name:"Accept",value:"application/json"}],queryString:[],postData:{mimeType:"application/x-www-form-urlencoded",params:c,text:c.map(t=>`${encodeURIComponent(t.name)}=${encodeURIComponent(t.value??"")}`).join("&")},headersSize:-1,bodySize:-1}}function z(e,n,a,r,o=[]){const u=a.serverValues?.[r]?.["x-defaultClientId"]||a["x-defaultClientId"]||"YOUR_CLIENT_ID",c=a.serverValues?.[r]?.["x-defaultClientSecret"]||a["x-defaultClientSecret"],t=a.serverValues?.[r]?.["x-defaultUsername"]||a["x-defaultUsername"],l=a.serverValues?.[r]?.["x-defaultPassword"]||a["x-defaultPassword"],s=[];return e==="clientCredentials"?s.push({name:"grant_type",value:"client_credentials"}):e==="password"&&s.push({name:"grant_type",value:"password"}),s.push({name:"client_id",value:u}),s.push({name:"client_secret",value:c||"YOUR_CLIENT_SECRET"}),e==="password"&&(s.push({name:"username",value:t||"<username>"}),s.push({name:"password",value:l||"<password>"})),o.length>0&&s.push({name:"scope",value:o.join(" ")}),{flowType:e,tokenUrl:n,clientId:u,clientSecret:c,username:t,password:l,scopes:o.length>0?o:void 0,method:"POST",url:n,httpVersion:"HTTP/1.1",cookies:[],headers:[{name:"Content-Type",value:"application/x-www-form-urlencoded"},{name:"Accept",value:"application/json"}],queryString:[],postData:{mimeType:"application/x-www-form-urlencoded",params:s,text:s.map(d=>`${encodeURIComponent(d.name)}=${encodeURIComponent(d.value??"")}`).join("&")},headersSize:-1,bodySize:-1}}function N(e,n,a){return n==="querystring"&&e.serializationMime===k.URL_ENCODED&&typeof a=="object"&&a!==null?re(J(a)):null}function re(e){const n=new Map,a=[];for(const r of e){const o=n.get(r.name);o?o.push(r.value):(n.set(r.name,[r.value]),a.push(r.name))}return a.map(r=>({name:r,value:(n.get(r)??[]).join(",")}))}function b(e,n,a,r,o,u,c){return e.filter(t=>!o.skipOptionalParameters||t.required).flatMap(t=>{const s=r[n==="querystring"?"query":n]?.[t.name];if(s!=null)return[{name:t.name,value:String(s)}];const d=t.serverValues?.[a]?.example;if(d!=null)return[{name:t.name,value:T(t,d)}];if(t.example!=null){const i=N(t,n,t.example);return i||(t.serializationMime&&u.serializeParameter?[{name:t.name,value:u.serializeParameter(t,t.example)}]:[{name:t.name,value:T(t,t.example)}])}if(n==="querystring"&&t.serializationMime===k.URL_ENCODED&&t.schemaId){const i=u.resolveSchema(t.schemaId);if(i){const p=u.sampleFromSchema(i,c),m=N(t,n,p);if(m)return m}}return[{name:t.name,value:oe(t,u,c)}]})}function oe(e,n,a){if(e.schemaId){const r=n.resolveSchema(e.schemaId);if(r){const o=n.sampleFromSchema(r,a);if(o!=null)return e.serializationMime&&n.serializeParameter?n.serializeParameter(e,o):T(e,o)}}return`{${e.name}}`}function ie(e){switch(e){case"query":case"querystring":case"cookie":return"form";case"path":case"header":return"simple";default:return"form"}}function T(e,n){if(n==null)return"";if(typeof n!="object")return String(n);const a=e.style??ie(e.in),o=e.explode??a==="form"?"*":"",u="__redoc_param_name__";try{switch(a){case"form":{const l=$.parse(`{?${u}${o}}`).expand({[u]:n}).substring(1).replace(/__redoc_param_name__/g,e.name).split(`&${e.name}=`);return l[0]=l[0].replace(new RegExp(`^${se(e.name)}=`),""),l.map(D).join(",")}case"spaceDelimited":return Array.isArray(n)?n.map(String).join(" "):String(n);case"pipeDelimited":return Array.isArray(n)?n.map(String).join("|"):String(n);case"simple":case"label":case"matrix":{const c=a==="label"?".":a==="matrix"?";":"",t=$.parse(`{${c}${u}${o}}`);return D(t.expand({[u]:n}).replace(/__redoc_param_name__/g,e.name))}case"deepObject":return JSON.stringify(n);default:return JSON.stringify(n)}}catch{return Array.isArray(n)?n.map(String).join(","):JSON.stringify(n)}}function se(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function D(e){try{return decodeURIComponent(e)}catch{return e}}function le(e,n,a,r,o,u,c){let t;if(a.replayBody!==void 0&&(t=a.replayBody),t===void 0&&a.exampleName){const i=Q(e.exampleIds,a.exampleName,r.resolveExample),p=i?r.resolveExample(i):void 0;p&&(t=p.value)}if(t===void 0&&e.exampleIds?.length){const i=r.resolveExample(e.exampleIds[0]);i&&(t=i.value)}if(t===void 0&&e.schemaId){const i=r.resolveVariantSchemaForSampling?.(e.schemaId),p=i?.schema??r.resolveSchema(e.schemaId),m=i?.variantSchemaId??e.schemaId;if(p){const y=n.toLowerCase().includes("xml");t=r.sampleFromSchema(p,{...o,format:y?"xml":o.format}),t&&typeof t=="object"&&!Array.isArray(t)&&m!==e.schemaId&&r.applyDiscriminatorValue?.(t,m,i?.mappingKey)}}if(c!==void 0&&a.replayBody===void 0&&(t===void 0?t=c:t=F(t,c)),t===void 0)return;const l=n.toLowerCase();let s,d=[];if(l.includes("x-www-form-urlencoded"))typeof t=="object"&&t!==null?(d=Object.entries(t).map(([i,p])=>({name:i,value:E(p)})),s=K(t)):s=String(t);else if(l.includes("multipart/form-data"))typeof t=="string"?(d=M(t)??[],s=t):(typeof t=="object"&&t!==null&&!Array.isArray(t)&&(d=Object.entries(t).map(([i,p])=>({name:i,value:E(p)}))),s=JSON.stringify(t,null,2));else if(H(l))if(typeof t=="string")s=t;else{const i=e.schemaId?r.resolveSchema(e.schemaId):void 0;s=String(Y(t,l,i,!0))}else l.includes("json")?s=typeof t=="string"?t:JSON.stringify(t,null,2):l.includes("xml")?s=typeof t=="string"?t:t&&typeof t=="object"?L(t):String(t):s=typeof t=="string"?t:JSON.stringify(t,null,2);return{mimeType:n,params:d,text:s}}function ue(e){try{const n=JSON.parse(e);if(n&&typeof n=="object"&&!Array.isArray(n))return n}catch{}}export{Ie as buildCodeSampleHAR};
|
|
1
|
+
import $ from"url-template";import{SecurityVariablesEnvSuffix as g}from"@redocly/theme/core/openapi";import{mergeBodyValue as F}from"../../adapters/openapi/configure/merge-utils.js";import{formUrlEncodeValue as K,stringifyFormFieldValue as E}from"../../utils/form-urlencoded.js";import{isSequentialMediaType as H}from"../../utils/media-type.js";import{parseMultipartFormData as M}from"../../utils/multipart.js";import{objectToHarParams as J}from"../../utils/serialize-querystring.js";import{jsonToXml as L}from"../../utils/xml.js";import{MediaTypes as k}from"../../constants/openapi.js";import{convertSampleToString as Y}from"./convertSampleToString.js";import{findExampleIdByKey as Q,mediaTypeContainingKey as X}from"./example-key.js";import{resolveServerUrl as G}from"./normalize-servers.js";import{serverMatchesUrl as W}from"./server-variables.js";function Ie(e,n,a,r){const o=e.servers.find(f=>W(f,n.serverUrl))||e.servers[0],u=o?.url?.replace(/\/$/,"")??"",c=u?G(u).replace(/\/$/,""):"",t={};if(o?.variables)for(const[f,A]of Object.entries(o.variables))t[f]=n.environment?.[f]||A.default||"";const l=e.path.replace(/^\//,""),s=`${c}/${l}`,d={skipReadOnly:!0,maxDepth:a.generatedPayloadSamplesMaxDepth??8,format:"json"},i=o?.url??n.serverUrl??"",p=n.requestValues??{},m=Z(e.security,n.activeSecuritySchemeIds),y=ee(m,n,a,i),S=b(e.parameters.header,"header",i,p,a,r,d).concat(y.headers),h=n.mediaType||X(e.requestBody,n.exampleName,r.resolveExample)||(e.requestBody?Object.keys(e.requestBody)[0]:void 0);let R=!1;for(const f of S)f.name.toLowerCase()==="content-type"&&h&&(f.value=h,R=!0);!R&&h&&S.unshift({name:"Content-Type",value:h});const v=b(e.parameters.cookie,"cookie",i,p,a,r,d).concat(y.cookies),O=e.parameters.querystring.length>0,C=b(O?e.parameters.querystring:e.parameters.query,O?"querystring":"query",i,p,a,r,d).concat(y.queries),U={};for(const f of e.parameters.path)U[f.name]=p.path?.[f.name]||f.serverValues?.[i]?.example||f.example||"";let x;if(h&&e.requestBody?.[h]){const f=e.requestBody[h],A=e.requestValues?.serverBody?.[i]??e.requestValues?.body;x=le(f,h,n,r,d,i,A)}const w={};for(const f of S)w[f.name]=f.value;const I={};v.length&&(I.cookie=v.map(f=>`${encodeURIComponent(f.name)}=${encodeURIComponent(f.value)}`).join("; ")),Object.assign(I,w);const j={};for(const f of C)V(j,f.name,f.value);const B=x?.text?ue(x.text):void 0;let _;if(x?.params?.length){_={};for(const f of x.params)V(_,f.name,f.value??"")}const P=C.map(f=>`${encodeURIComponent(f.name)}=${encodeURIComponent(f.value)}`).join("&"),q=P?`${s}?${P}`:s;return{method:e.method.toUpperCase(),url:s,pathname:q,httpVersion:"HTTP/1.1",cookies:v,headers:S,queryString:C,postData:x,headersSize:-1,bodySize:-1,fullUrl:q,headersObj:w,allHeaders:I,queryObj:j,jsonObj:B,paramsObj:_,basicAuth:y.basicAuth,pathParameters:U,serverVariables:t,responseCodes:e.responseCodes,allResponseCodes:e.responseCodes,oAuth2PreRequests:y.oAuth2PreRequests}}function V(e,n,a){const r=e[n];r===void 0?e[n]=a:Array.isArray(r)?r.push(a):e[n]=[r,a]}function Z(e,n){if(e.length){if(n?.length){const a=e.find(r=>{const o=r.schemes.map(u=>u.id);return o.length===n.length&&o.every(u=>n.includes(u))});if(a)return a}return e[0]}}function ee(e,n,a,r){const o={headers:[],cookies:[],queries:[]};if(!e)return o;for(const u of e.schemes)ne(u,o,n,a,r,e.scopes);return o}const te={"x-defaultUsername":g.Username,"x-defaultPassword":g.Password,"x-defaultClientId":g.ClientId,"x-defaultClientSecret":g.ClientSecret};function ne(e,n,a,r,o,u=[]){const c=a.requestValues?.security,t=l=>{const s=e.serverValues?.[o];if(s){const y=s[l];if(y!=null)return String(y)}const d=e[l];if(d!=null&&typeof d=="string")return d;const i=c?.[l];if(i!=null)return String(i);const p=l==="x-defaultAccessToken"?e.type==="apiKey"?g.APIKey:g.Token:te[l],m=p!==void 0?a.environment?.[e.id+p]:void 0;if(m)return m};if(e.type==="http"&&e.scheme==="basic")n.basicAuth={username:t("x-defaultUsername")||c?.username||"<username>",password:t("x-defaultPassword")||c?.password||"<password>"};else if(e.type==="http"){const l=t("x-defaultAccessToken"),s=e.scheme||"bearer",d=s.charAt(0).toUpperCase()+s.slice(1),i=e.bearerFormat?`<YOUR_${e.bearerFormat}_HERE>`:"<YOUR_TOKEN_HERE>";n.headers.push({name:"Authorization",value:l?`${d} ${l}`:`${d} ${i}`})}else if(e.type==="apiKey"&&e.name){const l=t("x-defaultAccessToken")||"YOUR_API_KEY_HERE",s={name:e.name,value:l};e.in==="header"?n.headers.push(s):e.in==="cookie"?n.cookies.push({name:e.name,value:l}):(e.in==="query"||e.in==="querystring"||e.in===void 0)&&n.queries.push({name:e.name,value:l})}else if(e.type==="oauth2"){const l=t("x-defaultAccessToken"),s=t("x-defaultTokenType")||"Bearer";if(n.headers.push({name:"Authorization",value:l?`${s} ${l}`:"Bearer <YOUR_TOKEN_HERE>"}),r.withOAuth2Call&&e.flows){const d=[];if(e.flows.deviceAuthorization){const i=e.flows.deviceAuthorization;d.push(ae(i.deviceAuthorizationUrl,i.tokenUrl,e,o,u))}else if(e.flows.clientCredentials){const i=e.flows.clientCredentials;d.push(z("clientCredentials",i.tokenUrl,e,o,u))}else if(e.flows.password){const i=e.flows.password;d.push(z("password",i.tokenUrl,e,o,u))}d.length>0&&(n.oAuth2PreRequests=(n.oAuth2PreRequests??[]).concat(d))}}else if(e.type==="openIdConnect"){const l=t("x-defaultAccessToken"),s=t("x-defaultTokenType")||"Bearer";n.headers.push({name:"Authorization",value:l?`${s} ${l}`:"Bearer <YOUR_TOKEN_HERE>"})}}function ae(e,n,a,r,o=[]){const u=a.serverValues?.[r]?.["x-defaultClientId"]||a["x-defaultClientId"]||"YOUR_CLIENT_ID",c=[{name:"client_id",value:u}];return o.length>0&&c.push({name:"scope",value:o.join(" ")}),{flowType:"deviceAuthorization",tokenUrl:n,clientId:u,scopes:o.length>0?o:void 0,method:"POST",url:e,httpVersion:"HTTP/1.1",cookies:[],headers:[{name:"Content-Type",value:"application/x-www-form-urlencoded"},{name:"Accept",value:"application/json"}],queryString:[],postData:{mimeType:"application/x-www-form-urlencoded",params:c,text:c.map(t=>`${encodeURIComponent(t.name)}=${encodeURIComponent(t.value??"")}`).join("&")},headersSize:-1,bodySize:-1}}function z(e,n,a,r,o=[]){const u=a.serverValues?.[r]?.["x-defaultClientId"]||a["x-defaultClientId"]||"YOUR_CLIENT_ID",c=a.serverValues?.[r]?.["x-defaultClientSecret"]||a["x-defaultClientSecret"],t=a.serverValues?.[r]?.["x-defaultUsername"]||a["x-defaultUsername"],l=a.serverValues?.[r]?.["x-defaultPassword"]||a["x-defaultPassword"],s=[];return e==="clientCredentials"?s.push({name:"grant_type",value:"client_credentials"}):e==="password"&&s.push({name:"grant_type",value:"password"}),s.push({name:"client_id",value:u}),s.push({name:"client_secret",value:c||"YOUR_CLIENT_SECRET"}),e==="password"&&(s.push({name:"username",value:t||"<username>"}),s.push({name:"password",value:l||"<password>"})),o.length>0&&s.push({name:"scope",value:o.join(" ")}),{flowType:e,tokenUrl:n,clientId:u,clientSecret:c,username:t,password:l,scopes:o.length>0?o:void 0,method:"POST",url:n,httpVersion:"HTTP/1.1",cookies:[],headers:[{name:"Content-Type",value:"application/x-www-form-urlencoded"},{name:"Accept",value:"application/json"}],queryString:[],postData:{mimeType:"application/x-www-form-urlencoded",params:s,text:s.map(d=>`${encodeURIComponent(d.name)}=${encodeURIComponent(d.value??"")}`).join("&")},headersSize:-1,bodySize:-1}}function N(e,n,a){return n==="querystring"&&e.serializationMime===k.URL_ENCODED&&typeof a=="object"&&a!==null?re(J(a)):null}function re(e){const n=new Map,a=[];for(const r of e){const o=n.get(r.name);o?o.push(r.value):(n.set(r.name,[r.value]),a.push(r.name))}return a.map(r=>({name:r,value:(n.get(r)??[]).join(",")}))}function b(e,n,a,r,o,u,c){return e.filter(t=>!o.skipOptionalParameters||t.required).flatMap(t=>{const s=r[n==="querystring"?"query":n]?.[t.name];if(s!=null)return[{name:t.name,value:String(s)}];const d=t.serverValues?.[a]?.example;if(d!=null)return[{name:t.name,value:T(t,d)}];if(t.example!=null){const i=N(t,n,t.example);return i||(t.serializationMime&&u.serializeParameter?[{name:t.name,value:u.serializeParameter(t,t.example)}]:[{name:t.name,value:T(t,t.example)}])}if(n==="querystring"&&t.serializationMime===k.URL_ENCODED&&t.schemaId){const i=u.resolveSchema(t.schemaId);if(i){const p=u.sampleFromSchema(i,c),m=N(t,n,p);if(m)return m}}return[{name:t.name,value:oe(t,u,c)}]})}function oe(e,n,a){if(e.schemaId){const r=n.resolveSchema(e.schemaId);if(r){const o=n.sampleFromSchema(r,a);if(o!=null)return e.serializationMime&&n.serializeParameter?n.serializeParameter(e,o):T(e,o)}}return`{${e.name}}`}function ie(e){switch(e){case"query":case"querystring":case"cookie":return"form";case"path":case"header":return"simple";default:return"form"}}function T(e,n){if(n==null)return"";if(typeof n!="object")return String(n);const a=e.style??ie(e.in),o=e.explode??a==="form"?"*":"",u="__redoc_param_name__";try{switch(a){case"form":{const l=$.parse(`{?${u}${o}}`).expand({[u]:n}).substring(1).replace(/__redoc_param_name__/g,e.name).split(`&${e.name}=`);return l[0]=l[0].replace(new RegExp(`^${se(e.name)}=`),""),l.map(D).join(",")}case"spaceDelimited":return Array.isArray(n)?n.map(String).join(" "):String(n);case"pipeDelimited":return Array.isArray(n)?n.map(String).join("|"):String(n);case"simple":case"label":case"matrix":{const c=a==="label"?".":a==="matrix"?";":"",t=$.parse(`{${c}${u}${o}}`);return D(t.expand({[u]:n}).replace(/__redoc_param_name__/g,e.name))}case"deepObject":return JSON.stringify(n);default:return JSON.stringify(n)}}catch{return Array.isArray(n)?n.map(String).join(","):JSON.stringify(n)}}function se(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function D(e){try{return decodeURIComponent(e)}catch{return e}}function le(e,n,a,r,o,u,c){let t;if(a.replayBody!==void 0&&(t=a.replayBody),t===void 0&&a.exampleName){const i=Q(e.exampleIds,a.exampleName,r.resolveExample),p=i?r.resolveExample(i):void 0;p&&(t=p.value)}if(t===void 0&&e.exampleIds?.length){const i=r.resolveExample(e.exampleIds[0]);i&&(t=i.value)}if(t===void 0&&e.schemaId){const i=r.resolveVariantSchemaForSampling?.(e.schemaId),p=i?.schema??r.resolveSchema(e.schemaId),m=i?.variantSchemaId??e.schemaId;if(p){const y=n.toLowerCase().includes("xml");t=r.sampleFromSchema(p,{...o,format:y?"xml":o.format}),t&&typeof t=="object"&&!Array.isArray(t)&&m!==e.schemaId&&r.applyDiscriminatorValue?.(t,m,i?.mappingKey)}}if(c!==void 0&&a.replayBody===void 0&&(t===void 0?t=c:t=F(t,c)),t===void 0)return;const l=n.toLowerCase();let s,d=[];if(l.includes("x-www-form-urlencoded"))typeof t=="object"&&t!==null?(d=Object.entries(t).map(([i,p])=>({name:i,value:E(p)})),s=K(t)):s=String(t);else if(l.includes("multipart/form-data"))typeof t=="string"?(d=M(t)??[],s=t):(typeof t=="object"&&t!==null&&!Array.isArray(t)&&(d=Object.entries(t).map(([i,p])=>({name:i,value:E(p)}))),s=JSON.stringify(t,null,2));else if(H(l))if(typeof t=="string")s=t;else{const i=e.schemaId?r.resolveSchema(e.schemaId):void 0;s=String(Y(t,l,i,!0))}else l.includes("json")?s=typeof t=="string"?t:JSON.stringify(t,null,2):l.includes("xml")?s=typeof t=="string"?t:t&&typeof t=="object"?L(t):String(t):s=typeof t=="string"?t:JSON.stringify(t,null,2);return{mimeType:n,params:d,text:s}}function ue(e){try{const n=JSON.parse(e);if(n&&typeof n=="object"&&!Array.isArray(n))return n}catch{}}export{Ie as buildCodeSampleHAR};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Which configured languages are offered in the code-sample panel. The community edition keeps only payload and x-codeSamples languages. */
|
|
2
|
+
export declare function filterAvailableLanguages<L extends {
|
|
3
|
+
key: string;
|
|
4
|
+
}>(languages: L[], _definitionSampleKeys: Set<string>): L[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function n(e,i){return e}export{n as filterAvailableLanguages};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { OpenAPIServer } from '
|
|
1
|
+
import type { OpenAPIServer } from '../../types/openapi.js';
|
|
2
2
|
export declare function resolveServerUrl(url: string, specUrl?: string): string;
|
|
3
3
|
export declare function normalizeServers(specUrl: string | undefined, servers: OpenAPIServer[]): OpenAPIServer[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isAbsoluteUrl as l,removeQueryStringAndHash as o,resolveUrl as s}from"../../adapters/openapi/utils/helpers.js";import{getUrlDirname as i}from"../../adapters/openapi/utils/url.js";import{IS_BROWSER as u}from"../../utils/environments.js";function f(e){const t=o(e);if(!t||t.endsWith("/"))return t;const r=t.lastIndexOf("/");return r===-1?"":t.slice(0,r)}function a(e){return e===void 0?o((()=>{if(!u)return globalThis.SSR_HOSTNAME||"";const r=window.location.href;return r.endsWith(".html")&&i(r)||r})()):l(e)?i(e):f(e)}function m(e,t){const r=a(t);return r?s(r,e):e}function S(e,t){let r=t;return r.length===0&&(r=[{url:"/"}]),r.map(n=>({...n,url:m(n.url,e),description:n.description||""}))}export{S as normalizeServers,m as resolveServerUrl};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createStoreContext as S,toRecord as b}from"../../../adapters/helpers.js";import{populateOpenApiStore as O}from"../../../adapters/openapi/store.js";import{buildCodeSampleSource as $}from"../../../adapters/openapi/build-code-sample-source.js";function q(e,t){if(!e.length&&!t?.length||!e.length)return t;if(!t?.length)return e;const r=new Set(t.map(a=>{const n=a;return`${n.in}:${n.name}`})),u=[...t];for(const a of e){const n=a,o=`${n.in}:${n.name}`;r.has(o)||u.push(a)}return u}let m=null;function v(e,t){if(m?.doc===e)return m.ctx;const r=S(b(e));return O(e,r,t),m={doc:e,ctx:r},r}function K(e,t,r,u,a){const n=r.paths;if(!n||typeof n!="object")return;const o=n[e];if(!o||typeof o!="object")return;const
|
|
1
|
+
import{createStoreContext as S,toRecord as b}from"../../../adapters/helpers.js";import{populateOpenApiStore as O}from"../../../adapters/openapi/store.js";import{buildCodeSampleSource as $}from"../../../adapters/openapi/build-code-sample-source.js";function q(e,t){if(!e.length&&!t?.length||!e.length)return t;if(!t?.length)return e;const r=new Set(t.map(a=>{const n=a;return`${n.in}:${n.name}`})),u=[...t];for(const a of e){const n=a,o=`${n.in}:${n.name}`;r.has(o)||u.push(a)}return u}let m=null;function v(e,t){if(m?.doc===e)return m.ctx;const r=S(b(e));return O(e,r,t),m={doc:e,ctx:r},r}function K(e,t,r,u,a){const n=r.paths;if(!n||typeof n!="object")return;const o=n[e];if(!o||typeof o!="object")return;const d=t.toLowerCase(),f=o;let c=d,i=f[d],p=!1;if(!i&&d==="query"&&f["x-query"]&&(i=f["x-query"],c="x-query"),!i&&d!=="query"&&o.additionalOperations){const l=o.additionalOperations,y=t in l?t:Object.keys(l).find(C=>C.toLowerCase()===d);y&&(i=l[y],c=y,p=!0)}if(!i||typeof i!="object")return;const s=i,x=o.parameters??[],h={pointer:p?`/paths/${e}/additionalOperations/${c}`:`/paths/${e}/${c}`,pathName:e,httpVerb:t.toUpperCase(),operationId:s.operationId,summary:typeof s.summary=="string"?s.summary:void 0,isWebhook:!1,isAdditionalOperation:p,tags:[],parameters:q(x,s.parameters),requestBody:s.requestBody,servers:s.servers??o.servers,security:s.security},g=v(r,u);return a?.(h,g,r),$(h,g,u.ignoreNamedSchemas,void 0,void 0,u)}export{K as buildCodeSampleSourceFromDocument};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { OpenAPIDefinition
|
|
1
|
+
import type { OpenAPIDefinition } from '../../../types/openapi.js';
|
|
2
2
|
import type { MockServerOptions } from '../../../adapters/openapi/utils/merge-mock-server.js';
|
|
3
|
-
export declare function buildServerEnvValues(servers: OpenAPIServer[]): Record<string, Record<string, string>>;
|
|
4
3
|
export declare function buildReplayPredefinedEnvValues(definition: OpenAPIDefinition, mockServer: MockServerOptions): Record<string, Record<string, string>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{mergeInMockServer as
|
|
1
|
+
import{mergeInMockServer as t}from"../../../adapters/openapi/utils/merge-mock-server.js";import{buildServerEnvValues as i}from"../server-env.js";function f(e,r){const n=t((e.servers??[]).filter(o=>typeof o?.url=="string"),r);return i(n)}export{f as buildReplayPredefinedEnvValues};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { OpenAPIServer } from '../../types/openapi.js';
|
|
2
|
+
/** Seeds one environment per global server so a saved environment name can resolve to a server in a fresh session. */
|
|
3
|
+
export declare function buildServerEnvValues(servers: OpenAPIServer[]): Record<string, Record<string, string>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{normalizeServers as o}from"./normalize-servers.js";import{getServerEnvName as m}from"../../utils/environments.js";function f(r){const t=o(void 0,r);return Object.fromEntries(t.map(e=>[String(m(e)),{server:e.url,...Object.fromEntries(Object.entries(e.variables??{}).map(([n,i])=>[n,i.default||""]))}]))}export{f as buildServerEnvValues};
|
|
@@ -96,11 +96,11 @@ export type CodeSampleSource = {
|
|
|
96
96
|
/** Raw pointer into the spec (for deep linking) */
|
|
97
97
|
pointer?: string;
|
|
98
98
|
/** Docs route slug of the operation page, relative to the routing base path
|
|
99
|
-
* (e.g. `operations/getmuseumhours`) —
|
|
99
|
+
* (e.g. `operations/getmuseumhours`) — lets hosts link back to the description */
|
|
100
100
|
href?: string;
|
|
101
|
-
/** OpenAPI `operationId` — should match the loaded spec so
|
|
101
|
+
/** OpenAPI `operationId` — should match the loaded spec so hosts can resolve the operation */
|
|
102
102
|
openApiOperationId?: string;
|
|
103
|
-
/** OpenAPI operation `summary` —
|
|
103
|
+
/** OpenAPI operation `summary` — the human-readable operation name */
|
|
104
104
|
summary?: string;
|
|
105
105
|
/** OpenAPI `security` array (AND-groups) for multi-scheme UI selection */
|
|
106
106
|
securityGroups?: Array<Record<string, string[]>>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import*as B from"openapi-sampler";import{createStoreContext as I,resolveContent as C,resolveRef as h,toRecord as u}from"../../adapters/helpers.js";import{populateOpenApiStore as M}from"../../adapters/openapi/store.js";import{buildCodeSampleSource as N}from"../../adapters/openapi/build-code-sample-source.js";import{resolveOpenApiExampleValue as w}from"../../adapters/openapi/resolve-openapi-example-value.js";import{JsonPointer as b}from"../../adapters/openapi/utils/JsonPointer.js";import{createCodeSampleResolvers as A}from"../code-samples/resolvers.js";import{buildCodeSampleHAR as P}from"../code-samples/builder.js";import{tryGenerateCodeSample as T}from"../code-samples/generators/index.js";import{convertSampleToString as E}from"../code-samples/convertSampleToString.js";import{encodeExampleForMediaType as K,isSampleableMediaType as D,isSequentialMediaType as V,langFromMime as W}from"../../utils/media-type.js";import{getGeneratorKey as $,getLangKey as g}from"../../utils/languages.js";import{getServerEnvName as q}from"../../utils/environments.js";import{isOperationName as R}from"../../utils/http-methods.js";import{isStatusCode as F}from"../../utils/status-code.js";let v=null;function G(t,e){const n=e.ignoreNamedSchemas,o=n?[...n].sort().join(`
|
|
2
|
-
`):"";if(v?.doc===t&&v.optionsKey===o)return v.ctx;const r=I(u(t));return M(t,r,e),v={doc:t,optionsKey:o,ctx:r},r}function L(t,e){const n=t.paths;if(!(!n||typeof n!="object")){for(const[o,r]of Object.entries(n))if(!(!r||typeof r!="object"))for(const[s,i]of Object.entries(r)){if(!R(s)||!i||typeof i!="object")continue;const a=i;if(a.operationId===e)return{pathName:o,method:s,operation:a,pointer:b.compile(["paths",o,s])}}}}function U(t,e){const n=b.parse(e),o=n.indexOf("paths"),r=o>=0?n[o+1]:void 0,s=o>=0?n[o+2]:void 0;if(!r||!s||!R(s))return;const a=t.paths?.[r]?.[s];if(!(!a||typeof a!="object"))return{pathName:r,method:s,operation:a,pointer:b.compile(["paths",r,s])}}function H(t,{operationId:e,pointer:n}){if(e)return L(t,e);if(n)return U(t,n)}function ue(t,e,n){const o=H(t,n);if(!o)return;const{pathName:r,method:s,operation:i,pointer:a}=o,p=t.paths?.[r]??{},l={pointer:a,pathName:r,httpVerb:s.toUpperCase(),operationId:i.operationId,summary:typeof i.summary=="string"?i.summary:void 0,isWebhook:!1,isAdditionalOperation:!1,tags:i.tags??[],parameters:J(t,p.parameters,i.parameters),requestBody:i.requestBody,responses:i.responses,servers:i.servers??p.servers??t.servers,security:i.security},m=G(t,e),d=N(l,m,e,e
|
|
2
|
+
`):"";if(v?.doc===t&&v.optionsKey===o)return v.ctx;const r=I(u(t));return M(t,r,e),v={doc:t,optionsKey:o,ctx:r},r}function L(t,e){const n=t.paths;if(!(!n||typeof n!="object")){for(const[o,r]of Object.entries(n))if(!(!r||typeof r!="object"))for(const[s,i]of Object.entries(r)){if(!R(s)||!i||typeof i!="object")continue;const a=i;if(a.operationId===e)return{pathName:o,method:s,operation:a,pointer:b.compile(["paths",o,s])}}}}function U(t,e){const n=b.parse(e),o=n.indexOf("paths"),r=o>=0?n[o+1]:void 0,s=o>=0?n[o+2]:void 0;if(!r||!s||!R(s))return;const a=t.paths?.[r]?.[s];if(!(!a||typeof a!="object"))return{pathName:r,method:s,operation:a,pointer:b.compile(["paths",r,s])}}function H(t,{operationId:e,pointer:n}){if(e)return L(t,e);if(n)return U(t,n)}function ue(t,e,n){const o=H(t,n);if(!o)return;const{pathName:r,method:s,operation:i,pointer:a}=o,p=t.paths?.[r]??{},l={pointer:a,pathName:r,httpVerb:s.toUpperCase(),operationId:i.operationId,summary:typeof i.summary=="string"?i.summary:void 0,isWebhook:!1,isAdditionalOperation:!1,tags:i.tags??[],parameters:J(t,p.parameters,i.parameters),requestBody:i.requestBody,responses:i.responses,servers:i.servers??p.servers??t.servers,security:i.security},m=G(t,e),d=N(l,m,e.ignoreNamedSchemas,void 0,void 0,e),O=i["x-codeSamples"];O?.length&&(d.definitionSamples=O.map(({lang:S,label:c,source:f})=>({lang:S,label:c,source:f})));const y=A(m.schemaStore,m.exampleStore,e);return{doc:t,options:e,operation:i,pathName:r,method:s,source:d,storeCtx:m,resolvers:y}}function J(t,e,n){if(!e?.length)return n;if(!n?.length)return e;const o=u(t),r=a=>{const p=h(o,a)??a;return`${p.in}:${p.name}`},s=new Set(n.map(r));return[...e.filter(a=>!s.has(r(a))),...n]}function z(t,{environment:e,environments:n}){let o=t;if(e){const r=o.filter(s=>String(q(s))===e||s.url===e);o=r.length?r:o}return n&&(o=o.map(r=>{const s=n[String(q(r))]?.server;return s?{...r,url:s}:r})),o}function le(t,e={}){const{source:n,options:o}=t,r=o.codeSamples?.languages??[],s=new Map(r.map((c,f)=>[c.key,f])),i=z(n.servers,e),a=e.environment&&e.environments?.[e.environment]||{},p=(n.definitionSamples??[]).filter(c=>s.has(g(c))&&typeof c.source=="string"),l=new Set(p.map(g)),m={serverUrl:i[0]?.url??a.server,mediaType:e.mimeType,exampleName:e.exampleKey,environment:a,requestValues:e.parameters,replayBody:e.requestBody},d={skipOptionalParameters:o.codeSamples?.skipOptionalParameters,withOAuth2Call:o.codeSamples?.withOAuth2Call,generatedPayloadSamplesMaxDepth:o.generatedSamplesMaxDepth},y=n.operationType==="webhook"?void 0:P({...n,servers:i},m,d,t.resolvers),S=[];if(y)for(const c of r){const f=$(c);if(f==="payload"||l.has(c.key))continue;const x=T(f,y,c.options),k=x.kind==="ok"?x.source:x.kind==="unsupported-language"?"Language is not supported.":"Failed to generate code sample.";k&&S.push({lang:c.lang,label:c.label,source:k})}return[...p,...S].filter(c=>!!c.source).sort((c,f)=>(s.get(g(c))??9999)-(s.get(g(f))??9999))}function Q(t,e,n){if(e.examples&&typeof e.examples=="object"){const o=Object.keys(e.examples);if(o.length){const r=o.length===1?o[0]:n&&o.includes(n)?n:o[0],s=h(u(t),e.examples[r])??e.examples[r],i=w(s);if(i!==void 0)return i}}if(e.example!==void 0)return e.example}function X(t,e,n,o){const r=e.schema??e.itemSchema;if(!r)return;const s=h(u(t),r)??r;try{return B.sample(s,{skipReadOnly:o==="request",skipWriteOnly:o==="response",quiet:!0,skipNonRequired:n.onlyRequiredInSamples,maxSampleDepth:n.generatedSamplesMaxDepth},u(t))}catch{return}}function j(t,e,n,o,r,s){const i=[];if(!e)return i;for(const[a,p]of Object.entries(e)){if(!p||typeof p!="object"||s&&a!==s)continue;let l=Q(t.doc,p,n);const m=l===void 0&&D(a);if(m&&(l=X(t.doc,p,t.options,r)),l===void 0)continue;const d=E(l,a,p.schema??p.itemSchema,m&&V(a));d!==void 0&&i.push({lang:W(a),title:`${o} ${a}`,source:K(d,a,p.encoding)})}return i}function fe(t,{exampleKey:e,mimeType:n,titlePrefix:o="Payload"}={}){const r=h(u(t.doc),t.operation.requestBody)??t.operation.requestBody,s=C(u(t.doc),r);return j(t,s,e,o,"request",n)}function de(t,{exampleKey:e}={}){const n=t.operation.responses;if(!n||typeof n!="object")return[];const o=[];for(const[r,s]of Object.entries(n)){if(!F(r))continue;const i=h(u(t.doc),s)??s,a=C(u(t.doc),i);o.push(...j(t,a,e,r,"response"))}return o}export{le as buildCodeSamples,fe as getRequestBodySamples,de as getResponseSamples,ue as resolveOperationSampleContext};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ApiItem, SchemaEntry } from '../../types/store.js';
|
|
2
|
+
import type { SearchDocument } from './types.js';
|
|
3
|
+
/** Builds flat `SearchDocument`s from `ApiItem`s (OpenAPI, AsyncAPI, GraphQL). */
|
|
4
|
+
export declare class ApiDocsSearchIndexer {
|
|
5
|
+
#private;
|
|
6
|
+
constructor(basePath: string, schemaStore?: Record<string, SchemaEntry>, document?: Record<string, unknown>);
|
|
7
|
+
addItem(item: ApiItem): void;
|
|
8
|
+
getResult(): SearchDocument[];
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{REDOCLY_TEAMS_RBAC as f}from"@redocly/config";import{nodeTypes as P,contentType as S,schemaKind as E}from"../../types/common.js";import{extractFullText as y}from"../../adapters/utils/markdoc.js";import{appendArraySuffix as D,appendVariantSuffix as g,buildGraphqlSuffix as O,buildOpenApiSectionSuffix as j,makeDeepLink as I}from"../../utils/deep-link.js";const V=10,R="message payload",w="message headers",x=200;function _(k){return k.length>x?`${k.slice(0,x)}\u2026`:k}class G{#a=[];#r;#i;#s;#o;constructor(e,n,t){this.#r=e,this.#i=n,this.#s=t}addItem(e){if(!(!e.link||!e.content))try{switch(e.content.contentType){case S.OVERVIEW:this.#d(e,this.#r);break;case S.GROUP:case S.ITEM:this.#d(e,e.link);break}}catch(n){console.error(`Cannot add item to api-docs search indexer [${e.label}, ${e.link}]:`,n.message)}}#d(e,n){if(!e.content)return;const t=n.startsWith(this.#r+"/")?n.slice(this.#r.length+1):n.split("/").slice(-2).join("/"),r=e.content.children,i=this.#l(r),o=this.#y(r,t),s=e,a={id:n,url:n,title:e.label??"",text:i,path:[],deprecated:e.content.meta?.deprecated,..."httpVerb"in e&&e.httpVerb?{httpMethod:e.httpVerb}:{},..."httpPath"in e&&e.httpPath?{httpPath:e.httpPath}:{},..."badges"in e&&Array.isArray(e.badges)&&e.badges.length?{badges:e.badges}:{},..."isAdditionalOperation"in e&&e.isAdditionalOperation?{isAdditionalOperation:!0}:{},[f]:s[f],...o.length&&{parameters:o}};this.#a.push(a)}#l(e){const n=[],t=r=>{for(const i of r)if(i.nodeType===P.MARKDOC){const o=i;if(this.#h(o.content))continue;const s=y(o.content);s&&n.push(s)}else(i.nodeType===P.CONTAINER||i.nodeType===P.OVERVIEW_SECTION_WRAPPER)&&t(i.children)};return t(e),n.join(" ").trim()}#h(e){let n=!1,t=!1;const r=o=>{o.type==="code"&&o.attributes?.content?n=!0:o.type==="text"&&o.attributes?.content&&(t=!0);for(const s of o.children??[])r(s)},i=Array.isArray(e)?e:[e];for(const o of i)r(o);return n&&!t}#y(e,n){const t={},r=new Set,i=o=>{for(const s of o)if(s.nodeType===P.ITEM){const a=s;if(a[f])continue;this.#m(a,t,n),this.#S(a,t,r,n)}else if(s.nodeType===P.CONTAINER){const a=s;if(a[f])continue;i(a.children)}else s.nodeType===P.OVERVIEW_SECTION_WRAPPER&&i(s.children)};return i(e),Object.values(t)}#m(e,n,t){if(e.parameters?.length)for(const r of e.parameters){if(r[f])continue;const i=this.#g(e.variant),o=this.#k(e.variant),s=r.description?y(r.description):"",a=this.#$(r.schemaId),d={name:r.name,description:s,place:i,mediaType:void 0,type:a,required:r.required??!1,deepLink:this.#c(t,"request",o,void 0,void 0,[r.name]),example:void 0,enum:void 0};n[this.#t(d)]=d}}#t(e){return[...Array.isArray(e.path)?e.path:[],e.name.toString()].join(".")+e.description+e.place}#c(e,n,t,r,i,o){if(!e)return"";const s=o.join("/"),a=[`t=${n}`];return t&&a.push(`in=${t}`),i&&a.push(`c=${i}`),r&&a.push(`ct=${r}`),s&&a.push(`path=${s}`),`/${e}#${e}/${a.join("&")}`.toLowerCase()}#P(e,n,t,r){if(!e)return"";let i="messages";n&&(i+=`&m=${n}`),i+=`&t=${t}`;const o=r.join("/");return o&&(i+=`&path=${o}`),`/${e}#${e}/${i}`.toLowerCase()}#k(e){switch(e){case"query":return"query";case"path":return"path";case"headers":return"header";case"cookies":return"cookie";default:return}}#g(e){switch(e){case"query":return"query parameters";case"path":return"path parameters";case"headers":return"header parameters";case"cookies":return"cookie parameters";case"parameters":return"channel parameters";default:return e?`${e} parameters`:"parameters"}}#$(e){const n=this.#i?.[e];if(!n||n.kind!==E.JSON_SCHEMA)return"unknown";const t=n.data,r=this.#p(t);return this.#f(r)}#f(e){return Array.isArray(e.type)?e.type.join(" | "):e.type?e.type:e.properties||e.additionalProperties?"object":e.items?"array":e.enum?"string":"any"}#S(e,n,t,r){const i=this.#A(e);if(e.graphqlSchema&&Array.isArray(e.graphqlSchema)){this.#I(e.graphqlSchema,i,n,e,r);return}const o=!!this.#i&&!!this.#s;o&&this.#O(e,i,n,t,r);for(const s of e.responses??[])s[f]||(this.#T(s,n,r),o&&this.#b(s,n,r));if(o)for(const s of e.messages??[])s[f]||this.#q(s,n,r)}#O(e,n,t,r,i){const o=n.startsWith("response");if(e.mediaTypeSchemas){const s=Object.entries(e.mediaTypeSchemas),a=s.find(([,d])=>!d[f]);if(a){const[d,c]=a;c.schemaId&&this.#n(c.schemaId,n,d,s.length>1,o,t,[],r,i)}}else e.schemaId&&this.#n(e.schemaId,n,void 0,!1,o,t,[],r,i)}#T(e,n,t){const r=e.description?y(e.description):"",o=[e.summary?y(e.summary):"",r].filter(Boolean).join(" ").trim();if(!o)return;const s={name:e.code,description:o,place:`response ${e.code}`,mediaType:void 0,type:"unknown",required:!1,deepLink:t?I(t,j("response",void 0,e.code)):void 0,example:void 0,enum:void 0};n[this.#t(s)]=s}#b(e,n,t){const r=`response ${e.code} fields`,i=new Set;if(e.mediaTypeContent){const o=Object.entries(e.mediaTypeContent),s=o.find(([,a])=>!a[f]);if(s){const[a,d]=s;d.schemaId&&this.#n(d.schemaId,r,a,o.length>1,!0,n,[],i,t)}}else e.schemaId&&this.#n(e.schemaId,r,e.mediaType,!1,!0,n,[],i,t)}#q(e,n,t){const r=e.description?y(e.description):"",i=e.summary??"",o={name:e.name,description:(r+i).trim(),place:"message",mediaType:void 0,type:"unknown",required:!1,example:void 0,enum:void 0};n[this.#t(o)]=o,this.#o=e.name;const s=new Set;e.schemaId&&this.#n(e.schemaId,R,e.contentType,!1,!1,n,[],s,t),e.headerSchemaId&&this.#n(e.headerSchemaId,w,void 0,!1,!1,n,[],s,t),this.#o=void 0}#A(e){switch(e.variant){case"body":return"request fields";case"responses":return"response fields";case"graphql-fields":return"fields";case"graphql-args":return"arguments";case"return-type":return"return type fields";default:return e.variant??"fields"}}#E(e){return e.variant!=="graphql-args"?e.graphqlTypeName:e.graphqlFieldName?e.graphqlFieldName:e.graphqlTypeName?`@${e.graphqlTypeName}`:void 0}#I(e,n,t,r,i){const o=r.variant==="graphql-args",s=this.#E(r),a=d=>i&&s?I(i,d):void 0;for(const d of e){const c=d.description?y(d.description):"",u=`${s}.${d.name}`,l={name:d.name,description:c,place:n,mediaType:void 0,path:[],type:d.type??"unknown",required:!1,deepLink:a(o?O({t:"argument",path:u,arg:d.name}):O({t:"field",path:u})),example:void 0,enum:void 0};if(t[this.#t(l)]=l,d.args?.length)for(const p of d.args){const m=p.description?y(p.description):"",h={name:p.name,description:m,place:"arguments",mediaType:void 0,path:[d.name],type:p.type??"unknown",required:!1,deepLink:a(O({t:"argument",path:`${u}.${p.name}`,arg:p.name})),example:void 0,enum:void 0};t[this.#t(h)]=h}}}#n(e,n,t,r,i,o,s,a,d=""){const c=this.#i?.[e];if(!c||c.kind!==E.JSON_SCHEMA||c[f])return;const u=c.data,l=r?t:void 0;this.#u(u,n,t,l,i,o,{path:s,linkPath:[...s],depth:0},a,d)}#R(e){const n=e.match(/^response (\d+)/);return n?n[1]:void 0}#p(e){if(e.allOf){const n={};for(const t of e.allOf){const r=t.$ref?this.#e(t.$ref):t;if(r){const i=n.properties,o=n.required;Object.assign(n,r),(i||r.properties)&&(n.properties={...i||{},...r.properties||{}}),(o||r.required)&&(n.required=[...o||[],...r.required||[]])}}return delete n.allOf,e.description&&(n.description=e.description),n}if(e.$ref){const n=this.#e(e.$ref);if(n){const t={...n};return e.description&&(t.description=e.description),t}}return e}#e(e){if(!e.startsWith("#/"))return;const n=e.slice(2).split("/");let t=this.#s;for(const r of n){if(t==null||typeof t!="object")return;t=t[r]}return t!=null&&typeof t=="object"?t:void 0}#u(e,n,t,r,i,o,s,a,d=""){if(s.depth>V||e[f])return;const c=(p,m)=>this.#u(p,n,t,r,i,o,m,a,d);if(e.$ref){this.#w(e.$ref,c,s,a);return}if(e.allOf){c(this.#x(e,a),s);return}const u=e.discriminator??e["x-discriminator"];if(u?.propertyName&&!s.inDiscriminatorVariant){this.#W(e,u,c,s);return}const l=e.oneOf??e.anyOf;if(l){this.#C(e,l,c,s,a);return}if(e.if&&(e.then||e.else)){this.#L(e,c,s);return}e.properties&&this.#D(e,c,{place:n,mediaType:t,deepLinkContentType:r,isResponse:i,paramsMap:o,frame:s,visited:a,slug:d}),this.#v(e,c,s,a)}#w(e,n,t,r){if(r.has(e))return;r.add(e);const i=this.#e(e);i&&n(i,t)}#x(e,n){const t={};for(const r of e.allOf??[]){let i=r;if(r.$ref){if(n.has(r.$ref))continue;n.add(r.$ref),i=this.#e(r.$ref)}if(i){const o=t.properties,s=t.required;Object.assign(t,i),(o||i.properties)&&(t.properties={...o||{},...i.properties||{}}),(s||i.required)&&(t.required=[...s||[],...i.required||[]])}}return delete t.allOf,t}#C(e,n,t,r,i){e.properties&&t({...e,oneOf:void 0,anyOf:void 0},{...r,linkPath:g(r.linkPath,"&oneof=0")}),n.forEach((o,s)=>{if(o.$ref){if(i.has(o.$ref))return;i.add(o.$ref)}const a=o.$ref?this.#e(o.$ref):o;a&&t(a,{...r,linkPath:g(r.linkPath,`&oneof=${s}`),depth:r.depth+1})})}#L(e,n,t){const{if:r,then:i,else:o,...s}=e;[{allOf:[s,i??{},r??{}]},{allOf:[s,o??{}]}].forEach((d,c)=>{n(d,{...t,linkPath:g(t.linkPath,`&oneof=${c}`),depth:t.depth+1})})}#D(e,n,t){const{isResponse:r,paramsMap:i,frame:o,visited:s}=t,a=e.required||[],d=this.#R(t.place),c=r?"response":"request",u=t.place===R?"payload":t.place===w?"headers":void 0,l={requiredList:a,responseCode:d,type:c,asyncSubsection:u,...t};for(const[p,m]of Object.entries(e.properties??{})){if(m[f])continue;const h=this.#j(m,s);if(!h)continue;const C=this.#V(h,s),$=this.#p(h);if(!this.#_(h,$,r))continue;const T=p===o.discriminatorPropertyName,L=[...o.path,p],b=this.#F(p,T,o),q=this.#M(p,h,$,b,l),A=this.#t(q);i[A]==null&&(i[A]=q,!C&&!T&&n($,{path:L,linkPath:b,depth:o.depth+1}))}}#j(e,n){if(!e.$ref)return e;if(!n.has(e.$ref))return n.add(e.$ref),this.#e(e.$ref)}#V(e,n){if(!e.allOf)return!1;let t=!1;for(const r of e.allOf)r.$ref?n.has(r.$ref)||(n.add(r.$ref),t=!0):t=!0;return!t}#_(e,n,t){return!(e[f]||n[f]||n.readOnly&&!t||n.writeOnly&&t||e.additionalProperties!==void 0&&!e.properties)}#F(e,n,t){return[...n&&t.discriminatorLinkPath?t.discriminatorLinkPath:t.linkPath,e]}#M(e,n,t,r,i){const o=n.description??t.description,s=o?y(o):"",a=n.example??t.example,d=a!==void 0?_(typeof a=="string"?a:JSON.stringify(a)):void 0,c=Array.isArray(t.enum)&&t.enum.length?t.enum:void 0;return{name:e,description:s,place:i.place,mediaType:i.mediaType,path:i.frame.path,type:this.#f(t),required:i.requiredList.includes(e),deepLink:i.asyncSubsection?this.#P(i.slug,this.#o,i.asyncSubsection,r):this.#c(i.slug,i.type,void 0,i.deepLinkContentType,i.responseCode,r),example:d,enum:c}}#v(e,n,t,r){if(!e.items||typeof e.items!="object"||Array.isArray(e.items))return;if(e.items.$ref){if(r.has(e.items.$ref))return;r.add(e.items.$ref)}const i=e.items.$ref?this.#e(e.items.$ref):e.items;i&&n(i,{...t,linkPath:D(t.linkPath),depth:t.depth+1})}#W(e,n,t,r){const i=this.#G(e,n),o=s=>({...r,linkPath:g(r.linkPath,`&d=${s}`),inDiscriminatorVariant:!0,discriminatorPropertyName:n.propertyName,discriminatorLinkPath:r.linkPath});e.properties&&t({...e,discriminator:void 0,"x-discriminator":void 0,oneOf:void 0,anyOf:void 0},i.length?o(0):r),i.forEach((s,a)=>{t(s,{...o(a),depth:r.depth+1})})}#G(e,n){const t=e.oneOf??e.anyOf??[],r=Object.values(n.mapping??{});if(r.length===0)return t;const i=s=>t.find(a=>a.$ref===s||a["x-original-ref"]===s)??this.#e(s)??{},o=r.filter(s=>s!==n.defaultMapping).map(i);return n.defaultMapping&&o.push(i(n.defaultMapping)),o}getResult(){return this.#a}}export{G as ApiDocsSearchIndexer};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { OperationParameter, ParameterHighlight } from '@redocly/theme/core/openapi';
|
|
2
|
+
import type { ItemBadge } from '@redocly/config';
|
|
3
|
+
import type { REDOCLY_TEAMS_RBAC } from '@redocly/config';
|
|
4
|
+
export type SearchDocument = {
|
|
5
|
+
[REDOCLY_TEAMS_RBAC]?: Record<string, string>;
|
|
6
|
+
id: string;
|
|
7
|
+
url: string;
|
|
8
|
+
title: string | string[];
|
|
9
|
+
text: string | string[];
|
|
10
|
+
path?: string[];
|
|
11
|
+
httpMethod?: string;
|
|
12
|
+
httpPath?: string | string[];
|
|
13
|
+
isAdditionalOperation?: boolean;
|
|
14
|
+
deprecated?: boolean;
|
|
15
|
+
security?: string[];
|
|
16
|
+
parameters?: OperationParameter[];
|
|
17
|
+
badges?: ItemBadge[];
|
|
18
|
+
};
|
|
19
|
+
export type SearchItemData = {
|
|
20
|
+
document: SearchDocument;
|
|
21
|
+
highlight: Record<string, string> & {
|
|
22
|
+
parameters?: ParameterHighlight[];
|
|
23
|
+
path?: string[];
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export type { OperationParameter, ParameterHighlight } from '@redocly/theme/core/openapi';
|
|
27
|
+
export type { ItemBadge } from '@redocly/config';
|
|
File without changes
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { RedocStandaloneProps } from './RedocStandalone.js';
|
|
2
|
+
import type { TypeOfUsage } from './telemetry/RedocTelemetry.js';
|
|
3
|
+
import { RedocStandalone } from './RedocStandalone.js';
|
|
4
|
+
export { RedocStandalone };
|
|
5
|
+
export type { RedocStandaloneProps };
|
|
6
|
+
type InitOptions = NonNullable<RedocStandaloneProps['options']> & {
|
|
7
|
+
router?: 'hash' | 'history';
|
|
8
|
+
disableTelemetry?: boolean;
|
|
9
|
+
specType?: RedocStandaloneProps['specType'];
|
|
10
|
+
/** The Docker image sets `type-of-usage="docker"` on the `<redoc>` element. */
|
|
11
|
+
typeOfUsage?: TypeOfUsage;
|
|
12
|
+
basePath?: string;
|
|
13
|
+
};
|
|
14
|
+
export declare function init(definitionOrDefinitionUrl: string | Record<string, unknown>, options?: InitOptions, element?: Element | null): void;
|
|
15
|
+
/**
|
|
16
|
+
* Attaches to server-rendered markup instead of replacing it. The definition must be
|
|
17
|
+
* the same pre-bundled document the server pass rendered from.
|
|
18
|
+
*/
|
|
19
|
+
export declare function hydrate(definitionOrDefinitionUrl: string | Record<string, unknown>, options?: InitOptions, element?: Element | null): Promise<void>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{createElement as m}from"react";import{createRoot as g,hydrateRoot as E}from"react-dom/client";import{HashRouter as R}from"react-router";import{RedocStandalone as y,prepareApiDocs as S}from"./RedocStandalone.js";import{RedoclyApiDocsStandalone as A}from"./RedoclyApiDocsStandalone.js";import{logoFromDefinition as T}from"./utils/x-logo.js";const C=["html","cli","react","docker"];function M(e,t){return C.includes(e)?e:t}function f(e){return typeof document<"u"?document.querySelector(e):null}function w(e){const t={};for(const o of Array.from(e.attributes))t[o.name]=o.value;return t}function q(e){const t=w(e),o={};for(const r in t){const s=r.replace(/-(.)/g,(n,c)=>c.toUpperCase());o[s]=t[r]}return o}function h(e,t,o,r){const{router:s,disableTelemetry:n,specType:c,typeOfUsage:i,basePath:p,...u}={...t,...q(o)};let l,a;return typeof e=="string"?c==="graphql"&&!I(e)?a=e:l=e:typeof e=="object"&&(a=e),{router:s,props:{definition:a,definitionUrl:l,specType:c,options:u,basePath:p,telemetryConfig:{typeOfUsage:M(i,r),...n!==void 0?{disabled:n===!0||String(n)==="true"}:{}}}}}function d(e,t){return t==="history"?e:m(R,null,e)}function b(e){if(e===null)throw new Error('"element" argument is not provided and <redoc> tag is not found on the page');return e}function v(e,t={},o=f("redoc")){const r=b(o),{router:s,props:n}=h(e,t,r,"html");g(r).render(d(m(y,n),s))}const H=/server rendered HTML didn't match the client|error while hydrating|Minified React error #(418|423)/;async function L(e,t={},o=f("redoc")){const r=b(o),{router:s,props:n}=h(e,t,r,"cli"),c=n.basePath??"/",i=await S({...n,basePath:c}),p=m(A,{items:i.items,store:i.store,basePath:c,options:i.options,logo:T(i.document),telemetryConfig:n.telemetryConfig,definition:i.document});if(r.childElementCount===0){g(r).render(d(p,s));return}E(r,d(p,s),{onRecoverableError:(u,l)=>{const a=u instanceof Error?u.message:String(u);H.test(a)||console.error(a,l)}})}function I(e){return!e.includes(`
|
|
2
|
+
`)&&/^[^\s]+$/.test(e)}function P(){const e=f("redoc");if(!e)return;const t=e.getAttribute("spec-url");t&&v(t,{},e)}P();export{y as RedocStandalone,L as hydrate,v as init};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ThemeDataTransferObject } from '@redocly/theme/core/openapi';
|
|
2
|
+
/** Theme config injected into the standalone render's `ThemeDataContext`; `undefined` keeps the theme defaults. */
|
|
3
|
+
export declare const STANDALONE_THEME_CONFIG: ThemeDataTransferObject['config'] | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=void 0;export{e as STANDALONE_THEME_CONFIG};
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { Telemetry } from '@redocly/redoc-opentelemetry';
|
|
2
2
|
import type { EventType, EventPayload } from '@redocly/redoc-opentelemetry';
|
|
3
3
|
export type SpecType = 'openapi' | 'asyncapi' | 'graphql';
|
|
4
|
+
export type TypeOfUsage = 'html' | 'cli' | 'react' | 'docker';
|
|
4
5
|
export interface RedocTelemetryConfig {
|
|
5
6
|
specType: SpecType;
|
|
6
7
|
collectorUrl?: string;
|
|
7
8
|
serviceName?: string;
|
|
8
9
|
disabled?: boolean;
|
|
9
10
|
serviceVersion?: string;
|
|
11
|
+
typeOfUsage?: TypeOfUsage;
|
|
10
12
|
}
|
|
11
13
|
export declare class RedocTelemetry extends Telemetry {
|
|
12
14
|
private specType;
|
|
15
|
+
readonly typeOfUsage: TypeOfUsage | undefined;
|
|
13
16
|
constructor(config: RedocTelemetryConfig);
|
|
14
17
|
send<T extends EventType>(event: T, data?: EventPayload<T>): void;
|
|
15
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Telemetry as
|
|
1
|
+
import{Telemetry as p}from"@redocly/redoc-opentelemetry";import o from"../../package.json"with{type:"json"};import{DEFAULT_SERVICE_NAME as t,TELEMETRY_DISABLED_BY_DEFAULT as c}from"./defaults.js";const E="https://otel.cloud.redocly.com/v1/traces";class n extends p{specType;typeOfUsage;constructor(e){super(),this.specType=e.specType,this.typeOfUsage=e.typeOfUsage,this.init({otel:{isProd:process.env.NODE_ENV==="production"||process.env.ENABLE_LOCAL_TELEMETRY==="true",serviceVersion:e.serviceVersion||`${o.name}@${o.version}`,version:"1.0.0",collectorTraceUrl:e.collectorUrl||E,serviceName:e.serviceName||t,tracerName:"client-telemetry"},disabled:e.disabled??c})}send(e,s){s&&Array.isArray(s)&&s.length>0&&(s=s.map(r=>r&&typeof r=="object"?{...r,specType:this.specType}:r)),super.send(e,s,{env:process.env.NODE_ENV})}}export{n as RedocTelemetry};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const E=!0,t="realm-ui";export{t as DEFAULT_SERVICE_NAME,E as TELEMETRY_DISABLED_BY_DEFAULT};
|