mirror of
https://github.com/Redocly/redoc.git
synced 2025-08-03 03:40:23 +03:00
Merge tag 'v2.0.0-rc.65' into sections-at-the-end
This commit is contained in:
commit
99f35d22ab
22
CHANGELOG.md
22
CHANGELOG.md
|
@ -1,3 +1,25 @@
|
|||
# [2.0.0-rc.65](https://github.com/Redocly/redoc/compare/v2.0.0-rc.64...v2.0.0-rc.65) (2022-03-15)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* auth link scroll for Firerox ([#1922](https://github.com/Redocly/redoc/issues/1922)) ([fe67e9c](https://github.com/Redocly/redoc/commit/fe67e9c332fee716582a00d60fdf34767bff22d4))
|
||||
* improve customization fab ([#1891](https://github.com/Redocly/redoc/issues/1891)) ([635f379](https://github.com/Redocly/redoc/commit/635f379eb086268c91eef715148eca8f080cfb86))
|
||||
* sanitize array of items ([#1920](https://github.com/Redocly/redoc/issues/1920)) ([059bd80](https://github.com/Redocly/redoc/commit/059bd8000e5fd65753d5ca9e0c47940394e0c79b))
|
||||
* use x-displayName in securityDefinitions [#1444](https://github.com/Redocly/redoc/pull/1444)) ([ac6fb4](https://github.com/Redocly/redoc/commit/
|
||||
|
||||
|
||||
|
||||
# [2.0.0-rc.64](https://github.com/Redocly/redoc/compare/v2.0.0-rc.63...v2.0.0-rc.64) (2022-02-24)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* bump json-pointer version to avoid CVE-2021-23820 ([#1910](https://github.com/Redocly/redoc/issues/1910)) ([777efdd](https://github.com/Redocly/redoc/commit/777efdde35c1c8dc79dd714e1666279e9192dddb))
|
||||
* external ref in schema definition ([#1894](https://github.com/Redocly/redoc/issues/1894)) ([57cdd9f](https://github.com/Redocly/redoc/commit/57cdd9f6da38418d6214ac3c6480c5847ecd0228))
|
||||
|
||||
|
||||
|
||||
# [2.0.0-rc.63](https://github.com/Redocly/redoc/compare/v2.0.0-rc.61...v2.0.0-rc.63) (2022-01-27)
|
||||
|
||||
|
||||
|
|
|
@ -217,12 +217,18 @@ You can use all of the following options with the standalone version of the <red
|
|||
* `hideDownloadButton` - do not show "Download" spec button. **THIS DOESN'T MAKE YOUR SPEC PRIVATE**, it just hides the button.
|
||||
* `hideHostname` - if set, the protocol and hostname is not shown in the operation definition.
|
||||
* `hideLoading` - do not show loading animation. Useful for small docs.
|
||||
* `hideFab` - do not show FAB in mobile view. Useful for implementing a custom floating action button.
|
||||
* `hideSchemaPattern` - if set, the pattern is not shown in the schema.
|
||||
* `hideSingleRequestSampleTab` - do not show the request sample tab for requests with only one sample.
|
||||
* `showObjectSchemaExamples` - show object schema example in the properties, default `false`.
|
||||
* `expandSingleSchemaField` - automatically expand single field in a schema
|
||||
* `schemaExpansionLevel` - specifies whether to automatically expand schemas. Special value `"all"` expands all levels. The default value is `0`.
|
||||
* `jsonSampleExpandLevel` - set the default expand level for JSON payload samples (responses and request body). Special value `"all"` expands all levels. The default value is `2`.
|
||||
* `hideSchemaTitles` - do not display schema `title` next to to the type
|
||||
* `simpleOneOfTypeLabel` - show only unique oneOf types in the label without titles
|
||||
* `sortEnumValuesAlphabetically` - set to true, sorts all enum values in all schemas alphabetically
|
||||
* `sortOperationsAlphabetically` - set to true, sorts operations in the navigation sidebar and in the middle panel alphabetically
|
||||
* `sortTagsAlphabetically` - set to true, sorts tags in the navigation sidebar and in the middle panel alphabetically
|
||||
* `lazyRendering` - _Not implemented yet_ ~~if set, enables lazy rendering mode in ReDoc. This mode is useful for APIs with big number of operations (e.g. > 50). In this mode ReDoc shows initial screen ASAP and then renders the rest operations asynchronously while showing progress bar on the top. Check out the [demo](\\redocly.github.io/redoc) for the example.~~
|
||||
* `menuToggle` - if true clicking second time on expanded menu item will collapse it, default `true`.
|
||||
* `nativeScrollbars` - use native scrollbar for sidemenu instead of perfect-scroll (scrolling performance optimization for big specs).
|
||||
|
@ -300,6 +306,9 @@ You can use all of the following options with the standalone version of the <red
|
|||
* `backgroundColor`: '#263238'
|
||||
* `width`: '40%'
|
||||
* `textColor`: '#ffffff'
|
||||
* `fab`
|
||||
* `backgroundColor`: '#263238'
|
||||
* `color`: '#ffffff'
|
||||
|
||||
-----------
|
||||
## Development
|
||||
|
|
1337
cli/npm-shrinkwrap.json
generated
1337
cli/npm-shrinkwrap.json
generated
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "redoc-cli",
|
||||
"version": "0.13.6",
|
||||
"version": "0.13.8",
|
||||
"description": "ReDoc's Command Line Interface",
|
||||
"main": "index.js",
|
||||
"bin": "index.js",
|
||||
|
@ -19,7 +19,7 @@
|
|||
"node-libs-browser": "^2.2.1",
|
||||
"react": "^17.0.1",
|
||||
"react-dom": "^17.0.1",
|
||||
"redoc": "2.0.0-rc.62",
|
||||
"redoc": "2.0.0-rc.64",
|
||||
"styled-components": "^5.3.0",
|
||||
"yargs": "^17.0.1"
|
||||
},
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
---
|
||||
title: Using the Redoc CLI
|
||||
redirectFrom:
|
||||
title: Use the Redoc CLI
|
||||
redirectFrom:
|
||||
- /docs/quickstart/cli/
|
||||
---
|
||||
|
||||
# Using the Redoc CLI
|
||||
# How to use the Redoc CLI
|
||||
|
||||
With Redoc's command-line interface you can bundle your OpenAPI definition and API documentation
|
||||
(made with Redoc) into a zero-dependency HTML file and locally render your
|
||||
|
@ -21,7 +21,7 @@ Or you can install `redoc-cli` using [npx](https://www.freecodecamp.org/news/npm
|
|||
|
||||
### Install Redoc CLI with yarn
|
||||
|
||||
To install the `redoc-cli` package globally with yarn:
|
||||
To install the `redoc-cli` package globally with yarn:
|
||||
|
||||
```bash
|
||||
yarn global add redoc-cli
|
||||
|
@ -29,7 +29,7 @@ yarn global add redoc-cli
|
|||
|
||||
### Install Redoc with npm
|
||||
|
||||
To install the `redoc-cli` package globally with npm:
|
||||
To install the `redoc-cli` package globally with npm:
|
||||
|
||||
```bash
|
||||
npm i -g redoc-cli
|
||||
|
@ -52,9 +52,9 @@ The CLI includes the following commands:
|
|||
|
||||
- **`redoc-cli serve [spec]`:** Starts a local server with Redoc. You must include the required parameter, spec, which is
|
||||
a reference to an OpenAPI definition. Options include:
|
||||
- `--ssr`: Implements a server-side rendering model.
|
||||
- `--ssr`: Implements a server-side rendering model.
|
||||
- `--watch`: Automatically reloads the server while you edit your OpenAPI definition.
|
||||
- `--options`: Customizes your output using [Redoc options](https://redoc.ly/docs/api-reference-docs/configuration/).
|
||||
- `--options`: Customizes your output using [Redoc options](https://redocly.com/docs/api-reference-docs/configuration/).
|
||||
To add nested options, use dot notation.
|
||||
- **`redoc-cli bundle [spec]`:** Bundles `spec` and Redoc into a zero-dependency HTML file. Options include:
|
||||
- `-t` or `--template`: Uses custom [Handlebars](https://handlebarsjs.com/) templates to render your OpenAPI definition.
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
---
|
||||
title: Using the Redoc Docker image
|
||||
title: Use the Redoc Docker image
|
||||
redirectFrom:
|
||||
- /docs/quickstart/docker/
|
||||
---
|
||||
|
||||
# Using the Redoc Docker image
|
||||
# How to use the Redoc Docker image
|
||||
|
||||
Redoc is available as a pre-built Docker image in [Docker Hub](https://hub.docker.com/r/redocly/redoc/).
|
||||
|
||||
|
@ -26,7 +26,7 @@ To exit the preview, use `control+C`.
|
|||
|
||||
By default Redoc starts with a demo Swagger Petstore OpenAPI definition located at
|
||||
http://petstore.swagger.io/v2/swagger.json. You can update this URL using
|
||||
the environment variable `SPEC_URL`.
|
||||
the environment variable `SPEC_URL`.
|
||||
|
||||
For example:
|
||||
|
||||
|
@ -34,8 +34,8 @@ For example:
|
|||
docker run -p 8080:80 -e SPEC_URL=https://api.example.com/openapi.json redocly/redoc
|
||||
```
|
||||
|
||||
## Using a Dockerfile
|
||||
## Create a Dockerfile
|
||||
|
||||
You can also create a Dockerfile with some predefined environment variables. Check out
|
||||
a sample [Dockerfile](https://github.com/Redocly/redoc/blob/master/config/docker/Dockerfile)
|
||||
in our code repo.
|
||||
in our code repo.
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
---
|
||||
title: Using the Redoc HTML element
|
||||
title: Use the Redoc HTML element
|
||||
redirectFrom:
|
||||
- /docs/quickstart/html/
|
||||
---
|
||||
|
||||
# Using the Redoc HTML element
|
||||
# How to use the Redoc HTML element
|
||||
|
||||
## Step 1 - Install Redoc
|
||||
|
||||
|
@ -17,9 +17,9 @@ You can install Redoc using one of the following package managers:
|
|||
If you do not have a `package.json` file in your project directory,
|
||||
you need to add one by initializing npm or yarn in your project. Use the command `npm init` for npm,
|
||||
or `yarn init` for yarn. These initialization commands will lead you through the process
|
||||
of creating a `package.json` file in your project.
|
||||
of creating a `package.json` file in your project.
|
||||
|
||||
For more information, see
|
||||
For more information, see
|
||||
[Creating a package.json file](https://docs.npmjs.com/creating-a-package-json-file)
|
||||
in the npm documentation or [Yarn init](https://classic.yarnpkg.com/en/docs/cli/init/)
|
||||
in the yarn documentation.
|
||||
|
@ -27,7 +27,7 @@ in the yarn documentation.
|
|||
|
||||
### Install Redoc with yarn
|
||||
|
||||
After navigating to your project directory in your terminal, use the following command:
|
||||
After navigating to your project directory in your terminal, use the following command:
|
||||
|
||||
```bash
|
||||
yarn add redoc
|
||||
|
@ -35,7 +35,7 @@ yarn add redoc
|
|||
|
||||
### Install Redoc with npm
|
||||
|
||||
After navigating to your project directory in your terminal, use the following command:
|
||||
After navigating to your project directory in your terminal, use the following command:
|
||||
|
||||
```bash
|
||||
npm i redoc
|
||||
|
@ -68,7 +68,7 @@ You can add the <redoc> element to your HTML page and reference your OpenAPI
|
|||
definition using the `spec-url` attribute, or you can initialize Redoc using
|
||||
a globally exposed Redoc object.
|
||||
|
||||
### Using the `spec-url` attribute
|
||||
### The `spec-url` attribute
|
||||
|
||||
To add the <redoc> element with the `spec-url` attribute:
|
||||
|
||||
|
@ -88,7 +88,7 @@ You can also use a local file (JSON or YAML) in your project, for instance:
|
|||
<redoc spec-url="dist.json"></redoc>
|
||||
```
|
||||
|
||||
### Using a Redoc object
|
||||
### The Redoc object
|
||||
|
||||
To add the <redoc> element with a globally exposed Redoc object:
|
||||
|
||||
|
@ -97,7 +97,7 @@ Redoc.init(specOrSpecUrl, options, element, callback)
|
|||
```
|
||||
- `specOrSpecUrl`: Either a JSON object with the OpenAPI definition or a URL to the
|
||||
definition in JSON or YAML format.
|
||||
- `options`: See [options object](https://redoc.ly/docs/api-reference-docs/configuration/) reference.
|
||||
- `options`: See [options object](https://redocly.com/docs/api-reference-docs/configuration/) reference.
|
||||
- `element`: DOM element Redoc will be inserted into.
|
||||
- `callback`(optional): Callback to be called after Redoc has been fully rendered.
|
||||
It is also called on errors with `error` as the first argument.
|
||||
|
@ -120,4 +120,4 @@ Redoc.init('dist.yaml', {
|
|||
scrollYOffset: 50
|
||||
}, document.getElementById('redoc-container'))
|
||||
</script>
|
||||
```
|
||||
```
|
||||
|
|
|
@ -38,20 +38,20 @@ You will need an OpenAPI definition. For testing purposes, you can use one of th
|
|||
- [Fitbit Plus OpenAPI Definition](https://raw.githubusercontent.com/TwineHealth/TwineDeveloperDocs/master/spec/swagger.yaml)
|
||||
|
||||
:::info OpenAPI specification
|
||||
For more information on the OpenAPI specification, refer to the [Learning OpenAPI 3](https://redoc.ly/docs/resources/learning-openapi/)
|
||||
For more information on the OpenAPI specification, refer to the [Learning OpenAPI 3](https://redocly.com/docs/resources/learning-openapi/)
|
||||
section in the documentation.
|
||||
:::
|
||||
|
||||
### Running Redoc locally
|
||||
### How to run Redoc locally
|
||||
|
||||
If you want to view your Redoc output locally, you can simulate an HTTP server.
|
||||
|
||||
#### Using Redocly OpenAPI CLI
|
||||
#### Redocly OpenAPI CLI
|
||||
|
||||
Redocly OpenAPI CLI is an open source command-line tool that includes a command
|
||||
for simulating an HTTP server to provide a preview of your OpenAPI definition locally.
|
||||
|
||||
If you have [OpenAPI CLI](https://redoc.ly/docs/cli/#installation-and-usage) installed, `cd` into your
|
||||
If you have [OpenAPI CLI](https://redocly.com/docs/cli/#installation-and-usage) installed, `cd` into your
|
||||
project directory and run the following command:
|
||||
|
||||
```bash
|
||||
|
@ -72,9 +72,9 @@ openapi preview-docs -p 8888 openapi.yaml
|
|||
Replace `openapi.yaml` in the example command with the file path to your OpenAPI definition.
|
||||
|
||||
For more information about the `preview-docs` command, refer to
|
||||
[OpenAPI CLI commands](https://redoc.ly/docs/cli/commands/preview-docs/#preview-docs) in the OpenAPI CLI documentation.
|
||||
[OpenAPI CLI commands](https://redocly.com/docs/cli/commands/preview-docs/#preview-docs) in the OpenAPI CLI documentation.
|
||||
|
||||
#### Using Python
|
||||
#### Python
|
||||
|
||||
If you have [Python 3](https://www.python.org/downloads/) installed, `cd` into your
|
||||
project directory and run the following command:
|
||||
|
@ -93,7 +93,7 @@ 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`.
|
||||
|
||||
#### Using Node.js
|
||||
#### Node.js
|
||||
|
||||
If you have [Node.js](https://nodejs.org/en/download/) installed, install `http-server`
|
||||
using the following npm command:
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
---
|
||||
title: Using the Redoc React component
|
||||
title: Use the Redoc React component
|
||||
redirectFrom:
|
||||
- /docs/quickstart/react/
|
||||
---
|
||||
|
||||
# Using the Redoc React component
|
||||
# How to use the Redoc React component
|
||||
|
||||
## Before you start
|
||||
|
||||
|
@ -44,7 +44,7 @@ Or you can pass your OpenAPI definition as an object, using the following format
|
|||
|
||||
## Optional - Pass options
|
||||
|
||||
Options can be passed into the RedocStandalone component to alter how it renders.
|
||||
Options can be passed into the RedocStandalone component to alter how it renders.
|
||||
|
||||
For example:
|
||||
|
||||
|
@ -58,8 +58,8 @@ For example:
|
|||
/>
|
||||
```
|
||||
|
||||
For more information on configuration options, refer to the
|
||||
[Configuration options for Reference docs](https://redoc.ly/docs/api-reference-docs/configuration/)
|
||||
For more information on configuration options, refer to the
|
||||
[Configuration options for Reference docs](https://redocly.com/docs/api-reference-docs/configuration/)
|
||||
section of the documentation. Options available for Redoc are noted,
|
||||
"Supported in Redoc CE".
|
||||
|
||||
|
|
|
@ -43,11 +43,12 @@ replace the `spec-url` attribute with the URL or local file address to your defi
|
|||
</html>
|
||||
```
|
||||
|
||||
:::attention Running Redoc locally requires an HTTP server
|
||||
:::attention Redoc requires an HTTP server to run locally
|
||||
|
||||
Loading local OpenAPI definitions is impossible without running a web server because of issues with
|
||||
[same-origin policy](https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy) and
|
||||
other security reasons. Refer to [Running Redoc locally](./deployment/intro.md#running-redoc-locally) for
|
||||
more information.
|
||||
other security reasons. Refer to [Running Redoc locally](./deployment/intro.md#how-to-run-redoc-locally) for more information.
|
||||
|
||||
:::
|
||||
|
||||
For a more detailed explanation with step-by-step instructions and additional options for using Redoc, refer to the [Redoc deployment guide](./deployment/intro.md).
|
||||
|
|
|
@ -19,7 +19,7 @@ Or you can install `redoc-cli` using [npx](https://www.freecodecamp.org/news/npm
|
|||
|
||||
### Install Redoc CLI with yarn
|
||||
|
||||
To install the `redoc-cli` package globally with yarn:
|
||||
To install the `redoc-cli` package globally with yarn:
|
||||
|
||||
```bash
|
||||
yarn global add redoc-cli
|
||||
|
@ -27,7 +27,7 @@ yarn global add redoc-cli
|
|||
|
||||
### Install Redoc with npm
|
||||
|
||||
To install the `redoc-cli` package globally with npm:
|
||||
To install the `redoc-cli` package globally with npm:
|
||||
|
||||
```bash
|
||||
npm i -g redoc-cli
|
||||
|
@ -50,9 +50,9 @@ The CLI includes the following commands:
|
|||
|
||||
- **`redoc-cli serve [spec]`:** Starts a local server with Redoc. You must include the required parameter, spec, which is
|
||||
a reference to an OpenAPI definition. Options include:
|
||||
- `--ssr`: Implements a server-side rendering model.
|
||||
- `--ssr`: Implements a server-side rendering model.
|
||||
- `--watch`: Automatically reloads the server while you edit your OpenAPI definition.
|
||||
- `--options`: Customizes your output using [Redoc options](https://redoc.ly/docs/api-reference-docs/configuration/).
|
||||
- `--options`: Customizes your output using [Redoc options](https://redocly.com/docs/api-reference-docs/configuration/).
|
||||
To add nested options, use dot notation.
|
||||
- **`redoc-cli bundle [spec]`:** Bundles `spec` and Redoc into a zero-dependency HTML file. Options include:
|
||||
- `-t` or `--template`: Uses custom [Handlebars](https://handlebarsjs.com/) templates to render your OpenAPI definition.
|
||||
|
|
|
@ -37,7 +37,7 @@ title: Using the Redoc HTML element
|
|||
:::attention Running Redoc locally requires an HTTP server
|
||||
Loading local OpenAPI definitions is impossible without running a web server because of issues with
|
||||
[same-origin policy](https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy) and
|
||||
other security reasons.
|
||||
other security reasons.
|
||||
:::
|
||||
|
||||
### Running Redoc locally
|
||||
|
@ -49,7 +49,7 @@ If you want to view your Redoc output locally, you can simulate an HTTP server.
|
|||
Redocly OpenAPI CLI is an open source command-line tool that includes a command
|
||||
for simulating an HTTP server to provide a preview of your OpenAPI definition locally.
|
||||
|
||||
If you have [OpenAPI CLI](https://redoc.ly/docs/cli/#installation-and-usage) installed, `cd` into your
|
||||
If you have [OpenAPI CLI](https://redocly.com/docs/cli/#installation-and-usage) installed, `cd` into your
|
||||
project directory and run the following command:
|
||||
|
||||
```bash
|
||||
|
@ -107,9 +107,9 @@ You can install Redoc using one of the following package managers:
|
|||
If you do not have a `package.json` file in your project directory,
|
||||
you need to add one by initializing npm or yarn in your project. Use the command `npm init` for npm,
|
||||
or `yarn init` for yarn. These initialization commands will lead you through the process
|
||||
of creating a `package.json` file in your project.
|
||||
of creating a `package.json` file in your project.
|
||||
|
||||
For more information, see
|
||||
For more information, see
|
||||
[Creating a package.json file](https://docs.npmjs.com/creating-a-package-json-file)
|
||||
in the npm documentation or [Yarn init](https://classic.yarnpkg.com/en/docs/cli/init/)
|
||||
in the yarn documentation.
|
||||
|
@ -118,7 +118,7 @@ in the yarn documentation.
|
|||
|
||||
### Install Redoc with yarn
|
||||
|
||||
After navigating to your project directory in your terminal, use the following command:
|
||||
After navigating to your project directory in your terminal, use the following command:
|
||||
|
||||
```bash
|
||||
yarn add redoc
|
||||
|
@ -126,7 +126,7 @@ yarn add redoc
|
|||
|
||||
### Install Redoc with npm
|
||||
|
||||
After navigating to your project directory in your terminal, use the following command:
|
||||
After navigating to your project directory in your terminal, use the following command:
|
||||
|
||||
```bash
|
||||
npm i redoc
|
||||
|
@ -188,7 +188,7 @@ Redoc.init(specOrSpecUrl, options, element, callback)
|
|||
```
|
||||
- `specOrSpecUrl`: Either a JSON object with the OpenAPI definition or a URL to the
|
||||
definition in JSON or YAML format.
|
||||
- `options`: See [options object](https://redoc.ly/docs/api-reference-docs/configuration/) reference.
|
||||
- `options`: See [options object](https://redocly.com/docs/api-reference-docs/configuration/) reference.
|
||||
- `element`: DOM element Redoc will be inserted into.
|
||||
- `callback`(optional): Callback to be called after Redoc has been fully rendered.
|
||||
It is also called on errors with `error` as the first argument.
|
||||
|
@ -211,4 +211,4 @@ Redoc.init('dist.yaml', {
|
|||
scrollYOffset: 50
|
||||
}, document.getElementById('redoc-container'))
|
||||
</script>
|
||||
```
|
||||
```
|
||||
|
|
|
@ -25,7 +25,7 @@ The following options are supported:
|
|||
|
||||
## Before you start
|
||||
|
||||
You will need an OpenAPI definition. For testing purposes, you can use one of the following sample OpenAPI definitions:
|
||||
You will need an OpenAPI definition. For testing purposes, you can use one of the following sample OpenAPI definitions:
|
||||
- OpenAPI 3.0
|
||||
- [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)
|
||||
|
@ -33,7 +33,7 @@ You will need an OpenAPI definition. For testing purposes, you can use one of th
|
|||
- [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)
|
||||
|
||||
For more information on the OpenAPI specification, refer to the [Learning OpenAPI 3](https://redoc.ly/docs/resources/learning-openapi/)
|
||||
For more information on the OpenAPI specification, refer to the [Learning OpenAPI 3](https://redocly.com/docs/resources/learning-openapi/)
|
||||
section in the documentation.
|
||||
|
||||
## Live demo online
|
||||
|
|
|
@ -42,7 +42,7 @@ Or you can pass your OpenAPI definition as an object, using the following format
|
|||
|
||||
## Optional - Pass options
|
||||
|
||||
Options can be passed into the RedocStandalone component to alter how it renders.
|
||||
Options can be passed into the RedocStandalone component to alter how it renders.
|
||||
|
||||
For example:
|
||||
|
||||
|
@ -56,8 +56,8 @@ For example:
|
|||
/>
|
||||
```
|
||||
|
||||
For more information on configuration options, refer to the
|
||||
[Configuration options for Reference docs](https://redoc.ly/docs/api-reference-docs/configuration/)
|
||||
For more information on configuration options, refer to the
|
||||
[Configuration options for Reference docs](https://redocly.com/docs/api-reference-docs/configuration/)
|
||||
section of the documentation. Options available for Redoc are noted,
|
||||
"Supported in Redoc CE".
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# ReDoc vendor extensions
|
||||
# Redoc vendor extensions
|
||||
|
||||
You can use the following [vendor extensions](https://swagger.io/specification/#specificationExtensions) with Redoc.
|
||||
|
||||
|
@ -194,8 +194,8 @@ Extends the OpenAPI [Operation Object](http://swagger.io/specification/#operatio
|
|||
| :------------- | :------: | :---------- |
|
||||
| x-codeSamples | [ [Code Sample Object](#codeSampleObject) ] | A list of code samples associated with operation |
|
||||
|
||||
###### How to use with ReDoc
|
||||
`x-codeSamples` are rendered on the right panel in ReDoc.
|
||||
###### How to use with Redoc
|
||||
`x-codeSamples` are rendered on the right panel in Redoc.
|
||||
|
||||
#### <a name="codeSampleObject"></a>Code Sample Object
|
||||
Operation code sample
|
||||
|
@ -230,8 +230,8 @@ Extends the OpenAPI [Parameter Object](http://swagger.io/specification/#paramete
|
|||
| :------------- | :------: | :---------- |
|
||||
| x-examples | [Example Object](http://swagger.io/specification/#exampleObject) | Object that contains examples for the request. Applies when `in` is `body` and mime-type is `application/json` |
|
||||
|
||||
###### How to use with ReDoc
|
||||
`x-examples` are rendered in the JSON tab on the right panel in ReDoc.
|
||||
###### How to use with Redoc
|
||||
`x-examples` are rendered in the JSON tab on the right panel in Redoc.
|
||||
|
||||
### Response Object vendor extensions
|
||||
Extends the OpenAPI [Response Object](https://swagger.io/specification/#responseObject)
|
||||
|
@ -241,7 +241,7 @@ Extends the OpenAPI [Response Object](https://swagger.io/specification/#response
|
|||
| :------------- | :------: | :---------- |
|
||||
| x-summary | string | a short summary of the response |
|
||||
|
||||
###### How to use with ReDoc
|
||||
###### How to use with Redoc
|
||||
If specified, you can use `x-summary` as the response button text, with description rendered under the button.
|
||||
|
||||
### Schema Object
|
||||
|
@ -252,21 +252,21 @@ Extends the OpenAPI [Schema Object](http://swagger.io/specification/#schemaObjec
|
|||
| :------------- | :------: | :---------- |
|
||||
| x-nullable | boolean | marks schema as a nullable |
|
||||
|
||||
###### How to use with ReDoc
|
||||
Schemas marked as `x-nullable` are marked in ReDoc with the label Nullable
|
||||
###### How to use with Redoc
|
||||
Schemas marked as `x-nullable` are marked in Redoc with the label Nullable
|
||||
|
||||
#### x-extendedDiscriminator
|
||||
**ATTENTION**: This is a ReDoc-specific vendor extension, and is not supported by other tools.
|
||||
**ATTENTION**: This is a Redoc-specific vendor extension, and is not supported by other tools.
|
||||
|
||||
| Field Name | Type | Description |
|
||||
| :------------- | :------: | :---------- |
|
||||
| x-extendedDiscriminator | string | specifies extended discriminator |
|
||||
|
||||
###### How to use with ReDoc
|
||||
ReDoc uses this vendor extension to solve name-clash issues with the standard `discriminator`.
|
||||
###### How to use with Redoc
|
||||
Redoc uses this vendor extension to solve name-clash issues with the standard `discriminator`.
|
||||
Value of this field specifies the field which will be used as a extended discriminator.
|
||||
ReDoc displays definition with selectpicker using which user can select value of the `x-extendedDiscriminator`-marked field.
|
||||
ReDoc displays the definition derived from the current (using `allOf`) and has `enum` with only one value which is the same as the selected value of the field specified as `x-extendedDiscriminator`.
|
||||
Redoc displays definition with selectpicker using which user can select value of the `x-extendedDiscriminator`-marked field.
|
||||
Redoc displays the definition derived from the current (using `allOf`) and has `enum` with only one value which is the same as the selected value of the field specified as `x-extendedDiscriminator`.
|
||||
|
||||
###### x-extendedDiscriminator example
|
||||
|
||||
|
@ -309,7 +309,7 @@ PayPalPayment:
|
|||
In the example above, the names of definitions (`PayPalPayment`) are named differently than names in the payload (`paypal`) which is not supported by default `discriminator`.
|
||||
|
||||
#### x-additionalPropertiesName
|
||||
**ATTENTION**: This is a ReDoc-specific vendor extension, and is not supported by other tools.
|
||||
**ATTENTION**: This is a Redoc-specific vendor extension, and is not supported by other tools.
|
||||
|
||||
Extends the `additionalProperties` property of the schema object.
|
||||
|
||||
|
@ -317,8 +317,8 @@ Extends the `additionalProperties` property of the schema object.
|
|||
| :------------- | :------: | :---------- |
|
||||
| x-additionalPropertiesName | string | descriptive name of additional properties keys |
|
||||
|
||||
###### How to use with ReDoc
|
||||
ReDoc uses this extension to display a more descriptive property name in objects with `additionalProperties` when viewing the property list with an `object`.
|
||||
###### How to use with Redoc
|
||||
Redoc uses this extension to display a more descriptive property name in objects with `additionalProperties` when viewing the property list with an `object`.
|
||||
|
||||
###### x-additionalPropertiesName example
|
||||
|
||||
|
@ -337,7 +337,7 @@ Player:
|
|||
```
|
||||
|
||||
#### x-explicitMappingOnly
|
||||
**ATTENTION**: This is ReDoc-specific vendor extension, and is not supported by other tools.
|
||||
**ATTENTION**: This is Redoc-specific vendor extension, and is not supported by other tools.
|
||||
|
||||
Extends the `discriminator` property of the schema object.
|
||||
|
||||
|
@ -345,8 +345,8 @@ Extends the `discriminator` property of the schema object.
|
|||
| :------------- | :------: | :---------- |
|
||||
| x-explicitMappingOnly | boolean | limit the discriminator selectpicker to the explicit mappings only |
|
||||
|
||||
###### How to use with ReDoc
|
||||
ReDoc uses this extension to filter the `discriminator` mappings shown in the selectpicker.
|
||||
###### How to use with Redoc
|
||||
Redoc uses this extension to filter the `discriminator` mappings shown in the selectpicker.
|
||||
When set to `true`, the selectpicker will only list the the explicitly defined mappings. When `false`, the default behavior is kept, i.e. explicit and implicit mappings will be shown.
|
||||
|
||||
###### x-explicitMappingOnly example
|
||||
|
|
65
package-lock.json
generated
65
package-lock.json
generated
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "redoc",
|
||||
"version": "2.0.0-rc.63",
|
||||
"version": "2.0.0-rc.65",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "redoc",
|
||||
"version": "2.0.0-rc.63",
|
||||
"version": "2.0.0-rc.65",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@redocly/openapi-core": "^1.0.0-beta.54",
|
||||
|
@ -15,16 +15,16 @@
|
|||
"decko": "^1.2.0",
|
||||
"dompurify": "^2.2.8",
|
||||
"eventemitter3": "^4.0.7",
|
||||
"json-pointer": "^0.6.1",
|
||||
"json-pointer": "^0.6.2",
|
||||
"lunr": "^2.3.9",
|
||||
"mark.js": "^8.11.1",
|
||||
"marked": "^4.0.10",
|
||||
"mobx-react": "^7.2.0",
|
||||
"openapi-sampler": "^1.1.1",
|
||||
"openapi-sampler": "^1.2.1",
|
||||
"path-browserify": "^1.0.1",
|
||||
"perfect-scrollbar": "^1.5.1",
|
||||
"polished": "^4.1.3",
|
||||
"prismjs": "^1.24.1",
|
||||
"prismjs": "^1.27.0",
|
||||
"prop-types": "^15.7.2",
|
||||
"react-tabs": "^3.2.2",
|
||||
"slugify": "~1.4.7",
|
||||
|
@ -8209,9 +8209,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"node_modules/follow-redirects": {
|
||||
"version": "1.14.7",
|
||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.7.tgz",
|
||||
"integrity": "sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ==",
|
||||
"version": "1.14.8",
|
||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.8.tgz",
|
||||
"integrity": "sha512-1x0S9UVJHsQprFcEC/qnNzBLcIxsjAV905f/UkQxbclCsoTWlacCNOpQa/anodLl2uaEKFhfWOvM2Qg77+15zA==",
|
||||
"dev": true,
|
||||
"funding": [
|
||||
{
|
||||
|
@ -12463,9 +12463,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"node_modules/json-pointer": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/json-pointer/-/json-pointer-0.6.1.tgz",
|
||||
"integrity": "sha512-3OvjqKdCBvH41DLpV4iSt6v2XhZXV1bPB4OROuknvUXI7ZQNofieCPkmE26stEJ9zdQuvIxDHCuYhfgxFAAs+Q==",
|
||||
"version": "0.6.2",
|
||||
"resolved": "https://registry.npmjs.org/json-pointer/-/json-pointer-0.6.2.tgz",
|
||||
"integrity": "sha512-vLWcKbOaXlO+jvRy4qNd+TI1QUPZzfJj1tpJ3vAXDych5XJf93ftpUKe5pKCrzyIIwgBJcOcCVRUfqQP25afBw==",
|
||||
"dependencies": {
|
||||
"foreach": "^2.0.4"
|
||||
}
|
||||
|
@ -14191,12 +14191,12 @@
|
|||
}
|
||||
},
|
||||
"node_modules/openapi-sampler": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/openapi-sampler/-/openapi-sampler-1.1.1.tgz",
|
||||
"integrity": "sha512-WAFsl5SPYuhQwaMTDFOcKhnEY1G1rmamrMiPmJdqwfl1lr81g63/befcsN9BNi0w5/R0L+hfcUj13PANEBeLgg==",
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/openapi-sampler/-/openapi-sampler-1.2.1.tgz",
|
||||
"integrity": "sha512-mHrYmyvcLD0qrfqPkPRBAL2z16hGT2rW0d0B7nklfoTcc3pmkJLkSZlKSeFgerUM41E5c7jlxf0Y19xrM7mWQQ==",
|
||||
"dependencies": {
|
||||
"@types/json-schema": "^7.0.7",
|
||||
"json-pointer": "^0.6.1"
|
||||
"json-pointer": "0.6.2"
|
||||
}
|
||||
},
|
||||
"node_modules/optionator": {
|
||||
|
@ -15036,9 +15036,12 @@
|
|||
}
|
||||
},
|
||||
"node_modules/prismjs": {
|
||||
"version": "1.25.0",
|
||||
"resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.25.0.tgz",
|
||||
"integrity": "sha512-WCjJHl1KEWbnkQom1+SzftbtXMKQoezOCYs5rECqMN+jP+apI7ftoflyqigqzopSO3hMhTEb0mFClA8lkolgEg=="
|
||||
"version": "1.27.0",
|
||||
"resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.27.0.tgz",
|
||||
"integrity": "sha512-t13BGPUlFDR7wRB5kQDG4jjl7XeuH6jbJGt11JHPL96qwsEHNX2+68tFXqc1/k+/jALsbSWJKUOT/hcYAZ5LkA==",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/process": {
|
||||
"version": "0.11.10",
|
||||
|
@ -25358,9 +25361,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"follow-redirects": {
|
||||
"version": "1.14.7",
|
||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.7.tgz",
|
||||
"integrity": "sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ==",
|
||||
"version": "1.14.8",
|
||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.8.tgz",
|
||||
"integrity": "sha512-1x0S9UVJHsQprFcEC/qnNzBLcIxsjAV905f/UkQxbclCsoTWlacCNOpQa/anodLl2uaEKFhfWOvM2Qg77+15zA==",
|
||||
"dev": true
|
||||
},
|
||||
"foreach": {
|
||||
|
@ -28493,9 +28496,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"json-pointer": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/json-pointer/-/json-pointer-0.6.1.tgz",
|
||||
"integrity": "sha512-3OvjqKdCBvH41DLpV4iSt6v2XhZXV1bPB4OROuknvUXI7ZQNofieCPkmE26stEJ9zdQuvIxDHCuYhfgxFAAs+Q==",
|
||||
"version": "0.6.2",
|
||||
"resolved": "https://registry.npmjs.org/json-pointer/-/json-pointer-0.6.2.tgz",
|
||||
"integrity": "sha512-vLWcKbOaXlO+jvRy4qNd+TI1QUPZzfJj1tpJ3vAXDych5XJf93ftpUKe5pKCrzyIIwgBJcOcCVRUfqQP25afBw==",
|
||||
"requires": {
|
||||
"foreach": "^2.0.4"
|
||||
}
|
||||
|
@ -29794,12 +29797,12 @@
|
|||
}
|
||||
},
|
||||
"openapi-sampler": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/openapi-sampler/-/openapi-sampler-1.1.1.tgz",
|
||||
"integrity": "sha512-WAFsl5SPYuhQwaMTDFOcKhnEY1G1rmamrMiPmJdqwfl1lr81g63/befcsN9BNi0w5/R0L+hfcUj13PANEBeLgg==",
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/openapi-sampler/-/openapi-sampler-1.2.1.tgz",
|
||||
"integrity": "sha512-mHrYmyvcLD0qrfqPkPRBAL2z16hGT2rW0d0B7nklfoTcc3pmkJLkSZlKSeFgerUM41E5c7jlxf0Y19xrM7mWQQ==",
|
||||
"requires": {
|
||||
"@types/json-schema": "^7.0.7",
|
||||
"json-pointer": "^0.6.1"
|
||||
"json-pointer": "0.6.2"
|
||||
}
|
||||
},
|
||||
"optionator": {
|
||||
|
@ -30430,9 +30433,9 @@
|
|||
}
|
||||
},
|
||||
"prismjs": {
|
||||
"version": "1.25.0",
|
||||
"resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.25.0.tgz",
|
||||
"integrity": "sha512-WCjJHl1KEWbnkQom1+SzftbtXMKQoezOCYs5rECqMN+jP+apI7ftoflyqigqzopSO3hMhTEb0mFClA8lkolgEg=="
|
||||
"version": "1.27.0",
|
||||
"resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.27.0.tgz",
|
||||
"integrity": "sha512-t13BGPUlFDR7wRB5kQDG4jjl7XeuH6jbJGt11JHPL96qwsEHNX2+68tFXqc1/k+/jALsbSWJKUOT/hcYAZ5LkA=="
|
||||
},
|
||||
"process": {
|
||||
"version": "0.11.10",
|
||||
|
|
11
package.json
11
package.json
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "redoc",
|
||||
"version": "2.0.0-rc.63",
|
||||
"version": "2.0.0-rc.65",
|
||||
"description": "ReDoc",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
@ -145,16 +145,16 @@
|
|||
"decko": "^1.2.0",
|
||||
"dompurify": "^2.2.8",
|
||||
"eventemitter3": "^4.0.7",
|
||||
"json-pointer": "^0.6.1",
|
||||
"json-pointer": "^0.6.2",
|
||||
"lunr": "^2.3.9",
|
||||
"mark.js": "^8.11.1",
|
||||
"marked": "^4.0.10",
|
||||
"mobx-react": "^7.2.0",
|
||||
"openapi-sampler": "^1.1.1",
|
||||
"openapi-sampler": "^1.2.1",
|
||||
"path-browserify": "^1.0.1",
|
||||
"perfect-scrollbar": "^1.5.1",
|
||||
"polished": "^4.1.3",
|
||||
"prismjs": "^1.24.1",
|
||||
"prismjs": "^1.27.0",
|
||||
"prop-types": "^15.7.2",
|
||||
"react-tabs": "^3.2.2",
|
||||
"slugify": "~1.4.7",
|
||||
|
@ -191,6 +191,9 @@
|
|||
"modulePathIgnorePatterns": [
|
||||
"/benchmark/"
|
||||
],
|
||||
"snapshotSerializers": [
|
||||
"enzyme-to-json/serializer"
|
||||
],
|
||||
"moduleNameMapper": {
|
||||
"\\.(css|less)$": "<rootDir>/src/empty.js"
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import styled from '../styled-components';
|
||||
import { darken } from 'polished';
|
||||
import { deprecatedCss } from './mixins';
|
||||
|
||||
export const OneOfList = styled.div`
|
||||
margin: 0 0 3px 0;
|
||||
|
@ -14,7 +15,7 @@ export const OneOfLabel = styled.span`
|
|||
}
|
||||
`;
|
||||
|
||||
export const OneOfButton = styled.button<{ active: boolean }>`
|
||||
export const OneOfButton = styled.button<{ active: boolean; deprecated: boolean }>`
|
||||
display: inline-block;
|
||||
margin-right: 10px;
|
||||
margin-bottom: 5px;
|
||||
|
@ -28,6 +29,8 @@ export const OneOfButton = styled.button<{ active: boolean }>`
|
|||
box-shadow: 0 0 0 1px ${props => props.theme.colors.primary.main};
|
||||
}
|
||||
|
||||
${({ deprecated }) => (deprecated && deprecatedCss) || ''};
|
||||
|
||||
${props => {
|
||||
if (props.active) {
|
||||
return `
|
||||
|
|
|
@ -11,7 +11,7 @@ export function ArrayItemDetails({ schema }: { schema: SchemaModel }) {
|
|||
return (
|
||||
<Wrapper>
|
||||
[ items
|
||||
{schema.displayFormat && <TypeFormat>{` <${schema.displayFormat}> `}</TypeFormat>}
|
||||
{schema.displayFormat && <TypeFormat> <{schema.displayFormat} ></TypeFormat>}
|
||||
<ConstraintsView constraints={schema.constraints} />
|
||||
<Pattern schema={schema} />
|
||||
{schema.items && <ArrayItemDetails schema={schema.items} />} ]
|
||||
|
|
|
@ -6,6 +6,7 @@ import {
|
|||
OneOfLabel,
|
||||
OneOfList,
|
||||
} from '../../common-elements/schema';
|
||||
import { Badge } from '../../common-elements/shelfs';
|
||||
import { SchemaModel } from '../../services/models';
|
||||
import { Schema, SchemaProps } from './Schema';
|
||||
|
||||
|
@ -20,7 +21,11 @@ export class OneOfButton extends React.Component<OneOfButtonProps> {
|
|||
render() {
|
||||
const { idx, schema, subSchema } = this.props;
|
||||
return (
|
||||
<StyledOneOfButton active={idx === schema.activeOneOf} onClick={this.activateOneOf}>
|
||||
<StyledOneOfButton
|
||||
deprecated={subSchema.deprecated}
|
||||
active={idx === schema.activeOneOf}
|
||||
onClick={this.activateOneOf}
|
||||
>
|
||||
{subSchema.title || subSchema.typePrefix + subSchema.displayType}
|
||||
</StyledOneOfButton>
|
||||
);
|
||||
|
@ -50,6 +55,9 @@ export class OneOfSchema extends React.Component<SchemaProps> {
|
|||
<OneOfButton key={subSchema.pointer} schema={schema} subSchema={subSchema} idx={idx} />
|
||||
))}
|
||||
</OneOfList>
|
||||
<div>
|
||||
{oneOf[schema.activeOneOf].deprecated && <Badge type="warning">Deprecated</Badge>}
|
||||
</div>
|
||||
<Schema {...this.props} schema={oneOf[schema.activeOneOf]} />
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -70,7 +70,7 @@ export class SecurityRequirement extends React.PureComponent<SecurityRequirement
|
|||
security.schemes.map(scheme => {
|
||||
return (
|
||||
<SecurityRequirementAndWrap key={scheme.id}>
|
||||
<Link to={scheme.sectionId}>{scheme.id}</Link>
|
||||
<Link to={scheme.sectionId}>{scheme.displayName}</Link>
|
||||
{scheme.scopes.length > 0 && ' ('}
|
||||
{scheme.scopes.map(scope => (
|
||||
<ScopeName key={scope}>{scope}</ScopeName>
|
||||
|
|
|
@ -73,7 +73,7 @@ export class SecurityDefs extends React.PureComponent<SecurityDefsProps> {
|
|||
<MiddlePanel>
|
||||
<H2>
|
||||
<ShareLink to={scheme.sectionId} />
|
||||
{scheme.id}
|
||||
{scheme.displayName}
|
||||
</H2>
|
||||
<Markdown source={scheme.description || ''} />
|
||||
<StyledMarkdownBlock>
|
||||
|
|
|
@ -56,7 +56,7 @@ const StyledStickySidebar = styled.div<{ open?: boolean }>`
|
|||
const FloatingButton = styled.div`
|
||||
outline: none;
|
||||
user-select: none;
|
||||
background-color: #f2f2f2;
|
||||
background-color: ${({ theme }) => theme.fab.backgroundColor};
|
||||
color: ${props => props.theme.colors.primary.main};
|
||||
display: none;
|
||||
cursor: pointer;
|
||||
|
@ -74,6 +74,9 @@ const FloatingButton = styled.div`
|
|||
width: 60px;
|
||||
height: 60px;
|
||||
padding: 0 20px;
|
||||
svg {
|
||||
color: ${({ theme }) => theme.fab.color};
|
||||
}
|
||||
|
||||
@media print {
|
||||
display: none;
|
||||
|
@ -140,9 +143,11 @@ export class StickyResponsiveSidebar extends React.Component<
|
|||
>
|
||||
{this.props.children}
|
||||
</StyledStickySidebar>
|
||||
<FloatingButton onClick={this.toggleNavMenu}>
|
||||
<AnimatedChevronButton open={open} />
|
||||
</FloatingButton>
|
||||
{!this.context.hideFab && (
|
||||
<FloatingButton onClick={this.toggleNavMenu}>
|
||||
<AnimatedChevronButton open={open} />
|
||||
</FloatingButton>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -6,18 +6,19 @@ import * as React from 'react';
|
|||
import { OneOfSchema, Schema } from '../';
|
||||
import { OpenAPIParser, SchemaModel } from '../../services';
|
||||
import { RedocNormalizedOptions } from '../../services/RedocNormalizedOptions';
|
||||
import { withTheme } from '../testProviders';
|
||||
|
||||
const options = new RedocNormalizedOptions({});
|
||||
describe('Components', () => {
|
||||
describe('SchemaView', () => {
|
||||
const parser = new OpenAPIParser(
|
||||
{ openapi: '3.0', info: { title: 'test', version: '0' }, paths: {} },
|
||||
undefined,
|
||||
options,
|
||||
);
|
||||
|
||||
describe('OneOf', () => {
|
||||
it('should pass down skipReadOnly/skipReadWrite to nested oneOf', () => {
|
||||
const parser = new OpenAPIParser(
|
||||
{ openapi: '3.0', info: { title: 'test', version: '0' }, paths: {} },
|
||||
undefined,
|
||||
options,
|
||||
);
|
||||
|
||||
const schema = new SchemaModel(
|
||||
parser,
|
||||
{ oneOf: [{ type: 'string' }, { type: 'integer' }] },
|
||||
|
@ -38,5 +39,19 @@ describe('Components', () => {
|
|||
expect(schemaViewElement.props.skipReadOnly).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('OneOf deprecated', () => {
|
||||
const schema = new SchemaModel(
|
||||
parser,
|
||||
{ oneOf: [{ type: 'string', deprecated: true }, { type: 'integer' }] },
|
||||
'',
|
||||
options,
|
||||
);
|
||||
|
||||
it('should match snapshot', () => {
|
||||
const component = shallow(withTheme(<Schema schema={schema} />));
|
||||
expect(component.render()).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -80,6 +80,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
|||
"expandSingleSchemaField": false,
|
||||
"generatedPayloadSamplesMaxDepth": 10,
|
||||
"hideDownloadButton": false,
|
||||
"hideFab": false,
|
||||
"hideHostname": false,
|
||||
"hideSchemaPattern": false,
|
||||
"hideSchemaTitles": false,
|
||||
|
@ -187,6 +188,10 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
|||
},
|
||||
},
|
||||
"extensionsHook": undefined,
|
||||
"fab": Object {
|
||||
"backgroundColor": "#f2f2f2",
|
||||
"color": "#0065FB",
|
||||
},
|
||||
"logo": Object {
|
||||
"gutter": "2px",
|
||||
"maxHeight": "260px",
|
||||
|
@ -321,6 +326,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
|||
"expandSingleSchemaField": false,
|
||||
"generatedPayloadSamplesMaxDepth": 10,
|
||||
"hideDownloadButton": false,
|
||||
"hideFab": false,
|
||||
"hideHostname": false,
|
||||
"hideSchemaPattern": false,
|
||||
"hideSchemaTitles": false,
|
||||
|
@ -428,6 +434,10 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
|||
},
|
||||
},
|
||||
"extensionsHook": undefined,
|
||||
"fab": Object {
|
||||
"backgroundColor": "#f2f2f2",
|
||||
"color": "#0065FB",
|
||||
},
|
||||
"logo": Object {
|
||||
"gutter": "2px",
|
||||
"maxHeight": "260px",
|
||||
|
@ -538,6 +548,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
|||
"expandSingleSchemaField": false,
|
||||
"generatedPayloadSamplesMaxDepth": 10,
|
||||
"hideDownloadButton": false,
|
||||
"hideFab": false,
|
||||
"hideHostname": false,
|
||||
"hideSchemaPattern": false,
|
||||
"hideSchemaTitles": false,
|
||||
|
@ -645,6 +656,10 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
|||
},
|
||||
},
|
||||
"extensionsHook": undefined,
|
||||
"fab": Object {
|
||||
"backgroundColor": "#f2f2f2",
|
||||
"color": "#0065FB",
|
||||
},
|
||||
"logo": Object {
|
||||
"gutter": "2px",
|
||||
"maxHeight": "260px",
|
||||
|
@ -820,6 +835,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
|||
"expandSingleSchemaField": false,
|
||||
"generatedPayloadSamplesMaxDepth": 10,
|
||||
"hideDownloadButton": false,
|
||||
"hideFab": false,
|
||||
"hideHostname": false,
|
||||
"hideSchemaPattern": false,
|
||||
"hideSchemaTitles": false,
|
||||
|
@ -927,6 +943,10 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
|||
},
|
||||
},
|
||||
"extensionsHook": undefined,
|
||||
"fab": Object {
|
||||
"backgroundColor": "#f2f2f2",
|
||||
"color": "#0065FB",
|
||||
},
|
||||
"logo": Object {
|
||||
"gutter": "2px",
|
||||
"maxHeight": "260px",
|
||||
|
@ -1061,6 +1081,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
|||
"expandSingleSchemaField": false,
|
||||
"generatedPayloadSamplesMaxDepth": 10,
|
||||
"hideDownloadButton": false,
|
||||
"hideFab": false,
|
||||
"hideHostname": false,
|
||||
"hideSchemaPattern": false,
|
||||
"hideSchemaTitles": false,
|
||||
|
@ -1168,6 +1189,10 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
|||
},
|
||||
},
|
||||
"extensionsHook": undefined,
|
||||
"fab": Object {
|
||||
"backgroundColor": "#f2f2f2",
|
||||
"color": "#0065FB",
|
||||
},
|
||||
"logo": Object {
|
||||
"gutter": "2px",
|
||||
"maxHeight": "260px",
|
||||
|
@ -1278,6 +1303,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
|||
"expandSingleSchemaField": false,
|
||||
"generatedPayloadSamplesMaxDepth": 10,
|
||||
"hideDownloadButton": false,
|
||||
"hideFab": false,
|
||||
"hideHostname": false,
|
||||
"hideSchemaPattern": false,
|
||||
"hideSchemaTitles": false,
|
||||
|
@ -1385,6 +1411,10 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
|||
},
|
||||
},
|
||||
"extensionsHook": undefined,
|
||||
"fab": Object {
|
||||
"backgroundColor": "#f2f2f2",
|
||||
"color": "#0065FB",
|
||||
},
|
||||
"logo": Object {
|
||||
"gutter": "2px",
|
||||
"maxHeight": "260px",
|
||||
|
@ -1518,6 +1548,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
|||
"expandSingleSchemaField": false,
|
||||
"generatedPayloadSamplesMaxDepth": 10,
|
||||
"hideDownloadButton": false,
|
||||
"hideFab": false,
|
||||
"hideHostname": false,
|
||||
"hideSchemaPattern": false,
|
||||
"hideSchemaTitles": false,
|
||||
|
@ -1625,6 +1656,10 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
|||
},
|
||||
},
|
||||
"extensionsHook": undefined,
|
||||
"fab": Object {
|
||||
"backgroundColor": "#f2f2f2",
|
||||
"color": "#0065FB",
|
||||
},
|
||||
"logo": Object {
|
||||
"gutter": "2px",
|
||||
"maxHeight": "260px",
|
||||
|
@ -1797,6 +1832,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
|||
"expandSingleSchemaField": false,
|
||||
"generatedPayloadSamplesMaxDepth": 10,
|
||||
"hideDownloadButton": false,
|
||||
"hideFab": false,
|
||||
"hideHostname": false,
|
||||
"hideSchemaPattern": false,
|
||||
"hideSchemaTitles": false,
|
||||
|
@ -1904,6 +1940,10 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
|||
},
|
||||
},
|
||||
"extensionsHook": undefined,
|
||||
"fab": Object {
|
||||
"backgroundColor": "#f2f2f2",
|
||||
"color": "#0065FB",
|
||||
},
|
||||
"logo": Object {
|
||||
"gutter": "2px",
|
||||
"maxHeight": "260px",
|
||||
|
@ -2038,6 +2078,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
|||
"expandSingleSchemaField": false,
|
||||
"generatedPayloadSamplesMaxDepth": 10,
|
||||
"hideDownloadButton": false,
|
||||
"hideFab": false,
|
||||
"hideHostname": false,
|
||||
"hideSchemaPattern": false,
|
||||
"hideSchemaTitles": false,
|
||||
|
@ -2145,6 +2186,10 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
|||
},
|
||||
},
|
||||
"extensionsHook": undefined,
|
||||
"fab": Object {
|
||||
"backgroundColor": "#f2f2f2",
|
||||
"color": "#0065FB",
|
||||
},
|
||||
"logo": Object {
|
||||
"gutter": "2px",
|
||||
"maxHeight": "260px",
|
||||
|
@ -2255,6 +2300,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
|||
"expandSingleSchemaField": false,
|
||||
"generatedPayloadSamplesMaxDepth": 10,
|
||||
"hideDownloadButton": false,
|
||||
"hideFab": false,
|
||||
"hideHostname": false,
|
||||
"hideSchemaPattern": false,
|
||||
"hideSchemaTitles": false,
|
||||
|
@ -2362,6 +2408,10 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
|||
},
|
||||
},
|
||||
"extensionsHook": undefined,
|
||||
"fab": Object {
|
||||
"backgroundColor": "#f2f2f2",
|
||||
"color": "#0065FB",
|
||||
},
|
||||
"logo": Object {
|
||||
"gutter": "2px",
|
||||
"maxHeight": "260px",
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Components SchemaView OneOf deprecated should match snapshot 1`] = `
|
||||
<div>
|
||||
<span
|
||||
class="sc-kfYoZR juYXUf"
|
||||
>
|
||||
One of
|
||||
</span>
|
||||
<div
|
||||
class="sc-dlMDgC EoFth"
|
||||
>
|
||||
<button
|
||||
class="sc-fKgJPI iEPbLk"
|
||||
>
|
||||
string
|
||||
</button>
|
||||
<button
|
||||
class="sc-fKgJPI bpjiHN"
|
||||
>
|
||||
integer
|
||||
</button>
|
||||
</div>
|
||||
<div>
|
||||
<span
|
||||
class="sc-bqGGPW eSYQnm"
|
||||
type="warning"
|
||||
>
|
||||
Deprecated
|
||||
</span>
|
||||
</div>
|
||||
<div>
|
||||
<div>
|
||||
<div>
|
||||
<span
|
||||
class="sc-fbIWvP sc-FRrlG CMpTe bBFKjV"
|
||||
/>
|
||||
<span
|
||||
class="sc-fbIWvP sc-fXazdy CMpTe gJKPGC"
|
||||
>
|
||||
string
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div
|
||||
class="sc-iBzEeX sc-cOifOu dFWqin hjSJYo"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
|
@ -1,11 +1,11 @@
|
|||
import * as React from 'react';
|
||||
import { ThemeProvider } from 'styled-components';
|
||||
import defaultTheme from '../theme';
|
||||
import defaultTheme, { resolveTheme } from '../theme';
|
||||
|
||||
export default class TestThemeProvider extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<ThemeProvider theme={defaultTheme}>
|
||||
<ThemeProvider theme={resolveTheme(defaultTheme)}>
|
||||
{React.Children.only(this.props.children as any)}
|
||||
</ThemeProvider>
|
||||
);
|
||||
|
|
|
@ -152,7 +152,7 @@ export class MenuStore {
|
|||
} else {
|
||||
if (id.startsWith(SECURITY_SCHEMES_SECTION_PREFIX)) {
|
||||
item = this.flatItems.find(i => SECURITY_SCHEMES_SECTION_PREFIX.startsWith(i.id));
|
||||
this.activate(item);
|
||||
this.activateAndScroll(item, false);
|
||||
}
|
||||
this.scroll.scrollIntoViewBySelector(`[${SECTION_ATTR}="${id}"]`);
|
||||
}
|
||||
|
|
|
@ -191,6 +191,9 @@ export class OpenAPIParser {
|
|||
const { $ref, ...rest } = ref;
|
||||
const keys = Object.keys(rest);
|
||||
if (keys.length === 0) {
|
||||
if (this.isRef(resolved)) {
|
||||
return this.shallowDeref(resolved);
|
||||
}
|
||||
return resolved;
|
||||
}
|
||||
if (
|
||||
|
|
|
@ -54,6 +54,7 @@ export interface RedocRawOptions {
|
|||
ignoreNamedSchemas?: string[] | string;
|
||||
hideSchemaPattern?: boolean;
|
||||
generatedPayloadSamplesMaxDepth?: number;
|
||||
hideFab?: boolean;
|
||||
}
|
||||
|
||||
export function argValueToBoolean(val?: string | boolean, defaultValue?: boolean): boolean {
|
||||
|
@ -255,6 +256,7 @@ export class RedocNormalizedOptions {
|
|||
ignoreNamedSchemas: Set<string>;
|
||||
hideSchemaPattern: boolean;
|
||||
generatedPayloadSamplesMaxDepth: number;
|
||||
hideFab: boolean;
|
||||
|
||||
constructor(raw: RedocRawOptions, defaults: RedocRawOptions = {}) {
|
||||
raw = { ...defaults, ...raw };
|
||||
|
@ -326,5 +328,6 @@ export class RedocNormalizedOptions {
|
|||
RedocNormalizedOptions.normalizeGeneratedPayloadSamplesMaxDepth(
|
||||
raw.generatedPayloadSamplesMaxDepth,
|
||||
);
|
||||
this.hideFab = argValueToBoolean(raw.hideFab);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,5 +26,16 @@ describe('Models', () => {
|
|||
|
||||
expect(parser.shallowDeref(schemaOrRef)).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('should correct resolve double $ref if no need sibling', () => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const spec = require('./fixtures/3.1/schemaDefinition.json');
|
||||
parser = new OpenAPIParser(spec, undefined, opts);
|
||||
const schemaOrRef: Referenced<OpenAPIParameter> = {
|
||||
$ref: '#/components/schemas/Parent',
|
||||
};
|
||||
|
||||
expect(parser.deref(schemaOrRef, false, true)).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,5 +1,16 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Models Schema should correct resolve double $ref if no need sibling 1`] = `
|
||||
Object {
|
||||
"properties": Object {
|
||||
"test": Object {
|
||||
"type": "string",
|
||||
},
|
||||
},
|
||||
"type": "object",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Models Schema should hoist oneOfs when mergin allOf 1`] = `
|
||||
Object {
|
||||
"oneOf": Array [
|
||||
|
|
54
src/services/__tests__/fixtures/3.1/schemaDefinition.json
Normal file
54
src/services/__tests__/fixtures/3.1/schemaDefinition.json
Normal file
|
@ -0,0 +1,54 @@
|
|||
{
|
||||
"openapi": "3.1.0",
|
||||
"info": {
|
||||
"title": "Schema definition double $ref",
|
||||
"version": "1.0.0"
|
||||
},
|
||||
"servers": [
|
||||
{
|
||||
"url": "example.com"
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
{
|
||||
"name": "test",
|
||||
"x-displayName": "The test Model",
|
||||
"description": "<SchemaDefinition schemaRef=\"#/components/schemas/Parent\" />\n"
|
||||
}
|
||||
],
|
||||
"paths": {
|
||||
"/newPath": {
|
||||
"post": {
|
||||
"requestBody": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Child"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "all ok"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"Parent": {
|
||||
"$ref": "#/components/schemas/Child"
|
||||
},
|
||||
"Child": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"test": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -40,5 +40,13 @@ describe('Models', () => {
|
|||
expect(schema.oneOf).toHaveLength(2);
|
||||
expect(schema.displayType).toBe('(Array of strings or numbers) or string');
|
||||
});
|
||||
|
||||
test('schemaDefinition should resolve double ref', () => {
|
||||
const spec = require('../fixtures/3.1/schemaDefinition.json');
|
||||
parser = new OpenAPIParser(spec, undefined, opts);
|
||||
const schema = new SchemaModel(parser, spec.components.schemas.Parent, '', opts);
|
||||
expect(schema.fields).toHaveLength(1);
|
||||
expect(schema.pointer).toBe('#/components/schemas/Child');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -5,6 +5,7 @@ import { OpenAPIParser } from '../OpenAPIParser';
|
|||
export interface SecurityScheme extends OpenAPISecurityScheme {
|
||||
id: string;
|
||||
sectionId: string;
|
||||
displayName: string;
|
||||
scopes: string[];
|
||||
}
|
||||
|
||||
|
@ -23,11 +24,13 @@ export class SecurityRequirementModel {
|
|||
console.warn(`Non existing security scheme referenced: ${id}. Skipping`);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const displayName = scheme['x-displayName'] || id;
|
||||
|
||||
return {
|
||||
...scheme,
|
||||
id,
|
||||
sectionId: SECURITY_SCHEMES_SECTION_PREFIX + id,
|
||||
displayName,
|
||||
scopes,
|
||||
};
|
||||
})
|
||||
|
|
|
@ -7,6 +7,7 @@ export class SecuritySchemeModel {
|
|||
sectionId: string;
|
||||
type: OpenAPISecurityScheme['type'];
|
||||
description: string;
|
||||
displayName: string;
|
||||
apiKey?: {
|
||||
name: string;
|
||||
in: OpenAPISecurityScheme['in'];
|
||||
|
@ -27,6 +28,7 @@ export class SecuritySchemeModel {
|
|||
this.id = id;
|
||||
this.sectionId = SECURITY_SCHEMES_SECTION_PREFIX + id;
|
||||
this.type = info.type;
|
||||
this.displayName = info['x-displayName'] || id;
|
||||
this.description = info.description || '';
|
||||
if (info.type === 'apiKey') {
|
||||
this.apiKey = {
|
||||
|
|
|
@ -162,6 +162,10 @@ const defaultTheme: ThemeInterface = {
|
|||
codeBlock: {
|
||||
backgroundColor: ({ rightPanel }) => darken(0.1, rightPanel.backgroundColor),
|
||||
},
|
||||
fab: {
|
||||
backgroundColor: '#f2f2f2',
|
||||
color: '#0065FB',
|
||||
},
|
||||
};
|
||||
|
||||
export default defaultTheme;
|
||||
|
@ -338,6 +342,10 @@ export interface ResolvedThemeInterface {
|
|||
codeBlock: {
|
||||
backgroundColor: string;
|
||||
};
|
||||
fab: {
|
||||
backgroundColor: string;
|
||||
color: string;
|
||||
};
|
||||
|
||||
extensionsHook?: (name: string, props: any) => string;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user