redoc README

The project's README from github.com/Redocly/redoc. As one markdown file: README.md.

Redoc 3.0 is coming — one renderer for OpenAPI 3.2, AsyncAPI, GraphQL, and MCP

Learn what's coming in Redoc 3.x →

Generate beautiful API documentation from OpenAPI

npm License

bundle size npm jsDelivr status

About Redoc

Redoc is an open source tool for generating documentation from OpenAPI (formerly Swagger) definitions.

By default Redoc offers a three-panel, responsive layout:

Redoc demo

Live demo

If you want to see how Redoc renders your OpenAPI definition, you can try it out online at https://redocly.github.io/redoc/.

A version of the Swagger Petstore API is displayed by default. To test it with your own OpenAPI definition, enter the URL for your definition and select TRY IT.

Redoc features

Usage

Redoc is provided as a CLI tool (also distributed as a Docker image), HTML tag, and React component.

Generate documentation from the CLI

If you have Node installed, quickly generate documentation using npx:

npx @redocly/cli build-docs openapi.yaml

The tool outputs by default to a file named redoc-static.html that you can open in your browser.

Redocly CLI does more than docs; check it out and add linting, bundling, and more to your API workflow.

Add an HTML element to the page

Create an HTML page, or edit an existing one, and add the following within the body tags:

    <redoc spec-url="http://petstore.swagger.io/v2/swagger.json"></redoc>
    <script src="https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js"> </script>

Open the HTML file in your browser, and your API documentation is shown on the page.

Add your own spec-url to the <redoc> tag; this attribute can also be a local file. The JavaScript library can also be installed locally using npm and served from your own server, see the HTML deployment documentation for more details.

More usage options

Check out the deployment documentation for more options, and detailed documentation for each.

Redoc vs hosted Redoc

Redoc is Redocly's community-edition product. Looking for something more? We also offer a hosted Redoc with additional features including:

Documentation and resources

Showcase

A sample of the organizations using Redocly tools in the wild:

Pull requests to add your own API page to the list are welcome

Configuration

Redoc is highly configurable, see the configuration documentation for details.

OpenAPI specification extensions

Redoc uses the following specification extensions:

Releases

The README for the 1.x version is on the v1.x branch.

All the 2.x releases are deployed to npm and can be used with Redocly-cdn:

Additionally, all the 1.x releases are hosted on our GitHub Pages-based CDN (deprecated):

Development

see CONTRIBUTING.md

redoc (Redocly/redoc)

Searching Database…

26K ·GitHub
这是干什么的?Redoc 是一个开源工具,可以根据 OpenAPI(原名 Swagger)定义生成 API 参考文档 — 它把你的 spec 文件变成一个排版精美、易读的参考页面。
生成的文档长什么样?一个自适应的三栏网页:左边是搜索栏和导航菜单,中间是文档正文,右边是请求和响应示例。
怎么从我的 spec 文件生成文档?装好 Node 之后,用 npx 对你的 OpenAPI 定义运行 Redocly CLI — 它会生成一个 redoc-static.html 文件,直接用浏览器打开就行。
必须装 Node 吗?用 CLI 这条路需要 Node。如果不想配置 Node,还有 Docker 镜像、可以嵌进任意网页的 HTML 标签,以及用于应用集成的 React 组件。
和 Redocly 的托管产品相比,用这个少了什么?Redoc 是社区版。付费的托管版本额外提供试用控制台、自动生成的代码示例、完全自定义的样式、mock 服务器,以及对 AsyncAPI 和 GraphQL 的支持。
它支持哪些 API 描述格式?OpenAPI 3.1、OpenAPI 3.0 和旧版 Swagger 2.0 定义都支持,所以老的 Swagger spec 不用转换就能直接用。
能不能不装任何东西就预览文档?可以 — 有一个在线演示,默认会渲染一个示例 Petstore API;输入你自己 OpenAPI 定义的 URL,然后点击 TRY IT,就能看到 Redoc 的渲染效果。
这个 CLI 只能用来生成 HTML 文件吗?不是 — Redocly CLI 还能对你的 OpenAPI 文件做 lint 检查和打包,所以文档生成可以融入更完整的 API 工作流程。
实际上有哪些人在用 Redoc?展示页里列出了不少 Redocly 工具的用户,比如 Docker Engine、Zuora、Discourse、Rebilly、APIs.guru 和 Quaderno API。
Creator
Redocly
Size
104.5 MB
Stars
26K
Age
10y
Commits · 90 Days