New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docs: fully revised preview-docs command for openapi-cli #361
Merged
swapnilogale
merged 8 commits into
Redocly:master
from
bandantonio:docs-preview-docs-command
Oct 14, 2021
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e5eed5b
docs: fully revised preview-docs command for openapi-cli
bandantonio 74c76c0
docs: made content more consistent on the cli preview-docs command page
bandantonio b90eda4
docs: added information about port for preview-docs command
bandantonio 3c41d24
docs: fixed minor inconsistencies in preview-docs command
bandantonio 784203a
fix: minor phrasing issues
ivana-isadora b5d5252
Update docs/commands/preview-docs.md
ivana-isadora d8fc07a
docs: updated preview-docs command according to mentions
bandantonio e5508e3
Merge branch 'docs-preview-docs-command' of github.com:bandantonio/op…
bandantonio File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,100 @@ | ||
# `preview-docs` | ||
|
||
Preview the API reference docs on your local machine. | ||
## Introduction | ||
|
||
If you have a license key, you will have a preview of the premium Redocly API reference docs. The [`login`](./login.md) command also generates a preview of the premium Redocly API reference docs. | ||
With this command, you can generate documentation previews for API definitions on your local machine. | ||
|
||
Otherwise, you'll get a preview of Redoc community edition. | ||
If you have a license key or API key, you will get a preview of the premium [Redocly API reference docs](https://redoc.ly/reference-docs). If you don't, you will get a preview of [Redoc community edition](https://redoc.ly/redoc). | ||
|
||
:::success Tip | ||
To preview docs using the premium Redocly API reference docs, you must first authenticate to the API registry with the [`login`](./login.md) command. | ||
::: | ||
|
||
### `preview-docs` usage | ||
## Usage | ||
|
||
```bash | ||
openapi preview-docs <entrypoint> [branchName] | ||
openapi preview-docs <entrypoint> [--config=<path>] [--port=<value>] [branchName] | ||
openapi preview-docs <entrypoint> [--force] [--help] [--version] [branchName] | ||
openapi preview-docs <entrypoint> --version | ||
``` | ||
|
||
## Options | ||
|
||
Option | Type | Required | Default | Description | ||
--------------------------|:---------:|:------------:|:-----------:|------------ | ||
`entrypoint` | `string` | yes | - | Path to the API definition filename or configuration alias that you want to generate preview for. Refer to [the entrypoints section](#entrypoints) for more options. | ||
`--config` | `string` | no | - | Specify path to the [config file](#custom-configuration-file) | ||
`--force`, `-f` | `boolean` | no | - | Generate preview output even when errors occur | ||
`--help` | `boolean` | no | - | Show help | ||
`--port`, `-p` | `number` | no | 8080 | Specify the port where the documentation preview can be accessed. You can set any port as long as it is not used by applications in your operating system. | ||
`--skip-decorator` | `array` | no | - | Ignore [certain decorators](#skip-preprocessor-or-decorator) | ||
`--skip-preprocessor` | `array` | no | - | Ignore [certain preprocessors](#skip-preprocessor-or-decorator) | ||
`--use-community-edition` | `boolean` | no | - | Force using Redoc Community Edition for docs preview | ||
`--version` | `boolean` | no | - | Show version number | ||
|
||
## Examples | ||
|
||
```shell | ||
Positionals: | ||
entrypoint [string] [required] | ||
### Entrypoints | ||
|
||
Options: | ||
--version Show version number. [boolean] | ||
--help Show help. [boolean] | ||
--port, -p Preview port. [number] [default: 8080] | ||
--skip-preprocessor Ignore certain preprocessors. [array] | ||
--skip-decorator Ignore certain decorators. [array] | ||
--use-community-edition Force using Redoc CE for docs preview. [boolean] | ||
--force, -f Produce bundle output even when errors occur. | ||
[boolean] | ||
--config Specify path to the config file. [string] | ||
The command behaves differently depending on how you pass a path to the entrypoint to it and whether the [configuration file](#custom-configuration-file) exists. | ||
|
||
#### Pass entrypoint directly | ||
|
||
```bash | ||
openapi preview-docs openapi/openapi.yaml | ||
``` | ||
|
||
In this case, `preview-docs` will preview the definition that was passed to the command. The configuration file is ignored. | ||
|
||
### How to preview the docs on a custom port | ||
#### Pass entrypoint alias | ||
|
||
By default, without providing a port, the preview starts on port 8080, and can be accessed at `http://localhost:8080`. | ||
Instead of a full path, you can use an alias assigned in the `apiDefinitions` section within your `.redocly.yaml` configuration file as the entrypoint. For example, `petstore`: | ||
|
||
This command starts a preview on port 8888, and you can access the docs at `http://localhost:8888` after running it. | ||
```bash command | ||
openapi preview-docs petstore | ||
``` | ||
|
||
```yaml .redocly.yaml | ||
apiDefinitions: | ||
petstore: ./openapi/petstore-definition.json | ||
``` | ||
|
||
In this case, after resolving the path behind the `petstore` alias (example in the `.redocly.yaml` tab), `preview-docs` will preview the `petstore.json` definition file. For this approach, the `.redocly.yaml` configuration file is mandatory. | ||
|
||
### Custom configuration file | ||
|
||
By default, the CLI tool looks for a `.redocly.yaml` configuration file in the current working directory. Use the optional `--config` argument to provide an alternative path to a configuration file. | ||
|
||
```bash | ||
openapi preview-docs --config=./another/directory/config.yaml | ||
bandantonio marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
```shell | ||
### Custom port for preview | ||
|
||
By default, without using the `port` option, the preview starts on port `8080`, so you can access the docs at `http://localhost:8080` | ||
|
||
To specify a custom port for the preview, pass the desired value using either short or long option format: | ||
|
||
```bash short format | ||
openapi preview-docs -p 8888 openapi/openapi.yaml | ||
``` | ||
|
||
```bash long format | ||
openapi preview-docs -port 8888 openapi/openapi.yaml | ||
``` | ||
|
||
Both commands will start the preview on port `8888`, so you can access the docs at `http://localhost:8888` | ||
bandantonio marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
### Skip preprocessor or decorator | ||
|
||
You may want to skip specific preprocessors, rules, or decorators upon running the command. | ||
|
||
```bash Skip preprocessors | ||
openapi preview-docs --skip-preprocessor=discriminator-mapping-to-one-of,another-example | ||
``` | ||
|
||
```bash Skip decorators | ||
openapi preview-docs --skip-decorator=generate-code-samples,remove-internal-operations | ||
``` |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: This heading should be more specific in reflecting what we're doing with the entrypoint. We're passing the full path, right? I think we should focus on the differences between these 3 methods:
1 - full path
2 - just the filename
3 - alias from the config file
and make sure the headings reflect those differences.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not pretty sure about that. Let's better discuss it