bởi eda

Redoc generates beautiful, responsive three-panel API reference documentation from OpenAPI 3.1, 3.0, and Swagger 2.0 definitions. Deploy as a CLI tool, HTML element, React component, or Docker image.
This block provides the full source of the Redoc React component library, which renders OpenAPI 2.0/3.0/3.1 definitions as interactive, three-panel API documentation. It exports React components, MobX-backed services, theming utilities, and styled-components primitives. The typical buyer is a TypeScript/React application developer who wants to embed or customize API documentation rendering directly in their own project.
index.ts — Root re-export barrel; exposes all components, services, utils, styled-components, and common-elementsstandalone.tsx — Entry point for the standalone (non-React-app) bundlestyled-components.ts — Re-exports styled-components (theme-aware, used throughout)theme.ts — Default Redoc theme definition and type exportspolyfills.ts — Browser polyfills required before mountingcommon-elements/ — Low-level styled UI primitives (panels, headers, dropdowns, tabs, schema blocks, etc.)components/ — High-level React components (Redoc, RedocStandalone, ApiInfo, Schema, Operation, SearchBox, SideMenu, etc.)services/ — MobX stores and business logic (OpenAPI parsing, navigation, search)types/ — TypeScript type definitions for OpenAPI constructs and internal modelsutils/ — Pure utility functions (string, schema, URL helpers)empty.js — Stub module used in webpack/jest aliasing for browser-incompatible Node modulesnpm install react react-dom mobx mobx-react styled-components
npm install @redocly/openapi-core classnames decko dompurify eventemitter3
npm install json-pointer lunr mark.js marked openapi-sampler
npm install path-browserify perfect-scrollbar polished prismjs
npm install prop-types react-tabs slugify stickyfill swagger2openapi url-template
TypeScript type packages:
npm install --save-dev @types/react @types/react-dom @types/dompurify @types/lunr @types/marked @types/prismjs @types/prop-types
No native modules, no pod install, no Android linking required. This is a pure JavaScript/TypeScript library.
Khởi chạy sandbox cách ly và chạy phía máy chủ — không cần cài đặt cục bộ.
Tetrees AI Review cho phiên bản này
This TypeScript cli / script completed archive review. Structure, dependency manifests, documentation, functional source, and common risk patterns were checked by the Tetrees verification pipeline; runtime phases are stated separately.
Deterministic AVCP artifact review
Quy trình avcp-2026-08-04.1 · SHA-256 91f27249e86c59fd…
This version-scoped review deterministically inspects the submitted archive for structure, dependencies, documentation, functional source, and common malicious or high-risk signals. Build and test phases are reported as passed only after an isolated sandbox audition. It is not a guarantee of perfect security.
Đã đánh giá 4 thg 8, 2026
Đưa sản phẩm này thẳng vào AI IDE, trình tạo web hoặc cloud IDE của bạn.
Kết nối Tetrees với AI IDE tương thích để liệt kê sản phẩm bạn sở hữu và nhận ZIP đã xác minh mà không cấp quyền tải lên của người bán.
Chưa có đánh giá.
Sign in to join the discussion
Loading discussion…
Copy the source/ directory into your project, e.g. src/redoc-source/.
Update tsconfig.json to include the source and enable decorators (required by MobX/decko):
{
"compilerOptions": {
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"moduleResolution": "node",
"jsx": "react-jsx",
"esModuleInterop": true,
"paths": {
"redoc-source": ["./src/redoc-source/index.ts"]
}
},
"include": ["src"]
}
empty.js:// webpack.config.js
resolve: {
alias: {
'path': require.resolve('path-browserify'),
},
fallback: { fs: false, net: false, tls: false }
}
No environment variables are required at runtime. OpenAPI spec URL or object is passed directly as a prop.
Wrap your app in a theme provider if you intend to customize Redoc's styled-components theme (see theme.ts for shape).
import { Redoc } from './redoc-source/components/Redoc/Redoc';
// Props (simplified):
interface RedocProps {
store: AppStore; // MobX store built via StoreBuilder
options?: RedocRawOptions;
}
function Redoc(props: RedocProps): JSX.Element;
The primary rendering component. Mount this when you already have a resolved AppStore instance. Use it when you need full control over store construction and lifecycle (e.g., server-side rendering, custom loading states, hot-reloading the spec).
import { RedocStandalone } from './redoc-source/components/RedocStandalone';
interface RedocStandaloneProps {
spec?: object;
specUrl?: string;
options?: RedocRawOptions;
onLoaded?: (e?: Error) => void;
}
function RedocStandalone(props: RedocStandaloneProps): JSX.Element;
Self-contained component that handles spec fetching, parsing, and store construction internally. The simplest integration point: pass either a spec object or a specUrl string and it renders documentation with no additional setup.
import { ApiInfo } from './redoc-source/components/ApiInfo/ApiInfo';
// Renders the API title, version, description, contact, and license blocks.
// Requires an AppStore (or OptionsProvider context) to be present in the tree.
function ApiInfo(props: {}): JSX.Element;
Renders the top-of-page API metadata section (title, version, description, license, contact). Use it standalone if you want to embed only the header portion of documentation into an existing layout.
import { Dropdown, SimpleDropdown } from './redoc-source/common-elements/';
import type { DropdownOption } from './redoc-source/common-elements';
interface DropdownOption {
value: string;
label?: string;
}
Reusable dropdown UI primitive exported from common-elements. Use these in custom toolbar or media-type selector UIs that need to match Redoc's visual style.
The simplest integration: drop RedocStandalone into any React tree with a public OpenAPI URL.
import React from 'react';
import { RedocStandalone } from './redoc-source/components/RedocStandalone';
export function ApiDocsPage() {
return (
<RedocStandalone
specUrl="https://petstore3.swagger.io/api/v3/openapi.json"
options={{
scrollYOffset: 60,
hideDownloadButton: false,
theme: { colors: { primary: { main: '#dd5522' } } },
}}
onLoaded={(err) => {
if (err) console.error('Spec load failed', err);
}}
/>
);
}
Pass a pre-fetched or bundled OpenAPI object directly when you control spec delivery (e.g., imported JSON, server-side fetched).
import React from 'react';
import { RedocStandalone } from './redoc-source/components/RedocStandalone';
import mySpec from './openapi.json';
export function InlineDocsPage() {
return (
<RedocStandalone
spec={mySpec}
options={{ nativeScrollbars: true, hideHostname: true }}
/>
);
}
Use StoreBuilder + Redoc directly when you need access to the MobX store (e.g., programmatic navigation, custom loading UI, SSR hydration).
import React, { useEffect, useState } from 'react';
import { Redoc } from './redoc-source/components/Redoc/Redoc';
import { AppStore } from './redoc-source/services';
import { Loading } from './redoc-source/components/Loading/Loading';
export function ControlledDocsPage() {
const [store, setStore] = useState<AppStore | null>(null);
const [error, setError] = useState<Error | null>(null);
useEffect(() => {
AppStore.fromURL('https://petstore3.swagger.io/api/v3/openapi.json', {})
.then(setStore)
.catch(setError);
}, []);
if (error) return <div>Failed to load spec: {error.message}</div>;
if (!store) return <Loading />;
return <Redoc store={store} />;
}
Embed only the API header section inside your own page shell without the side menu or schema panels.
import React from 'react';
import { RedocStandalone } from './redoc-source/components/RedocStandalone';
import { ApiInfo } from './redoc-source/components/ApiInfo/ApiInfo';
// ApiInfo requires store context - easiest to wrap inside RedocStandalone
// or provide OptionsProvider + StoreProvider manually.
// Shown here inside a minimal custom wrapper:
export function HeaderOnlyDocs() {
return (
<RedocStandalone
specUrl="/api/openapi.yaml"
options={{ showExtensions: true }}
/>
);
}
index.ts — Master barrel export; re-exports everything from components/, services/, utils/, common-elements/, and styled-components.standalone.tsx — Webpack entry for the UMD/standalone bundle; not needed when importing as a library.styled-components.ts — Wraps and re-exports styled-components with Redoc's theme type applied; import styled from here inside Redoc source.theme.ts — Contains the default theme object and RedocTheme / ThemeInterface type definitions.polyfills.ts — Applies browser polyfills (e.g., stickyfill); import at the top of your entry if targeting older browsers.common-elements/ — Atomic styled-component primitives: Row, MiddlePanel, RightPanel, Section, Dropdown, SimpleDropdown, tabs, schema blocks, scrollbar wrappers.components/ — Feature-complete React components: Redoc, RedocStandalone, ApiInfo, ApiLogo, Operation, Schema, SearchBox, SideMenu, Parameters, Responses, SecuritySchemes, SourceCode, and more.services/ — MobX stores (AppStore, MenuStore, SearchStore) and OpenAPI model classes; the data layer for all components.types/ — Shared TypeScript interfaces for OpenAPI constructs (OpenAPIEncoding, etc.) and internal models.utils/ — Stateless helper functions: URL manipulation, string formatting, schema traversal utilities.empty.js — Empty module stub for Node.js built-ins that must be excluded from browser bundles.mobx@^6 and mobx-react@^7; mixing MobX 4/5 breaks observable decorators silently.experimentalDecorators not enabled: decko and MobX decorators fail to compile without "experimentalDecorators": true in tsconfig.json.styled-components version conflict: Redoc expects styled-components v5. If your app uses v6, you may get ThemeContext errors; pin styled-components@^5.3.path / fs Node built-ins in browser bundles: Webpack 5 no longer polyfills Node core modules. Add resolve.fallback: { path: require.resolve('path-browserify'), fs: false } to your webpack config or use the provided empty.js alias.stickyfill and perfect-scrollbar access document on import. Guard with typeof window !== 'undefined' or defer polyfills.ts import to client-only code.react version: Redoc components are tested against React 17/18. If you see Invalid hook call errors, ensure only one copy of react exists in node_modules (npm ls react).I have a copy of the Redoc React component source (upstream package: user@example.com)
located at `src/redoc-source/` in my project. I also have `USAGE.md` in the same
directory describing all real exports, dependencies, and integration steps.
My project is: [describe your stack, e.g., "Next.js 14 app router, TypeScript, Tailwind"].
Please help me integrate the Redoc source step-by-step:
1. Read USAGE.md and `src/redoc-source/index.ts` to understand all available exports.
2. Install the required dependencies listed in USAGE.md.
3. Update tsconfig.json and any bundler config (webpack/next.config.js) as described.
4. Create a page/component that renders my OpenAPI spec using `RedocStandalone`
imported from `src/redoc-source/components/RedocStandalone`.
5. My spec is located at: [local path or URL].
6. I want these customizations: [list theme colors, options, layout changes].
7. Do not invent any imports - only use symbols documented in USAGE.md and
visible in src/redoc-source/index.ts.
Show me the complete file contents for each file you create or modify.
Redoc is released under the MIT License. See the upstream repository and source/LICENSE if present for the full license text.
Upstream package: redoc on npm — source at github.com/Redocly/redoc.
This product’s unique contribution is clean room implementation of valuable code block into AVCP compatible standard.
Hướng dẫn cài đặt đầy đủ và prompt tích hợp sẽ mở khóa sau khi mua.
Automation, Utilities & Developer Tools
Miễn phí