$ show Redocly/redoc
Redoc is an open-source tool that generates interactive API documentation from OpenAPI (Swagger) specifications. It parses OpenAPI definitions (supporting versions 2.0, 3.0, and 3.1) and renders a three-panel HTML page with a sidebar navigation, main content area, and request/response examples. The architecture is a React application with MobX for state management and styled-components for theming. Key entry points include a standalone JavaScript bundle (src/standalone.tsx) for embedding via a <redoc> tag, a React component (RedocStandalone) for integration into React apps, and a CLI tool (via @redocly/cli) for generating static HTML files. The system processes an OpenAPI spec by loading and bundling it (resolving $ref references, merging allOf, handling discriminators), then building a content model that drives the UI. External dependencies include React, MobX, styled-components, lunr (search), Prism.js (syntax highlighting), and marked (markdown rendering). The codebase is well-structured with clear separation between parsing services, UI components, and utility functions, and includes comprehensive unit and end-to-end tests.
The LLM identified 3 files worth highlighting for reuse:
Core service that parses OpenAPI specifications, resolves $ref references, merges allOf compositions, and handles discriminators. It is a self-contained module that could be extracted for use in other OpenAPI tooling. Demonstrates advanced schema processing with circular reference detection and derived schema finding.
Custom markdown renderer that extends standard markdown with support for embedded components (e.g., security definitions) and sanitizes output using DOMPurify. It is isolated and could be reused in any project needing safe markdown rendering with custom extensions.
Implements full-text search over API documentation using lunr index, with serialization support and a worker thread for non-blocking search. The pattern of building a search index from a data model and running queries in a worker is reusable for any documentation or content site.