2021-11-23 08:07:56 +03:00
|
|
|
---
|
|
|
|
title: Redoc deployment guide
|
2023-10-09 19:35:52 +03:00
|
|
|
redirects:
|
|
|
|
'/docs/redoc/quickstart/intro/':
|
|
|
|
to: '/docs/redoc/deployment/intro/'
|
2021-11-23 08:07:56 +03:00
|
|
|
---
|
|
|
|
|
|
|
|
# Redoc deployment guide
|
|
|
|
|
|
|
|
Redoc offers multiple options for rendering your OpenAPI definition.
|
|
|
|
You should select the option that best fits your needs.
|
|
|
|
|
|
|
|
The following options are supported:
|
|
|
|
|
|
|
|
- **[Live demo](https://redocly.github.io/redoc/):**
|
2023-07-11 20:31:52 +03:00
|
|
|
The live demo offers a fast way to see how your OpenAPI renders with Redoc.
|
2021-11-23 08:07:56 +03:00
|
|
|
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**.
|
|
|
|
- **[HTML element](./html.md):**
|
|
|
|
Using the HTML element works well for typical website deployments.
|
|
|
|
- **[React component](./react.md):**
|
|
|
|
Using the React component is an option for users with a React-based application.
|
|
|
|
- **[Docker image](./docker.md):**
|
|
|
|
Using the Docker image works in a container-based deployment.
|
2023-03-31 20:40:37 +03:00
|
|
|
- **[Redocly CLI](./cli.md):**
|
|
|
|
Using the Redocly CLI is an option for users who prefer to use a command-line interface.
|
2021-11-23 08:07:56 +03:00
|
|
|
|
|
|
|
## Before you start
|
|
|
|
|
|
|
|
### OpenAPI definition
|
|
|
|
|
2023-07-11 20:31:52 +03:00
|
|
|
You need an OpenAPI definition. For testing purposes, you can use one of the following sample OpenAPI definitions:
|
2021-11-24 17:47:24 +03:00
|
|
|
|
2021-11-23 08:07:56 +03:00
|
|
|
- OpenAPI 3.0
|
2021-11-24 17:47:24 +03:00
|
|
|
- [Rebilly Users OpenAPI Definition](https://raw.githubusercontent.com/Rebilly/api-definitions/main/openapi/users.yaml)
|
|
|
|
- [Swagger Petstore Sample OpenAPI Definition](https://petstore3.swagger.io/api/v3/openapi.json)
|
2021-11-23 08:07:56 +03:00
|
|
|
- OpenAPI 2.0
|
2021-11-24 17:47:24 +03:00
|
|
|
- [Thingful OpenAPI Definition](https://raw.githubusercontent.com/thingful/openapi-spec/master/spec/swagger.yaml)
|
|
|
|
- [Fitbit Plus OpenAPI Definition](https://raw.githubusercontent.com/TwineHealth/TwineDeveloperDocs/master/spec/swagger.yaml)
|
2021-11-23 20:46:45 +03:00
|
|
|
|
2023-10-09 19:35:52 +03:00
|
|
|
{% admonition type="info" name="OpenAPI specification" %}
|
2022-03-14 13:21:58 +03:00
|
|
|
For more information on the OpenAPI specification, refer to the [Learning OpenAPI 3](https://redocly.com/docs/resources/learning-openapi/)
|
2021-11-23 08:07:56 +03:00
|
|
|
section in the documentation.
|
2023-10-09 19:35:52 +03:00
|
|
|
{% /admonition %}
|
2021-11-23 08:07:56 +03:00
|
|
|
|
2022-02-09 15:18:16 +03:00
|
|
|
### How to run Redoc locally
|
2021-11-23 08:07:56 +03:00
|
|
|
|
|
|
|
If you want to view your Redoc output locally, you can simulate an HTTP server.
|
|
|
|
|
2022-05-06 19:38:07 +03:00
|
|
|
#### Redocly CLI
|
2021-11-23 08:07:56 +03:00
|
|
|
|
2022-05-06 19:38:07 +03:00
|
|
|
Redocly CLI is an open source command-line tool that includes a command
|
2021-11-23 08:07:56 +03:00
|
|
|
for simulating an HTTP server to provide a preview of your OpenAPI definition locally.
|
|
|
|
|
2022-05-06 19:38:07 +03:00
|
|
|
If you have [Redocly CLI](https://redocly.com/docs/cli/#installation-and-usage) installed, `cd` into your
|
2021-11-23 08:07:56 +03:00
|
|
|
project directory and run the following command:
|
|
|
|
|
|
|
|
```bash
|
2023-05-26 18:11:14 +03:00
|
|
|
redocly preview-docs openapi.yaml
|
2021-11-23 08:07:56 +03:00
|
|
|
```
|
|
|
|
|
2021-11-23 20:46:45 +03:00
|
|
|
Replace `openapi.yaml` in the example command with the file path to your OpenAPI definition.
|
2021-11-23 08:07:56 +03:00
|
|
|
|
|
|
|
By default, without providing a port, the preview starts on port 8080, and can be accessed at `http://localhost:8080`.
|
|
|
|
To exit the preview, use `control+C`.
|
|
|
|
|
|
|
|
You can alter the port if you are using 8080 already, for example:
|
|
|
|
|
|
|
|
```bash
|
2023-05-26 18:11:14 +03:00
|
|
|
redocly preview-docs -p 8888 openapi.yaml
|
2021-11-23 08:07:56 +03:00
|
|
|
```
|
|
|
|
|
2021-11-23 20:46:45 +03:00
|
|
|
Replace `openapi.yaml` in the example command with the file path to your OpenAPI definition.
|
2021-11-23 08:07:56 +03:00
|
|
|
|
|
|
|
For more information about the `preview-docs` command, refer to
|
2022-05-06 19:38:07 +03:00
|
|
|
[Redocly CLI commands](https://redocly.com/docs/cli/commands/preview-docs/#preview-docs) in the Redocly CLI documentation.
|
2021-11-23 08:07:56 +03:00
|
|
|
|
2022-02-09 15:18:16 +03:00
|
|
|
#### Python
|
2021-11-23 08:07:56 +03:00
|
|
|
|
|
|
|
If you have [Python 3](https://www.python.org/downloads/) installed, `cd` into your
|
|
|
|
project directory and run the following command:
|
|
|
|
|
|
|
|
```python
|
|
|
|
python3 -m http.server
|
|
|
|
```
|
|
|
|
|
|
|
|
If you have [Python 2](https://www.python.org/downloads/) installed, `cd` into your
|
|
|
|
project directory and run the following command:
|
|
|
|
|
|
|
|
```python
|
|
|
|
python -m SimpleHTTPServer 8000
|
|
|
|
```
|
|
|
|
|
|
|
|
The output after entering the command provides the local URL where the preview can be accessed.
|
|
|
|
To exit the preview, use `control-C`.
|
|
|
|
|
2022-02-09 15:18:16 +03:00
|
|
|
#### Node.js
|
2021-11-23 08:07:56 +03:00
|
|
|
|
|
|
|
If you have [Node.js](https://nodejs.org/en/download/) installed, install `http-server`
|
|
|
|
using the following npm command:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
npm install -g http-server
|
|
|
|
```
|
|
|
|
|
|
|
|
Then, `cd` into your project directory and run the following command:
|
|
|
|
|
|
|
|
```node
|
2023-10-09 19:35:52 +03:00
|
|
|
http - server;
|
2021-11-23 08:07:56 +03:00
|
|
|
```
|
|
|
|
|
|
|
|
The output after entering the command provides the local URL where the preview can be accessed.
|
|
|
|
To exit the preview, use `control-C`.
|