mirror of
https://github.com/Redocly/redoc.git
synced 2025-08-03 20:00:20 +03:00
Merge tag 'v2.0.0-rc.69' into sections-at-the-end
This commit is contained in:
commit
323252fa79
34
.github/workflows/main.yml
vendored
34
.github/workflows/main.yml
vendored
|
@ -43,3 +43,37 @@ jobs:
|
||||||
context: ./cli
|
context: ./cli
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
tags: ${{ steps.prep.outputs.tags }}
|
tags: ${{ steps.prep.outputs.tags }}
|
||||||
|
dockerhub:
|
||||||
|
name: Publish redoc image to DockerHub
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Docker meta
|
||||||
|
id: docker_meta
|
||||||
|
uses: crazy-max/ghaction-docker-meta@v1
|
||||||
|
with:
|
||||||
|
images: redocly/redoc
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v1
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
|
||||||
|
- name: Login to DockerHub
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./config/docker/Dockerfile
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.docker_meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.docker_meta.outputs.labels }}
|
||||||
|
|
2
.github/workflows/publish-cli.yml
vendored
2
.github/workflows/publish-cli.yml
vendored
|
@ -35,7 +35,7 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
- run: npm ci
|
- run: npm ci && npm ci --prefix cli
|
||||||
- run: npm test
|
- run: npm test
|
||||||
e2e-tests:
|
e2e-tests:
|
||||||
needs: [bundle]
|
needs: [bundle]
|
||||||
|
|
36
.github/workflows/publish.yml
vendored
36
.github/workflows/publish.yml
vendored
|
@ -31,7 +31,7 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
- run: npm ci
|
- run: npm ci && npm ci --prefix cli
|
||||||
- run: npm test
|
- run: npm test
|
||||||
e2e-tests:
|
e2e-tests:
|
||||||
needs: [bundle]
|
needs: [bundle]
|
||||||
|
@ -98,37 +98,3 @@ jobs:
|
||||||
run: npm publish
|
run: npm publish
|
||||||
env:
|
env:
|
||||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
dockerhub:
|
|
||||||
needs: [publish]
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Docker meta
|
|
||||||
id: docker_meta
|
|
||||||
uses: crazy-max/ghaction-docker-meta@v1
|
|
||||||
with:
|
|
||||||
images: redocly/redoc
|
|
||||||
|
|
||||||
- name: Set up QEMU
|
|
||||||
uses: docker/setup-qemu-action@v1
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v1
|
|
||||||
|
|
||||||
- name: Login to DockerHub
|
|
||||||
uses: docker/login-action@v1
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Build and push
|
|
||||||
uses: docker/build-push-action@v2
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
file: ./config/docker/Dockerfile
|
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
push: true
|
|
||||||
tags: ${{ steps.docker_meta.outputs.tags }}
|
|
||||||
labels: ${{ steps.docker_meta.outputs.labels }}
|
|
||||||
|
|
8
.github/workflows/unit-tests.yml
vendored
8
.github/workflows/unit-tests.yml
vendored
|
@ -6,7 +6,7 @@ jobs:
|
||||||
build-and-unit:
|
build-and-unit:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
- run: npm ci
|
- run: npm ci && npm ci --prefix cli
|
||||||
- run: npm run bundle
|
- run: npm run bundle
|
||||||
- run: npm test
|
- run: npm test
|
||||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -28,6 +28,7 @@ bundles/
|
||||||
typings/*
|
typings/*
|
||||||
!typings/styled-patch.d.ts
|
!typings/styled-patch.d.ts
|
||||||
cli/index.js
|
cli/index.js
|
||||||
|
cli/__test__/*/**/*.html
|
||||||
|
|
||||||
/benchmark/revisions
|
/benchmark/revisions
|
||||||
|
|
||||||
|
|
16
CHANGELOG.md
16
CHANGELOG.md
|
@ -1,3 +1,19 @@
|
||||||
|
# [2.0.0-rc.69](https://github.com/Redocly/redoc/compare/v2.0.0-rc.68.1...v2.0.0-rc.69) (2022-05-12)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* wrong base url format causing error when constructing new URL ([#1996](https://github.com/Redocly/redoc/issues/1996)) ([d2cdaa1](https://github.com/Redocly/redoc/commit/d2cdaa1221b6a5e7b5da2418414bce1586069deb))
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* add download file option ([#1699](https://github.com/Redocly/redoc/issues/1699)) ([b601c9a](https://github.com/Redocly/redoc/commit/b601c9ae9e3288286f28e06854bd93cb3507706e))
|
||||||
|
* add option to display verb in webhooks ([#1994](https://github.com/Redocly/redoc/issues/1994)) ([311d2ce](https://github.com/Redocly/redoc/commit/311d2ce64dcf1e68c2563a276b34dda0e08b709c))
|
||||||
|
* support .redocly.yaml for options for redoc-cli ([#1981](https://github.com/Redocly/redoc/issues/1981)) ([1f417d6](https://github.com/Redocly/redoc/commit/1f417d67c6b2e0b49e41c713958c100d8e1ad19d))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# [2.0.0-rc.68](https://github.com/Redocly/redoc/compare/v2.0.0-rc.67...v2.0.0-rc.68) (2022-05-10)
|
# [2.0.0-rc.68](https://github.com/Redocly/redoc/compare/v2.0.0-rc.67...v2.0.0-rc.68) (2022-05-10)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -213,6 +213,8 @@ You can use all of the following options with the standalone version of the <red
|
||||||
* `generatedPayloadSamplesMaxDepth` - set the maximum render depth for JSON payload samples (responses and request body). The default value is `10`.
|
* `generatedPayloadSamplesMaxDepth` - set the maximum render depth for JSON payload samples (responses and request body). The default value is `10`.
|
||||||
* `maxDisplayedEnumValues` - display only specified number of enum values. hide rest values under spoiler.
|
* `maxDisplayedEnumValues` - display only specified number of enum values. hide rest values under spoiler.
|
||||||
* `hideDownloadButton` - do not show "Download" spec button. **THIS DOESN'T MAKE YOUR SPEC PRIVATE**, it just hides the button.
|
* `hideDownloadButton` - do not show "Download" spec button. **THIS DOESN'T MAKE YOUR SPEC PRIVATE**, it just hides the button.
|
||||||
|
* `downloadFileName` - set a custom file name for the downloaded API definition file.
|
||||||
|
* `downloadDefinitionUrl` - If the 'Download' button is visible in the API reference documentation (hideDownloadButton=false), the URL configured here will open when that button is selected. Provide it as an absolute URL with the full URI scheme.
|
||||||
* `hideHostname` - if set, the protocol and hostname is not shown in the operation definition.
|
* `hideHostname` - if set, the protocol and hostname is not shown in the operation definition.
|
||||||
* `hideLoading` - do not show loading animation. Useful for small docs.
|
* `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.
|
* `hideFab` - do not show FAB in mobile view. Useful for implementing a custom floating action button.
|
||||||
|
@ -249,6 +251,7 @@ You can use all of the following options with the standalone version of the <red
|
||||||
* **summary-only**: displays a summary in the sidebar navigation item. (**default**)
|
* **summary-only**: displays a summary in the sidebar navigation item. (**default**)
|
||||||
* **path-only**: displays a path in the sidebar navigation item.
|
* **path-only**: displays a path in the sidebar navigation item.
|
||||||
* **id-only**: displays the operation id with a fallback to the path in the sidebar navigation item.
|
* **id-only**: displays the operation id with a fallback to the path in the sidebar navigation item.
|
||||||
|
* `showWebhookVerb` - when set to `true`, shows the HTTP request method for webhooks in operations and in the sidebar.
|
||||||
|
|
||||||
### `<redoc>` theme object
|
### `<redoc>` theme object
|
||||||
* `spacing`
|
* `spacing`
|
||||||
|
|
|
@ -31,4 +31,10 @@ Some examples:
|
||||||
- Bundle using a custom template and add custom `templateOptions`:<br/>
|
- Bundle using a custom template and add custom `templateOptions`:<br/>
|
||||||
`$ redoc-cli build [spec] -t custom.hbs --templateOptions.metaDescription "Page meta description"`
|
`$ redoc-cli build [spec] -t custom.hbs --templateOptions.metaDescription "Page meta description"`
|
||||||
|
|
||||||
|
#### With a Redocly configuration file ([more info](https://redocly.com/docs/cli/configuration/#redocly-configuration-file)):
|
||||||
|
|
||||||
|
1. Go to folder with your Redocly configuration file (`.redocly.yaml` or `redocly.yaml`) and your OpenAPI definition file.
|
||||||
|
2. Build the site using the `build` command (options from the Redocly configuration file will be automatically fetched):
|
||||||
|
`redoc build openapi.yaml`
|
||||||
|
|
||||||
For more details, run `redoc-cli --help`.
|
For more details, run `redoc-cli --help`.
|
||||||
|
|
2
cli/__test__/build/configRedoc/.redocly.yaml
Normal file
2
cli/__test__/build/configRedoc/.redocly.yaml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
features.openapi:
|
||||||
|
disableSearch: true
|
30
cli/__test__/build/configRedoc/index.test.ts
Normal file
30
cli/__test__/build/configRedoc/index.test.ts
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
import { spawnSync } from 'child_process';
|
||||||
|
import { readFileSync } from 'fs';
|
||||||
|
|
||||||
|
describe('build', () => {
|
||||||
|
it('should use .redocly.yaml', () => {
|
||||||
|
const r = spawnSync(
|
||||||
|
'ts-node',
|
||||||
|
['../../../index.ts', 'build', ' ../../../../demo/openapi.yaml', '--output=redoc-test.html'],
|
||||||
|
{
|
||||||
|
cwd: __dirname,
|
||||||
|
shell: true,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
const out = r.stdout.toString('utf-8');
|
||||||
|
const err = r.stderr.toString('utf-8');
|
||||||
|
const result = `${out}\n${err}`;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const redocStaticFile = readFileSync(`${__dirname}/redoc-test.html`, 'utf8');
|
||||||
|
expect(redocStaticFile).toContain('"options":{"disableSearch":true}');
|
||||||
|
expect(redocStaticFile).not.toContain('role="search"');
|
||||||
|
} catch (err) {
|
||||||
|
expect(err.toString()).toContain('{"options":{"disableSearch":"true"}');
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(result).toContain('Found .redocly.yaml and using features.openapi options');
|
||||||
|
expect(result).toContain('bundled successfully');
|
||||||
|
});
|
||||||
|
});
|
34
cli/__test__/build/configRedoc/inline-options.test.ts
Normal file
34
cli/__test__/build/configRedoc/inline-options.test.ts
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
import { spawnSync } from 'child_process';
|
||||||
|
import { readFileSync } from 'fs';
|
||||||
|
|
||||||
|
describe('build with inline options', () => {
|
||||||
|
it('should use inline options and ignore .redocly.yaml', () => {
|
||||||
|
const r = spawnSync(
|
||||||
|
'ts-node',
|
||||||
|
[
|
||||||
|
'../../../index.ts',
|
||||||
|
'build',
|
||||||
|
' ../../../../demo/openapi.yaml',
|
||||||
|
'--options.disableSearch="false" ',
|
||||||
|
],
|
||||||
|
{
|
||||||
|
cwd: __dirname,
|
||||||
|
shell: true,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
const out = r.stdout.toString('utf-8');
|
||||||
|
const err = r.stderr.toString('utf-8');
|
||||||
|
const result = `${out}\n${err}`;
|
||||||
|
expect(result).not.toContain('Found .redocly.yaml and using features.openapi options');
|
||||||
|
expect(result).toContain('bundled successfully');
|
||||||
|
|
||||||
|
try {
|
||||||
|
const redocStaticFile = readFileSync(`${__dirname}/redoc-static.html`, 'utf8');
|
||||||
|
expect(redocStaticFile).toContain('"options":{"disableSearch":"false"}');
|
||||||
|
expect(redocStaticFile).toContain('role="search"');
|
||||||
|
} catch (err) {
|
||||||
|
expect(err.toString()).toContain('"options":{"disableSearch":"false"}');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
25
cli/__test__/build/configRedoc/url.test.ts
Normal file
25
cli/__test__/build/configRedoc/url.test.ts
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
import { spawnSync } from 'child_process';
|
||||||
|
|
||||||
|
describe('build with url', () => {
|
||||||
|
// FIXME: remove skip after release
|
||||||
|
it.skip('should not fail on resolving url', () => {
|
||||||
|
const r = spawnSync(
|
||||||
|
'ts-node',
|
||||||
|
[
|
||||||
|
'../../../index.ts',
|
||||||
|
'build',
|
||||||
|
'http://petstore.swagger.io/v2/swagger.json',
|
||||||
|
'--output=url-test.html',
|
||||||
|
],
|
||||||
|
{
|
||||||
|
cwd: __dirname,
|
||||||
|
shell: true,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
const out = r.stdout.toString('utf-8');
|
||||||
|
const err = r.stderr.toString('utf-8');
|
||||||
|
const result = `${out}\n${err}`;
|
||||||
|
expect(result).toContain('bundled successfully');
|
||||||
|
});
|
||||||
|
});
|
17
cli/index.ts
17
cli/index.ts
|
@ -25,6 +25,12 @@ import {
|
||||||
import * as mkdirp from 'mkdirp';
|
import * as mkdirp from 'mkdirp';
|
||||||
|
|
||||||
import * as YargsParser from 'yargs';
|
import * as YargsParser from 'yargs';
|
||||||
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||||
|
import { findConfig } from '@redocly/openapi-core';
|
||||||
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||||
|
import { parseYaml } from '@redocly/openapi-core';
|
||||||
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||||
|
import { Config } from '@redocly/openapi-core';
|
||||||
|
|
||||||
interface Options {
|
interface Options {
|
||||||
ssr?: boolean;
|
ssr?: boolean;
|
||||||
|
@ -447,6 +453,17 @@ function getObjectOrJSON(options) {
|
||||||
handleError(e);
|
handleError(e);
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
const configFile = findConfig();
|
||||||
|
if (configFile) {
|
||||||
|
console.log(`Found ${configFile} and using features.openapi options`);
|
||||||
|
try {
|
||||||
|
const config = parseYaml(readFileSync(configFile, 'utf-8')) as Config;
|
||||||
|
|
||||||
|
return config['features.openapi'];
|
||||||
|
} catch (e) {
|
||||||
|
console.warn(`Found ${configFile} but failed to parse: ${e.message}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
80
cli/npm-shrinkwrap.json
generated
80
cli/npm-shrinkwrap.json
generated
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "redoc-cli",
|
"name": "redoc-cli",
|
||||||
"version": "0.13.11",
|
"version": "0.13.12",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "redoc-cli",
|
"name": "redoc-cli",
|
||||||
"version": "0.13.11",
|
"version": "0.13.12",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"chokidar": "^3.5.1",
|
"chokidar": "^3.5.1",
|
||||||
|
@ -17,7 +17,7 @@
|
||||||
"node-libs-browser": "^2.2.1",
|
"node-libs-browser": "^2.2.1",
|
||||||
"react": "^17.0.1",
|
"react": "^17.0.1",
|
||||||
"react-dom": "^17.0.1",
|
"react-dom": "^17.0.1",
|
||||||
"redoc": "2.0.0-rc.67",
|
"redoc": "2.0.0-rc.68",
|
||||||
"styled-components": "^5.3.0",
|
"styled-components": "^5.3.0",
|
||||||
"yargs": "^17.3.1"
|
"yargs": "^17.3.1"
|
||||||
},
|
},
|
||||||
|
@ -216,9 +216,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@redocly/openapi-core": {
|
"node_modules/@redocly/openapi-core": {
|
||||||
"version": "1.0.0-beta.91",
|
"version": "1.0.0-beta.96",
|
||||||
"resolved": "https://registry.npmjs.org/@redocly/openapi-core/-/openapi-core-1.0.0-beta.91.tgz",
|
"resolved": "https://registry.npmjs.org/@redocly/openapi-core/-/openapi-core-1.0.0-beta.96.tgz",
|
||||||
"integrity": "sha512-8RhZGn5jSoy3oZE0sAdXxhPPHrqKgy2JVJzLqjgX9LDjNf7cXOTYOXkXIkjv1tfZHFBV/H7c08rRLEdxnzn0dg==",
|
"integrity": "sha512-tcy0q+9PRWV4rcnVx5uHII/9Cq9qpUzWNppupAaVgutxjQRPWH45e24NLinn6lA8Q4por6HuMYkk/0QAJE8d3A==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@redocly/ajv": "^8.6.4",
|
"@redocly/ajv": "^8.6.4",
|
||||||
"@types/node": "^14.11.8",
|
"@types/node": "^14.11.8",
|
||||||
|
@ -236,19 +236,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@redocly/openapi-core/node_modules/@types/node": {
|
"node_modules/@redocly/openapi-core/node_modules/@types/node": {
|
||||||
"version": "14.18.12",
|
"version": "14.18.16",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.12.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.16.tgz",
|
||||||
"integrity": "sha512-q4jlIR71hUpWTnGhXWcakgkZeHa3CCjcQcnuzU8M891BAWA2jHiziiWEPEkdS5pFsz7H9HJiy8BrK7tBRNrY7A=="
|
"integrity": "sha512-X3bUMdK/VmvrWdoTkz+VCn6nwKwrKCFTHtqwBIaQJNx4RUIBBUFXM00bqPz/DsDd+Icjmzm6/tyYZzeGVqb6/Q=="
|
||||||
},
|
|
||||||
"node_modules/@redocly/react-dropdown-aria": {
|
|
||||||
"version": "2.0.12",
|
|
||||||
"resolved": "https://registry.npmjs.org/@redocly/react-dropdown-aria/-/react-dropdown-aria-2.0.12.tgz",
|
|
||||||
"integrity": "sha512-feQEZlyBvQsbT/fvpJ4jJ5OLGaUPpnskHYDsY8DGpPymN+HUeDQrqkBEbbKRwMKidFTI2cxk2kJNNTnvdS9jyw==",
|
|
||||||
"peerDependencies": {
|
|
||||||
"react": "^16.8.4 || ^17.0.0",
|
|
||||||
"react-dom": "^16.8.4 || ^17.0.0",
|
|
||||||
"styled-components": "^5.1.1"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"node_modules/@types/chokidar": {
|
"node_modules/@types/chokidar": {
|
||||||
"version": "2.1.3",
|
"version": "2.1.3",
|
||||||
|
@ -1621,9 +1611,9 @@
|
||||||
"integrity": "sha1-GA8fnr74sOY45BZq1S24eb6y/8U="
|
"integrity": "sha1-GA8fnr74sOY45BZq1S24eb6y/8U="
|
||||||
},
|
},
|
||||||
"node_modules/marked": {
|
"node_modules/marked": {
|
||||||
"version": "4.0.12",
|
"version": "4.0.15",
|
||||||
"resolved": "https://registry.npmjs.org/marked/-/marked-4.0.12.tgz",
|
"resolved": "https://registry.npmjs.org/marked/-/marked-4.0.15.tgz",
|
||||||
"integrity": "sha512-hgibXWrEDNBWgGiK18j/4lkS6ihTe9sxtV4Q1OQppb/0zzyPSzoFANBa5MfsG/zgsWklmNnhm0XACZOH/0HBiQ==",
|
"integrity": "sha512-esX5lPdTfG4p8LDkv+obbRCyOKzB+820ZZyMOXJZygZBHrH9b3xXR64X4kT3sPe9Nx8qQXbmcz6kFSMt4Nfk6Q==",
|
||||||
"bin": {
|
"bin": {
|
||||||
"marked": "bin/marked.js"
|
"marked": "bin/marked.js"
|
||||||
},
|
},
|
||||||
|
@ -2217,12 +2207,11 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/redoc": {
|
"node_modules/redoc": {
|
||||||
"version": "2.0.0-rc.67",
|
"version": "2.0.0-rc.68",
|
||||||
"resolved": "https://registry.npmjs.org/redoc/-/redoc-2.0.0-rc.67.tgz",
|
"resolved": "https://registry.npmjs.org/redoc/-/redoc-2.0.0-rc.68.tgz",
|
||||||
"integrity": "sha512-u6rEKB0LylSisN+mFa3flj7zf+prXDB+G02foqC9BOlcXkUYXHFDZM4L3BTBL/DstyGTgjhe2dA9csAjIVti/g==",
|
"integrity": "sha512-sCz52OEhLDu2cIBimy4f6CaVoDxUzD16x63oZx4kpDQOTXYtk0hEOlph1s5VrgNg9pg+rJ9LCCfnwCuzx3Be8w==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@redocly/openapi-core": "^1.0.0-beta.88",
|
"@redocly/openapi-core": "^1.0.0-beta.95",
|
||||||
"@redocly/react-dropdown-aria": "^2.0.11",
|
|
||||||
"classnames": "^2.3.1",
|
"classnames": "^2.3.1",
|
||||||
"decko": "^1.2.0",
|
"decko": "^1.2.0",
|
||||||
"dompurify": "^2.2.8",
|
"dompurify": "^2.2.8",
|
||||||
|
@ -2230,7 +2219,7 @@
|
||||||
"json-pointer": "^0.6.2",
|
"json-pointer": "^0.6.2",
|
||||||
"lunr": "^2.3.9",
|
"lunr": "^2.3.9",
|
||||||
"mark.js": "^8.11.1",
|
"mark.js": "^8.11.1",
|
||||||
"marked": "^4.0.10",
|
"marked": "^4.0.15",
|
||||||
"mobx-react": "^7.2.0",
|
"mobx-react": "^7.2.0",
|
||||||
"openapi-sampler": "^1.2.1",
|
"openapi-sampler": "^1.2.1",
|
||||||
"path-browserify": "^1.0.1",
|
"path-browserify": "^1.0.1",
|
||||||
|
@ -3146,9 +3135,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@redocly/openapi-core": {
|
"@redocly/openapi-core": {
|
||||||
"version": "1.0.0-beta.91",
|
"version": "1.0.0-beta.96",
|
||||||
"resolved": "https://registry.npmjs.org/@redocly/openapi-core/-/openapi-core-1.0.0-beta.91.tgz",
|
"resolved": "https://registry.npmjs.org/@redocly/openapi-core/-/openapi-core-1.0.0-beta.96.tgz",
|
||||||
"integrity": "sha512-8RhZGn5jSoy3oZE0sAdXxhPPHrqKgy2JVJzLqjgX9LDjNf7cXOTYOXkXIkjv1tfZHFBV/H7c08rRLEdxnzn0dg==",
|
"integrity": "sha512-tcy0q+9PRWV4rcnVx5uHII/9Cq9qpUzWNppupAaVgutxjQRPWH45e24NLinn6lA8Q4por6HuMYkk/0QAJE8d3A==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@redocly/ajv": "^8.6.4",
|
"@redocly/ajv": "^8.6.4",
|
||||||
"@types/node": "^14.11.8",
|
"@types/node": "^14.11.8",
|
||||||
|
@ -3163,18 +3152,12 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/node": {
|
"@types/node": {
|
||||||
"version": "14.18.12",
|
"version": "14.18.16",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.12.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.16.tgz",
|
||||||
"integrity": "sha512-q4jlIR71hUpWTnGhXWcakgkZeHa3CCjcQcnuzU8M891BAWA2jHiziiWEPEkdS5pFsz7H9HJiy8BrK7tBRNrY7A=="
|
"integrity": "sha512-X3bUMdK/VmvrWdoTkz+VCn6nwKwrKCFTHtqwBIaQJNx4RUIBBUFXM00bqPz/DsDd+Icjmzm6/tyYZzeGVqb6/Q=="
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@redocly/react-dropdown-aria": {
|
|
||||||
"version": "2.0.12",
|
|
||||||
"resolved": "https://registry.npmjs.org/@redocly/react-dropdown-aria/-/react-dropdown-aria-2.0.12.tgz",
|
|
||||||
"integrity": "sha512-feQEZlyBvQsbT/fvpJ4jJ5OLGaUPpnskHYDsY8DGpPymN+HUeDQrqkBEbbKRwMKidFTI2cxk2kJNNTnvdS9jyw==",
|
|
||||||
"requires": {}
|
|
||||||
},
|
|
||||||
"@types/chokidar": {
|
"@types/chokidar": {
|
||||||
"version": "2.1.3",
|
"version": "2.1.3",
|
||||||
"resolved": "https://registry.npmjs.org/@types/chokidar/-/chokidar-2.1.3.tgz",
|
"resolved": "https://registry.npmjs.org/@types/chokidar/-/chokidar-2.1.3.tgz",
|
||||||
|
@ -4351,9 +4334,9 @@
|
||||||
"integrity": "sha1-GA8fnr74sOY45BZq1S24eb6y/8U="
|
"integrity": "sha1-GA8fnr74sOY45BZq1S24eb6y/8U="
|
||||||
},
|
},
|
||||||
"marked": {
|
"marked": {
|
||||||
"version": "4.0.12",
|
"version": "4.0.15",
|
||||||
"resolved": "https://registry.npmjs.org/marked/-/marked-4.0.12.tgz",
|
"resolved": "https://registry.npmjs.org/marked/-/marked-4.0.15.tgz",
|
||||||
"integrity": "sha512-hgibXWrEDNBWgGiK18j/4lkS6ihTe9sxtV4Q1OQppb/0zzyPSzoFANBa5MfsG/zgsWklmNnhm0XACZOH/0HBiQ=="
|
"integrity": "sha512-esX5lPdTfG4p8LDkv+obbRCyOKzB+820ZZyMOXJZygZBHrH9b3xXR64X4kT3sPe9Nx8qQXbmcz6kFSMt4Nfk6Q=="
|
||||||
},
|
},
|
||||||
"md5.js": {
|
"md5.js": {
|
||||||
"version": "1.3.5",
|
"version": "1.3.5",
|
||||||
|
@ -4822,12 +4805,11 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"redoc": {
|
"redoc": {
|
||||||
"version": "2.0.0-rc.67",
|
"version": "2.0.0-rc.68",
|
||||||
"resolved": "https://registry.npmjs.org/redoc/-/redoc-2.0.0-rc.67.tgz",
|
"resolved": "https://registry.npmjs.org/redoc/-/redoc-2.0.0-rc.68.tgz",
|
||||||
"integrity": "sha512-u6rEKB0LylSisN+mFa3flj7zf+prXDB+G02foqC9BOlcXkUYXHFDZM4L3BTBL/DstyGTgjhe2dA9csAjIVti/g==",
|
"integrity": "sha512-sCz52OEhLDu2cIBimy4f6CaVoDxUzD16x63oZx4kpDQOTXYtk0hEOlph1s5VrgNg9pg+rJ9LCCfnwCuzx3Be8w==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@redocly/openapi-core": "^1.0.0-beta.88",
|
"@redocly/openapi-core": "^1.0.0-beta.95",
|
||||||
"@redocly/react-dropdown-aria": "^2.0.11",
|
|
||||||
"classnames": "^2.3.1",
|
"classnames": "^2.3.1",
|
||||||
"decko": "^1.2.0",
|
"decko": "^1.2.0",
|
||||||
"dompurify": "^2.2.8",
|
"dompurify": "^2.2.8",
|
||||||
|
@ -4835,7 +4817,7 @@
|
||||||
"json-pointer": "^0.6.2",
|
"json-pointer": "^0.6.2",
|
||||||
"lunr": "^2.3.9",
|
"lunr": "^2.3.9",
|
||||||
"mark.js": "^8.11.1",
|
"mark.js": "^8.11.1",
|
||||||
"marked": "^4.0.10",
|
"marked": "^4.0.15",
|
||||||
"mobx-react": "^7.2.0",
|
"mobx-react": "^7.2.0",
|
||||||
"openapi-sampler": "^1.2.1",
|
"openapi-sampler": "^1.2.1",
|
||||||
"path-browserify": "^1.0.1",
|
"path-browserify": "^1.0.1",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "redoc-cli",
|
"name": "redoc-cli",
|
||||||
"version": "0.13.11",
|
"version": "0.13.12",
|
||||||
"description": "ReDoc's Command Line Interface",
|
"description": "ReDoc's Command Line Interface",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"bin": "index.js",
|
"bin": "index.js",
|
||||||
|
@ -19,7 +19,7 @@
|
||||||
"node-libs-browser": "^2.2.1",
|
"node-libs-browser": "^2.2.1",
|
||||||
"react": "^17.0.1",
|
"react": "^17.0.1",
|
||||||
"react-dom": "^17.0.1",
|
"react-dom": "^17.0.1",
|
||||||
"redoc": "2.0.0-rc.67",
|
"redoc": "2.0.0-rc.68",
|
||||||
"styled-components": "^5.3.0",
|
"styled-components": "^5.3.0",
|
||||||
"yargs": "^17.3.1"
|
"yargs": "^17.3.1"
|
||||||
},
|
},
|
||||||
|
|
|
@ -12,7 +12,7 @@ RUN apk update && apk add --no-cache git
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
WORKDIR /build
|
WORKDIR /build
|
||||||
COPY package.json package-lock.json /build/
|
COPY package.json package-lock.json /build/
|
||||||
RUN npm ci --no-optional --ignore-scripts
|
RUN npm ci --no-optional --ignore-scripts --force
|
||||||
|
|
||||||
# copy only required for the build files
|
# copy only required for the build files
|
||||||
COPY src /build/src
|
COPY src /build/src
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
title: Use the Redoc CLI
|
title: Use the Redoc CLI
|
||||||
redirectFrom:
|
redirectFrom:
|
||||||
- /docs/quickstart/cli/
|
- /docs/redoc/quickstart/cli/
|
||||||
---
|
---
|
||||||
|
|
||||||
# How to use the Redoc CLI
|
# How to use the Redoc CLI
|
||||||
|
@ -56,7 +56,7 @@ The CLI includes the following commands:
|
||||||
- `--watch`: Automatically reloads the server while you edit your OpenAPI definition.
|
- `--watch`: Automatically reloads the server while you edit your OpenAPI definition.
|
||||||
- `--options`: Customizes your output using [Redoc options](https://redocly.com/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.
|
To add nested options, use dot notation.
|
||||||
- **`redoc-cli bundle [spec]`:** Bundles `spec` and Redoc into a zero-dependency HTML file. Options include:
|
- **`redoc-cli build [spec]`:** Builds `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.
|
- `-t` or `--template`: Uses custom [Handlebars](https://handlebarsjs.com/) templates to render your OpenAPI definition.
|
||||||
- `--templateOptions`: Adds template options you want to pass to your
|
- `--templateOptions`: Adds template options you want to pass to your
|
||||||
custom Handlebars template. To add options, use dot notation.
|
custom Handlebars template. To add options, use dot notation.
|
||||||
|
@ -70,13 +70,13 @@ The CLI includes the following commands:
|
||||||
Bundle with the main color changed to `orange`:
|
Bundle with the main color changed to `orange`:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
redoc-cli bundle openapi.yaml --options.theme.colors.primary.main=orange
|
redoc-cli build openapi.yaml --options.theme.colors.primary.main=orange
|
||||||
```
|
```
|
||||||
|
|
||||||
Bundle using a custom Handlebars template and add custom `templateOptions`:
|
Bundle using a custom Handlebars template and add custom `templateOptions`:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
redoc-cli bundle http://petstore.swagger.io/v2/swagger.json -t custom.hbs --templateOptions.metaDescription "Page meta description"
|
redoc-cli build http://petstore.swagger.io/v2/swagger.json -t custom.hbs --templateOptions.metaDescription "Page meta description"
|
||||||
```
|
```
|
||||||
|
|
||||||
Sample Handlebars template:
|
Sample Handlebars template:
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
title: Use the Redoc Docker image
|
title: Use the Redoc Docker image
|
||||||
redirectFrom:
|
redirectFrom:
|
||||||
- /docs/quickstart/docker/
|
- /docs/redoc/quickstart/docker/
|
||||||
---
|
---
|
||||||
|
|
||||||
# How to use the Redoc Docker image
|
# How to use the Redoc Docker image
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
title: Use the Redoc HTML element
|
title: Use the Redoc HTML element
|
||||||
redirectFrom:
|
redirectFrom:
|
||||||
- /docs/quickstart/html/
|
- /docs/redoc/quickstart/html/
|
||||||
---
|
---
|
||||||
|
|
||||||
# How to use the Redoc HTML element
|
# How to use the Redoc HTML element
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
title: Redoc deployment guide
|
title: Redoc deployment guide
|
||||||
redirectFrom:
|
redirectFrom:
|
||||||
- /docs/quickstart/intro/
|
- /docs/redoc/quickstart/intro/
|
||||||
---
|
---
|
||||||
|
|
||||||
# Redoc deployment guide
|
# Redoc deployment guide
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
title: Use the Redoc React component
|
title: Use the Redoc React component
|
||||||
redirectFrom:
|
redirectFrom:
|
||||||
- /docs/quickstart/react/
|
- /docs/redoc/quickstart/react/
|
||||||
---
|
---
|
||||||
|
|
||||||
# How to use the Redoc React component
|
# How to use the Redoc React component
|
||||||
|
|
|
@ -1,112 +0,0 @@
|
||||||
---
|
|
||||||
title: Using the Redoc CLI
|
|
||||||
---
|
|
||||||
|
|
||||||
# Using 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
|
|
||||||
OpenAPI definition with Redoc.
|
|
||||||
|
|
||||||
## Step 1 - Install Redoc CLI
|
|
||||||
|
|
||||||
You can install the `redoc-cli` package globally using one of the following package managers:
|
|
||||||
|
|
||||||
- [npm](https://docs.npmjs.com/about-npm)
|
|
||||||
- [yarn](https://classic.yarnpkg.com/en/docs/getting-started)
|
|
||||||
|
|
||||||
Or you can install `redoc-cli` using [npx](https://www.freecodecamp.org/news/npm-vs-npx-whats-the-difference/).
|
|
||||||
|
|
||||||
### Install Redoc CLI with yarn
|
|
||||||
|
|
||||||
To install the `redoc-cli` package globally with yarn:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn global add redoc-cli
|
|
||||||
```
|
|
||||||
|
|
||||||
### Install Redoc with npm
|
|
||||||
|
|
||||||
To install the `redoc-cli` package globally with npm:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npm i -g redoc-cli
|
|
||||||
```
|
|
||||||
|
|
||||||
### Install with `npx`
|
|
||||||
|
|
||||||
To install the `redoc-cli` package locally with `npx`, navigate to your project
|
|
||||||
directory in your terminal, then use the following command:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npx redoc-cli
|
|
||||||
```
|
|
||||||
|
|
||||||
## Step 2 - Use the CLI
|
|
||||||
|
|
||||||
### Redoc CLI commands
|
|
||||||
|
|
||||||
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.
|
|
||||||
- `--watch`: Automatically reloads the server while you edit your OpenAPI definition.
|
|
||||||
- `--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.
|
|
||||||
- `--templateOptions`: Adds template options you want to pass to your
|
|
||||||
custom Handlebars template. To add options, use dot notation.
|
|
||||||
- **`--help`:** Prints help text for the Redoc CLI commands and options.
|
|
||||||
- **`--version`:** Prints the version of the `redoc-cli` package you have installed.
|
|
||||||
|
|
||||||
### Redoc CLI examples
|
|
||||||
|
|
||||||
#### Bundle
|
|
||||||
|
|
||||||
Bundle with the main color changed to `orange`:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
redoc-cli bundle openapi.yaml --options.theme.colors.primary.main=orange
|
|
||||||
```
|
|
||||||
|
|
||||||
Bundle using a custom Handlebars template and add custom `templateOptions`:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
redoc-cli bundle http://petstore.swagger.io/v2/swagger.json -t custom.hbs --templateOptions.metaDescription "Page meta description"
|
|
||||||
```
|
|
||||||
|
|
||||||
Sample Handlebars template:
|
|
||||||
|
|
||||||
```handlebars
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf8" />
|
|
||||||
<title>{{title}}</title>
|
|
||||||
<!-- needed for adaptive design -->
|
|
||||||
<meta description="{{{templateOptions.metaDescription}}}">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<style>
|
|
||||||
body {
|
|
||||||
padding: 0;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
{{{redocHead}}}
|
|
||||||
{{#unless disableGoogleFont}}<link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700" rel="stylesheet">{{/unless}}
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
{{{redocHTML}}}
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Serve
|
|
||||||
|
|
||||||
Serve with the `nativeScrollbars` option set to `true`:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
redoc-cli serve openapi/dist.yaml --options.nativeScrollbars
|
|
||||||
```
|
|
|
@ -1,39 +0,0 @@
|
||||||
---
|
|
||||||
title: Using the Redoc Docker image
|
|
||||||
---
|
|
||||||
|
|
||||||
# Using the Redoc Docker image
|
|
||||||
|
|
||||||
Redoc is available as a pre-built Docker image in [Docker Hub](https://hub.docker.com/r/redocly/redoc/).
|
|
||||||
|
|
||||||
If you have [Docker](https://docs.docker.com/get-docker/) installed, pull the image with the following command:
|
|
||||||
|
|
||||||
```docker
|
|
||||||
docker pull redocly/redoc
|
|
||||||
```
|
|
||||||
|
|
||||||
Then run the image with the following command:
|
|
||||||
|
|
||||||
```docker
|
|
||||||
docker run -p 8080:80 redocly/redoc
|
|
||||||
```
|
|
||||||
|
|
||||||
The preview starts on port 8080, based on the port used in the command,
|
|
||||||
and can be accessed at `http://localhost:8080`.
|
|
||||||
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`.
|
|
||||||
|
|
||||||
For example:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
docker run -p 8080:80 -e SPEC_URL=https://api.example.com/openapi.json redocly/redoc
|
|
||||||
```
|
|
||||||
|
|
||||||
## Using 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.
|
|
|
@ -1,214 +0,0 @@
|
||||||
---
|
|
||||||
title: Using the Redoc HTML element
|
|
||||||
---
|
|
||||||
|
|
||||||
# Using the Redoc HTML element
|
|
||||||
|
|
||||||
## TL;DR final code example
|
|
||||||
|
|
||||||
```html
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Redoc</title>
|
|
||||||
<!-- needed for adaptive design -->
|
|
||||||
<meta charset="utf-8"/>
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700" rel="stylesheet">
|
|
||||||
|
|
||||||
<!--
|
|
||||||
Redoc doesn't change outer page styles
|
|
||||||
-->
|
|
||||||
<style>
|
|
||||||
body {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<redoc spec-url='http://petstore.swagger.io/v2/swagger.json'></redoc>
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/redoc@latest/bundles/redoc.standalone.js"> </script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
:::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.
|
|
||||||
:::
|
|
||||||
|
|
||||||
### Running Redoc locally
|
|
||||||
|
|
||||||
If you want to view your Redoc output locally, you can simulate an HTTP server.
|
|
||||||
|
|
||||||
#### Using Redocly CLI
|
|
||||||
|
|
||||||
Redocly 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 [Redocly CLI](https://redocly.com/docs/cli/#installation-and-usage) installed, `cd` into your
|
|
||||||
project directory and run the following command:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
openapi preview-docs openapi.yaml
|
|
||||||
```
|
|
||||||
|
|
||||||
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`.
|
|
||||||
|
|
||||||
#### Using Python
|
|
||||||
|
|
||||||
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`.
|
|
||||||
|
|
||||||
#### Using Node.js
|
|
||||||
|
|
||||||
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
|
|
||||||
http-server
|
|
||||||
```
|
|
||||||
|
|
||||||
The output after entering the command provides the local URL where the preview can be accessed.
|
|
||||||
To exit the preview, use `control-C`.
|
|
||||||
|
|
||||||
## Step 1 - Install Redoc
|
|
||||||
|
|
||||||
You can install Redoc using one of the following package managers:
|
|
||||||
|
|
||||||
- [npm](https://docs.npmjs.com/about-npm)
|
|
||||||
- [yarn](https://classic.yarnpkg.com/en/docs/getting-started)
|
|
||||||
|
|
||||||
:::attention Initialize your package manager
|
|
||||||
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.
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
:::
|
|
||||||
|
|
||||||
### Install Redoc with yarn
|
|
||||||
|
|
||||||
After navigating to your project directory in your terminal, use the following command:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn add redoc
|
|
||||||
```
|
|
||||||
|
|
||||||
### Install Redoc with npm
|
|
||||||
|
|
||||||
After navigating to your project directory in your terminal, use the following command:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npm i redoc
|
|
||||||
```
|
|
||||||
|
|
||||||
## Step 2 - Reference the Redoc script
|
|
||||||
|
|
||||||
You can reference the Redoc script using either a link to the files hosted on a CDN
|
|
||||||
or the files located in your `node modules` folder.
|
|
||||||
|
|
||||||
### CDN link
|
|
||||||
|
|
||||||
To reference the Redoc script with a CDN link:
|
|
||||||
|
|
||||||
```html
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/redoc@latest/bundles/redoc.standalone.js"> </script>
|
|
||||||
```
|
|
||||||
|
|
||||||
### Node modules link
|
|
||||||
|
|
||||||
To reference the Redoc script with a node modules link:
|
|
||||||
|
|
||||||
```html
|
|
||||||
<script src="node_modules/redoc/bundles/redoc.standalone.js"> </script>
|
|
||||||
```
|
|
||||||
|
|
||||||
## Step 3 - Add the <redoc> element
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
To add the <redoc> element with the `spec-url` attribute:
|
|
||||||
|
|
||||||
```html
|
|
||||||
<redoc spec-url="url/to/your/spec"></redoc>
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Examples
|
|
||||||
|
|
||||||
```html
|
|
||||||
<redoc spec-url="http://petstore.swagger.io/v2/swagger.json"></redoc>
|
|
||||||
```
|
|
||||||
|
|
||||||
You can also use a local file (JSON or YAML) in your project, for instance:
|
|
||||||
|
|
||||||
```html
|
|
||||||
<redoc spec-url="dist.json"></redoc>
|
|
||||||
```
|
|
||||||
|
|
||||||
### Using a Redoc object
|
|
||||||
|
|
||||||
To add the <redoc> element with a globally exposed Redoc object:
|
|
||||||
|
|
||||||
```js
|
|
||||||
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://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.
|
|
||||||
|
|
||||||
#### Examples
|
|
||||||
|
|
||||||
```html
|
|
||||||
<script>
|
|
||||||
Redoc.init('http://petstore.swagger.io/v2/swagger.json', {
|
|
||||||
scrollYOffset: 50
|
|
||||||
}, document.getElementById('redoc-container'))
|
|
||||||
</script>
|
|
||||||
```
|
|
||||||
|
|
||||||
You can also use a local file (JSON or YAML) in your project, for instance:
|
|
||||||
|
|
||||||
```html
|
|
||||||
<script>
|
|
||||||
Redoc.init('dist.yaml', {
|
|
||||||
scrollYOffset: 50
|
|
||||||
}, document.getElementById('redoc-container'))
|
|
||||||
</script>
|
|
||||||
```
|
|
|
@ -1,44 +0,0 @@
|
||||||
---
|
|
||||||
title: Redoc quickstart guide
|
|
||||||
---
|
|
||||||
|
|
||||||
# Redoc quickstart guide
|
|
||||||
|
|
||||||
This guide includes step-by-step instructions for how to get started using
|
|
||||||
Redoc to render your OpenAPI definition.
|
|
||||||
|
|
||||||
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/):**
|
|
||||||
The live demo offers a fast way to see how your OpenAPI will render with Redoc.
|
|
||||||
- **[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.
|
|
||||||
- **[CLI](./cli.md):**
|
|
||||||
Using the CLI is an option for users who prefer to use a command-line interface.
|
|
||||||
|
|
||||||
## Before you start
|
|
||||||
|
|
||||||
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)
|
|
||||||
- OpenAPI 2.0
|
|
||||||
- [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://redocly.com/docs/resources/learning-openapi/)
|
|
||||||
section in the documentation.
|
|
||||||
|
|
||||||
## Live demo online
|
|
||||||
|
|
||||||
If you want to see how ReDoc will render 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 the **TRY IT** button.
|
|
|
@ -1,78 +0,0 @@
|
||||||
---
|
|
||||||
title: Using the Redoc React component
|
|
||||||
---
|
|
||||||
|
|
||||||
# Using the Redoc React component
|
|
||||||
|
|
||||||
## Before you start
|
|
||||||
|
|
||||||
Install the following dependencies required by Redoc if you do not already have them installed:
|
|
||||||
|
|
||||||
- `react`
|
|
||||||
- `react-dom`
|
|
||||||
- `mobx`
|
|
||||||
- `styled-components`
|
|
||||||
- `core-js`
|
|
||||||
|
|
||||||
If you have npm installed, you can install these dependencies using the following command:
|
|
||||||
|
|
||||||
```js
|
|
||||||
npm i react react-dom mobx styled-components core-js
|
|
||||||
```
|
|
||||||
|
|
||||||
## Step 1 - Import the `RedocStandalone` component
|
|
||||||
|
|
||||||
```js
|
|
||||||
import { RedocStandalone } from 'redoc';
|
|
||||||
```
|
|
||||||
|
|
||||||
## Step 2 - Use the component
|
|
||||||
|
|
||||||
You can either link to your OpenAPI definition with a URL, using the following format:
|
|
||||||
|
|
||||||
```react
|
|
||||||
<RedocStandalone specUrl="url/to/your/spec"/>
|
|
||||||
```
|
|
||||||
|
|
||||||
Or you can pass your OpenAPI definition as an object, using the following format:
|
|
||||||
|
|
||||||
```js
|
|
||||||
<RedocStandalone spec={/* spec as an object */}/>
|
|
||||||
```
|
|
||||||
|
|
||||||
## Optional - Pass options
|
|
||||||
|
|
||||||
Options can be passed into the RedocStandalone component to alter how it renders.
|
|
||||||
|
|
||||||
For example:
|
|
||||||
|
|
||||||
```js
|
|
||||||
<RedocStandalone
|
|
||||||
specUrl="http://petstore.swagger.io/v2/swagger.json"
|
|
||||||
options={{
|
|
||||||
nativeScrollbars: true,
|
|
||||||
theme: { colors: { primary: { main: '#dd5522' } } },
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
```
|
|
||||||
|
|
||||||
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".
|
|
||||||
|
|
||||||
## Optional - Specify `onLoaded` callback
|
|
||||||
|
|
||||||
You can also specify the `onLoaded` callback, which is called each time Redoc
|
|
||||||
is fully rendered or when an error occurs (with an error as the first argument).
|
|
||||||
|
|
||||||
```js
|
|
||||||
<RedocStandalone
|
|
||||||
specUrl="http://petstore.swagger.io/v2/swagger.json"
|
|
||||||
onLoaded={error => {
|
|
||||||
if (!error) {
|
|
||||||
console.log('Yay!');
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
```
|
|
81
package-lock.json
generated
81
package-lock.json
generated
|
@ -1,15 +1,15 @@
|
||||||
{
|
{
|
||||||
"name": "redoc",
|
"name": "redoc",
|
||||||
"version": "2.0.0-rc.68",
|
"version": "2.0.0-rc.69",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "redoc",
|
"name": "redoc",
|
||||||
"version": "2.0.0-rc.68",
|
"version": "2.0.0-rc.69",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@redocly/openapi-core": "^1.0.0-beta.95",
|
"@redocly/openapi-core": "^1.0.0-beta.97",
|
||||||
"classnames": "^2.3.1",
|
"classnames": "^2.3.1",
|
||||||
"decko": "^1.2.0",
|
"decko": "^1.2.0",
|
||||||
"dompurify": "^2.2.8",
|
"dompurify": "^2.2.8",
|
||||||
|
@ -19,7 +19,7 @@
|
||||||
"mark.js": "^8.11.1",
|
"mark.js": "^8.11.1",
|
||||||
"marked": "^4.0.15",
|
"marked": "^4.0.15",
|
||||||
"mobx-react": "^7.2.0",
|
"mobx-react": "^7.2.0",
|
||||||
"openapi-sampler": "^1.2.1",
|
"openapi-sampler": "^1.2.3",
|
||||||
"path-browserify": "^1.0.1",
|
"path-browserify": "^1.0.1",
|
||||||
"perfect-scrollbar": "^1.5.1",
|
"perfect-scrollbar": "^1.5.1",
|
||||||
"polished": "^4.1.3",
|
"polished": "^4.1.3",
|
||||||
|
@ -2590,9 +2590,9 @@
|
||||||
"integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="
|
"integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="
|
||||||
},
|
},
|
||||||
"node_modules/@redocly/openapi-core": {
|
"node_modules/@redocly/openapi-core": {
|
||||||
"version": "1.0.0-beta.95",
|
"version": "1.0.0-beta.97",
|
||||||
"resolved": "https://registry.npmjs.org/@redocly/openapi-core/-/openapi-core-1.0.0-beta.95.tgz",
|
"resolved": "https://registry.npmjs.org/@redocly/openapi-core/-/openapi-core-1.0.0-beta.97.tgz",
|
||||||
"integrity": "sha512-7Nnc4Obp/1lbrjNjD33oOnZCuoJa8awhBCEyyayPWGQFp1SkhjpZJnfnKkFuYbQzMjTIAvEeSp9DOQK/E0fgEA==",
|
"integrity": "sha512-3WW9/6flosJuRtU3GI0Vw39OYFZqqXMDCp5TLa3EjXOb7Nm6AZTWRb3Y+I/+UdNJ/NTszVJkQczoa1t476ekiQ==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@redocly/ajv": "^8.6.4",
|
"@redocly/ajv": "^8.6.4",
|
||||||
"@types/node": "^14.11.8",
|
"@types/node": "^14.11.8",
|
||||||
|
@ -2600,7 +2600,7 @@
|
||||||
"js-levenshtein": "^1.1.6",
|
"js-levenshtein": "^1.1.6",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
"lodash.isequal": "^4.5.0",
|
"lodash.isequal": "^4.5.0",
|
||||||
"minimatch": "^3.0.4",
|
"minimatch": "^5.0.1",
|
||||||
"node-fetch": "^2.6.1",
|
"node-fetch": "^2.6.1",
|
||||||
"pluralize": "^8.0.0",
|
"pluralize": "^8.0.0",
|
||||||
"yaml-ast-parser": "0.0.43"
|
"yaml-ast-parser": "0.0.43"
|
||||||
|
@ -2614,6 +2614,25 @@
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.17.3.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.17.3.tgz",
|
||||||
"integrity": "sha512-e6ZowgGJmTuXa3GyaPbTGxX17tnThl2aSSizrFthQ7m9uLGZBXiGhgE55cjRZTF5kjZvYn9EOPOMljdjwbflxw=="
|
"integrity": "sha512-e6ZowgGJmTuXa3GyaPbTGxX17tnThl2aSSizrFthQ7m9uLGZBXiGhgE55cjRZTF5kjZvYn9EOPOMljdjwbflxw=="
|
||||||
},
|
},
|
||||||
|
"node_modules/@redocly/openapi-core/node_modules/brace-expansion": {
|
||||||
|
"version": "2.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
|
||||||
|
"integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
|
||||||
|
"dependencies": {
|
||||||
|
"balanced-match": "^1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@redocly/openapi-core/node_modules/minimatch": {
|
||||||
|
"version": "5.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz",
|
||||||
|
"integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==",
|
||||||
|
"dependencies": {
|
||||||
|
"brace-expansion": "^2.0.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@sinonjs/commons": {
|
"node_modules/@sinonjs/commons": {
|
||||||
"version": "1.8.3",
|
"version": "1.8.3",
|
||||||
"resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.3.tgz",
|
"resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.3.tgz",
|
||||||
|
@ -4521,6 +4540,7 @@
|
||||||
"version": "1.1.11",
|
"version": "1.1.11",
|
||||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
||||||
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
|
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
|
||||||
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"balanced-match": "^1.0.0",
|
"balanced-match": "^1.0.0",
|
||||||
"concat-map": "0.0.1"
|
"concat-map": "0.0.1"
|
||||||
|
@ -5124,7 +5144,8 @@
|
||||||
"node_modules/concat-map": {
|
"node_modules/concat-map": {
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||||
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
|
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
|
||||||
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/connect-history-api-fallback": {
|
"node_modules/connect-history-api-fallback": {
|
||||||
"version": "1.6.0",
|
"version": "1.6.0",
|
||||||
|
@ -13482,6 +13503,7 @@
|
||||||
"version": "3.0.4",
|
"version": "3.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
||||||
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
|
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
|
||||||
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"brace-expansion": "^1.1.7"
|
"brace-expansion": "^1.1.7"
|
||||||
},
|
},
|
||||||
|
@ -14195,9 +14217,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/openapi-sampler": {
|
"node_modules/openapi-sampler": {
|
||||||
"version": "1.2.1",
|
"version": "1.2.3",
|
||||||
"resolved": "https://registry.npmjs.org/openapi-sampler/-/openapi-sampler-1.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/openapi-sampler/-/openapi-sampler-1.2.3.tgz",
|
||||||
"integrity": "sha512-mHrYmyvcLD0qrfqPkPRBAL2z16hGT2rW0d0B7nklfoTcc3pmkJLkSZlKSeFgerUM41E5c7jlxf0Y19xrM7mWQQ==",
|
"integrity": "sha512-dH2QYXqakorV5dxkP/f1BV3Ku4yNn21YmBsqJunnyrHLw7mnCNZZldftgrEpv/66b1m5oaUAmiJoJN+FqBEkJg==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/json-schema": "^7.0.7",
|
"@types/json-schema": "^7.0.7",
|
||||||
"json-pointer": "0.6.2"
|
"json-pointer": "0.6.2"
|
||||||
|
@ -20971,9 +20993,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@redocly/openapi-core": {
|
"@redocly/openapi-core": {
|
||||||
"version": "1.0.0-beta.95",
|
"version": "1.0.0-beta.97",
|
||||||
"resolved": "https://registry.npmjs.org/@redocly/openapi-core/-/openapi-core-1.0.0-beta.95.tgz",
|
"resolved": "https://registry.npmjs.org/@redocly/openapi-core/-/openapi-core-1.0.0-beta.97.tgz",
|
||||||
"integrity": "sha512-7Nnc4Obp/1lbrjNjD33oOnZCuoJa8awhBCEyyayPWGQFp1SkhjpZJnfnKkFuYbQzMjTIAvEeSp9DOQK/E0fgEA==",
|
"integrity": "sha512-3WW9/6flosJuRtU3GI0Vw39OYFZqqXMDCp5TLa3EjXOb7Nm6AZTWRb3Y+I/+UdNJ/NTszVJkQczoa1t476ekiQ==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@redocly/ajv": "^8.6.4",
|
"@redocly/ajv": "^8.6.4",
|
||||||
"@types/node": "^14.11.8",
|
"@types/node": "^14.11.8",
|
||||||
|
@ -20981,7 +21003,7 @@
|
||||||
"js-levenshtein": "^1.1.6",
|
"js-levenshtein": "^1.1.6",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
"lodash.isequal": "^4.5.0",
|
"lodash.isequal": "^4.5.0",
|
||||||
"minimatch": "^3.0.4",
|
"minimatch": "^5.0.1",
|
||||||
"node-fetch": "^2.6.1",
|
"node-fetch": "^2.6.1",
|
||||||
"pluralize": "^8.0.0",
|
"pluralize": "^8.0.0",
|
||||||
"yaml-ast-parser": "0.0.43"
|
"yaml-ast-parser": "0.0.43"
|
||||||
|
@ -20991,6 +21013,22 @@
|
||||||
"version": "14.17.3",
|
"version": "14.17.3",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.17.3.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.17.3.tgz",
|
||||||
"integrity": "sha512-e6ZowgGJmTuXa3GyaPbTGxX17tnThl2aSSizrFthQ7m9uLGZBXiGhgE55cjRZTF5kjZvYn9EOPOMljdjwbflxw=="
|
"integrity": "sha512-e6ZowgGJmTuXa3GyaPbTGxX17tnThl2aSSizrFthQ7m9uLGZBXiGhgE55cjRZTF5kjZvYn9EOPOMljdjwbflxw=="
|
||||||
|
},
|
||||||
|
"brace-expansion": {
|
||||||
|
"version": "2.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
|
||||||
|
"integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
|
||||||
|
"requires": {
|
||||||
|
"balanced-match": "^1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"minimatch": {
|
||||||
|
"version": "5.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz",
|
||||||
|
"integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==",
|
||||||
|
"requires": {
|
||||||
|
"brace-expansion": "^2.0.1"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -22567,6 +22605,7 @@
|
||||||
"version": "1.1.11",
|
"version": "1.1.11",
|
||||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
||||||
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
|
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
|
||||||
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"balanced-match": "^1.0.0",
|
"balanced-match": "^1.0.0",
|
||||||
"concat-map": "0.0.1"
|
"concat-map": "0.0.1"
|
||||||
|
@ -23038,7 +23077,8 @@
|
||||||
"concat-map": {
|
"concat-map": {
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||||
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
|
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
|
||||||
|
"dev": true
|
||||||
},
|
},
|
||||||
"connect-history-api-fallback": {
|
"connect-history-api-fallback": {
|
||||||
"version": "1.6.0",
|
"version": "1.6.0",
|
||||||
|
@ -29310,6 +29350,7 @@
|
||||||
"version": "3.0.4",
|
"version": "3.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
||||||
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
|
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
|
||||||
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"brace-expansion": "^1.1.7"
|
"brace-expansion": "^1.1.7"
|
||||||
}
|
}
|
||||||
|
@ -29831,9 +29872,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"openapi-sampler": {
|
"openapi-sampler": {
|
||||||
"version": "1.2.1",
|
"version": "1.2.3",
|
||||||
"resolved": "https://registry.npmjs.org/openapi-sampler/-/openapi-sampler-1.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/openapi-sampler/-/openapi-sampler-1.2.3.tgz",
|
||||||
"integrity": "sha512-mHrYmyvcLD0qrfqPkPRBAL2z16hGT2rW0d0B7nklfoTcc3pmkJLkSZlKSeFgerUM41E5c7jlxf0Y19xrM7mWQQ==",
|
"integrity": "sha512-dH2QYXqakorV5dxkP/f1BV3Ku4yNn21YmBsqJunnyrHLw7mnCNZZldftgrEpv/66b1m5oaUAmiJoJN+FqBEkJg==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@types/json-schema": "^7.0.7",
|
"@types/json-schema": "^7.0.7",
|
||||||
"json-pointer": "0.6.2"
|
"json-pointer": "0.6.2"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "redoc",
|
"name": "redoc",
|
||||||
"version": "2.0.0-rc.68",
|
"version": "2.0.0-rc.69",
|
||||||
"description": "ReDoc",
|
"description": "ReDoc",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
@ -43,7 +43,7 @@
|
||||||
"bundle:standalone": "webpack --env production --env standalone --mode=production",
|
"bundle:standalone": "webpack --env production --env standalone --mode=production",
|
||||||
"bundle:lib": "webpack --mode=production && npm run declarations",
|
"bundle:lib": "webpack --mode=production && npm run declarations",
|
||||||
"bundle:browser": "webpack --env production --env browser --mode=production",
|
"bundle:browser": "webpack --env production --env browser --mode=production",
|
||||||
"bundle": "npm run bundle:clean && npm run bundle:lib && npm run bundle:browser && npm run bundle:standalone",
|
"bundle": "npm run bundle:clean && npm run bundle:lib && npm run bundle:browser && npm run bundle:standalone && npm run compile:cli",
|
||||||
"declarations": "tsc --emitDeclarationOnly -p tsconfig.lib.json && cp -R src/types typings/",
|
"declarations": "tsc --emitDeclarationOnly -p tsconfig.lib.json && cp -R src/types typings/",
|
||||||
"stats": "webpack --env production --env standalone --json --profile --mode=production > stats.json",
|
"stats": "webpack --env production --env standalone --json --profile --mode=production > stats.json",
|
||||||
"prettier": "prettier --write \"cli/index.ts\" \"src/**/*.{ts,tsx}\"",
|
"prettier": "prettier --write \"cli/index.ts\" \"src/**/*.{ts,tsx}\"",
|
||||||
|
@ -138,7 +138,7 @@
|
||||||
"styled-components": "^4.1.1 || ^5.1.1"
|
"styled-components": "^4.1.1 || ^5.1.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@redocly/openapi-core": "^1.0.0-beta.95",
|
"@redocly/openapi-core": "^1.0.0-beta.97",
|
||||||
"classnames": "^2.3.1",
|
"classnames": "^2.3.1",
|
||||||
"decko": "^1.2.0",
|
"decko": "^1.2.0",
|
||||||
"dompurify": "^2.2.8",
|
"dompurify": "^2.2.8",
|
||||||
|
@ -148,7 +148,7 @@
|
||||||
"mark.js": "^8.11.1",
|
"mark.js": "^8.11.1",
|
||||||
"marked": "^4.0.15",
|
"marked": "^4.0.15",
|
||||||
"mobx-react": "^7.2.0",
|
"mobx-react": "^7.2.0",
|
||||||
"openapi-sampler": "^1.2.1",
|
"openapi-sampler": "^1.2.3",
|
||||||
"path-browserify": "^1.0.1",
|
"path-browserify": "^1.0.1",
|
||||||
"perfect-scrollbar": "^1.5.1",
|
"perfect-scrollbar": "^1.5.1",
|
||||||
"polished": "^4.1.3",
|
"polished": "^4.1.3",
|
||||||
|
|
|
@ -27,48 +27,48 @@ export interface OperationProps {
|
||||||
operation: OperationModel;
|
operation: OperationModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@observer
|
export const Operation = observer(({ operation }: OperationProps): JSX.Element => {
|
||||||
export class Operation extends React.Component<OperationProps> {
|
const { name: summary, description, deprecated, externalDocs, isWebhook, httpVerb } = operation;
|
||||||
render() {
|
const hasDescription = !!(description || externalDocs);
|
||||||
const { operation } = this.props;
|
const { showWebhookVerb } = React.useContext(OptionsContext);
|
||||||
|
return (
|
||||||
const { name: summary, description, deprecated, externalDocs, isWebhook } = operation;
|
<OptionsContext.Consumer>
|
||||||
const hasDescription = !!(description || externalDocs);
|
{options => (
|
||||||
|
<Row {...{ [SECTION_ATTR]: operation.operationHash }} id={operation.operationHash}>
|
||||||
return (
|
<MiddlePanel>
|
||||||
<OptionsContext.Consumer>
|
<H2>
|
||||||
{options => (
|
<ShareLink to={operation.id} />
|
||||||
<Row {...{ [SECTION_ATTR]: operation.operationHash }} id={operation.operationHash}>
|
{summary} {deprecated && <Badge type="warning"> Deprecated </Badge>}
|
||||||
<MiddlePanel>
|
{isWebhook && (
|
||||||
<H2>
|
<Badge type="primary">
|
||||||
<ShareLink to={operation.id} />
|
{' '}
|
||||||
{summary} {deprecated && <Badge type="warning"> Deprecated </Badge>}
|
Webhook {showWebhookVerb && httpVerb && '| ' + httpVerb.toUpperCase()}
|
||||||
{isWebhook && <Badge type="primary"> Webhook </Badge>}
|
</Badge>
|
||||||
</H2>
|
|
||||||
{options.pathInMiddlePanel && !isWebhook && (
|
|
||||||
<Endpoint operation={operation} inverted={true} />
|
|
||||||
)}
|
)}
|
||||||
{hasDescription && (
|
</H2>
|
||||||
<Description>
|
{options.pathInMiddlePanel && !isWebhook && (
|
||||||
{description !== undefined && <Markdown source={description} />}
|
<Endpoint operation={operation} inverted={true} />
|
||||||
{externalDocs && <ExternalDocumentation externalDocs={externalDocs} />}
|
)}
|
||||||
</Description>
|
{hasDescription && (
|
||||||
)}
|
<Description>
|
||||||
<Extensions extensions={operation.extensions} />
|
{description !== undefined && <Markdown source={description} />}
|
||||||
<SecurityRequirements securities={operation.security} />
|
{externalDocs && <ExternalDocumentation externalDocs={externalDocs} />}
|
||||||
<Parameters parameters={operation.parameters} body={operation.requestBody} />
|
</Description>
|
||||||
<ResponsesList responses={operation.responses} />
|
)}
|
||||||
<CallbacksList callbacks={operation.callbacks} />
|
<Extensions extensions={operation.extensions} />
|
||||||
</MiddlePanel>
|
<SecurityRequirements securities={operation.security} />
|
||||||
<DarkRightPanel>
|
<Parameters parameters={operation.parameters} body={operation.requestBody} />
|
||||||
{!options.pathInMiddlePanel && !isWebhook && <Endpoint operation={operation} />}
|
<ResponsesList responses={operation.responses} />
|
||||||
<RequestSamples operation={operation} />
|
<CallbacksList callbacks={operation.callbacks} />
|
||||||
<ResponseSamples operation={operation} />
|
</MiddlePanel>
|
||||||
<CallbackSamples callbacks={operation.callbacks} />
|
<DarkRightPanel>
|
||||||
</DarkRightPanel>
|
{!options.pathInMiddlePanel && !isWebhook && <Endpoint operation={operation} />}
|
||||||
</Row>
|
<RequestSamples operation={operation} />
|
||||||
)}
|
<ResponseSamples operation={operation} />
|
||||||
</OptionsContext.Consumer>
|
<CallbackSamples callbacks={operation.callbacks} />
|
||||||
);
|
</DarkRightPanel>
|
||||||
}
|
</Row>
|
||||||
}
|
)}
|
||||||
|
</OptionsContext.Consumer>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
|
@ -8,11 +8,13 @@ import { MenuItems } from './MenuItems';
|
||||||
import { MenuItemLabel, MenuItemLi, MenuItemTitle, OperationBadge } from './styled.elements';
|
import { MenuItemLabel, MenuItemLi, MenuItemTitle, OperationBadge } from './styled.elements';
|
||||||
import { l } from '../../services/Labels';
|
import { l } from '../../services/Labels';
|
||||||
import { scrollIntoViewIfNeeded } from '../../utils';
|
import { scrollIntoViewIfNeeded } from '../../utils';
|
||||||
|
import { OptionsContext } from '../OptionsProvider';
|
||||||
|
|
||||||
export interface MenuItemProps {
|
export interface MenuItemProps {
|
||||||
item: IMenuItem;
|
item: IMenuItem;
|
||||||
onActivate?: (item: IMenuItem) => void;
|
onActivate?: (item: IMenuItem) => void;
|
||||||
withoutChildren?: boolean;
|
withoutChildren?: boolean;
|
||||||
|
children?: React.ReactChild;
|
||||||
}
|
}
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
|
@ -75,37 +77,33 @@ export class MenuItem extends React.Component<MenuItemProps> {
|
||||||
|
|
||||||
export interface OperationMenuItemContentProps {
|
export interface OperationMenuItemContentProps {
|
||||||
item: OperationModel;
|
item: OperationModel;
|
||||||
|
children?: React.ReactChild;
|
||||||
}
|
}
|
||||||
|
|
||||||
@observer
|
export const OperationMenuItemContent = observer((props: OperationMenuItemContentProps) => {
|
||||||
export class OperationMenuItemContent extends React.Component<OperationMenuItemContentProps> {
|
const { item } = props;
|
||||||
ref = React.createRef<HTMLLabelElement>();
|
const ref = React.createRef<HTMLLabelElement>();
|
||||||
|
const { showWebhookVerb } = React.useContext(OptionsContext);
|
||||||
|
|
||||||
componentDidUpdate() {
|
React.useEffect(() => {
|
||||||
if (this.props.item.active && this.ref.current) {
|
if (props.item.active && ref.current) {
|
||||||
scrollIntoViewIfNeeded(this.ref.current);
|
scrollIntoViewIfNeeded(ref.current);
|
||||||
}
|
}
|
||||||
}
|
}, [props.item.active, ref]);
|
||||||
|
|
||||||
render() {
|
return (
|
||||||
const { item } = this.props;
|
<MenuItemLabel depth={item.depth} active={item.active} deprecated={item.deprecated} ref={ref}>
|
||||||
return (
|
{item.isWebhook ? (
|
||||||
<MenuItemLabel
|
<OperationBadge type="hook">
|
||||||
depth={item.depth}
|
{showWebhookVerb ? item.httpVerb : l('webhook')}
|
||||||
active={item.active}
|
</OperationBadge>
|
||||||
deprecated={item.deprecated}
|
) : (
|
||||||
ref={this.ref}
|
<OperationBadge type={item.httpVerb}>{shortenHTTPVerb(item.httpVerb)}</OperationBadge>
|
||||||
>
|
)}
|
||||||
{item.isWebhook ? (
|
<MenuItemTitle width="calc(100% - 38px)">
|
||||||
<OperationBadge type="hook">{l('webhook')}</OperationBadge>
|
{item.sidebarLabel}
|
||||||
) : (
|
{props.children}
|
||||||
<OperationBadge type={item.httpVerb}>{shortenHTTPVerb(item.httpVerb)}</OperationBadge>
|
</MenuItemTitle>
|
||||||
)}
|
</MenuItemLabel>
|
||||||
<MenuItemTitle width="calc(100% - 38px)">
|
);
|
||||||
{item.sidebarLabel}
|
});
|
||||||
{this.props.children}
|
|
||||||
</MenuItemTitle>
|
|
||||||
</MenuItemLabel>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -77,6 +77,8 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"options": RedocNormalizedOptions {
|
"options": RedocNormalizedOptions {
|
||||||
"allowedMdComponents": Object {},
|
"allowedMdComponents": Object {},
|
||||||
"disableSearch": false,
|
"disableSearch": false,
|
||||||
|
"downloadDefinitionUrl": undefined,
|
||||||
|
"downloadFileName": undefined,
|
||||||
"enumSkipQuotes": false,
|
"enumSkipQuotes": false,
|
||||||
"expandDefaultServerVariables": false,
|
"expandDefaultServerVariables": false,
|
||||||
"expandResponses": Object {},
|
"expandResponses": Object {},
|
||||||
|
@ -105,6 +107,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"sectionsAtTheEnd": Array [],
|
"sectionsAtTheEnd": Array [],
|
||||||
"showExtensions": false,
|
"showExtensions": false,
|
||||||
"showObjectSchemaExamples": false,
|
"showObjectSchemaExamples": false,
|
||||||
|
"showWebhookVerb": false,
|
||||||
"sideNavStyle": "summary-only",
|
"sideNavStyle": "summary-only",
|
||||||
"simpleOneOfTypeLabel": false,
|
"simpleOneOfTypeLabel": false,
|
||||||
"sortEnumValuesAlphabetically": false,
|
"sortEnumValuesAlphabetically": false,
|
||||||
|
@ -330,6 +333,8 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"options": RedocNormalizedOptions {
|
"options": RedocNormalizedOptions {
|
||||||
"allowedMdComponents": Object {},
|
"allowedMdComponents": Object {},
|
||||||
"disableSearch": false,
|
"disableSearch": false,
|
||||||
|
"downloadDefinitionUrl": undefined,
|
||||||
|
"downloadFileName": undefined,
|
||||||
"enumSkipQuotes": false,
|
"enumSkipQuotes": false,
|
||||||
"expandDefaultServerVariables": false,
|
"expandDefaultServerVariables": false,
|
||||||
"expandResponses": Object {},
|
"expandResponses": Object {},
|
||||||
|
@ -358,6 +363,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"sectionsAtTheEnd": Array [],
|
"sectionsAtTheEnd": Array [],
|
||||||
"showExtensions": false,
|
"showExtensions": false,
|
||||||
"showObjectSchemaExamples": false,
|
"showObjectSchemaExamples": false,
|
||||||
|
"showWebhookVerb": false,
|
||||||
"sideNavStyle": "summary-only",
|
"sideNavStyle": "summary-only",
|
||||||
"simpleOneOfTypeLabel": false,
|
"simpleOneOfTypeLabel": false,
|
||||||
"sortEnumValuesAlphabetically": false,
|
"sortEnumValuesAlphabetically": false,
|
||||||
|
@ -558,6 +564,8 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"options": RedocNormalizedOptions {
|
"options": RedocNormalizedOptions {
|
||||||
"allowedMdComponents": Object {},
|
"allowedMdComponents": Object {},
|
||||||
"disableSearch": false,
|
"disableSearch": false,
|
||||||
|
"downloadDefinitionUrl": undefined,
|
||||||
|
"downloadFileName": undefined,
|
||||||
"enumSkipQuotes": false,
|
"enumSkipQuotes": false,
|
||||||
"expandDefaultServerVariables": false,
|
"expandDefaultServerVariables": false,
|
||||||
"expandResponses": Object {},
|
"expandResponses": Object {},
|
||||||
|
@ -586,6 +594,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"sectionsAtTheEnd": Array [],
|
"sectionsAtTheEnd": Array [],
|
||||||
"showExtensions": false,
|
"showExtensions": false,
|
||||||
"showObjectSchemaExamples": false,
|
"showObjectSchemaExamples": false,
|
||||||
|
"showWebhookVerb": false,
|
||||||
"sideNavStyle": "summary-only",
|
"sideNavStyle": "summary-only",
|
||||||
"simpleOneOfTypeLabel": false,
|
"simpleOneOfTypeLabel": false,
|
||||||
"sortEnumValuesAlphabetically": false,
|
"sortEnumValuesAlphabetically": false,
|
||||||
|
@ -853,6 +862,8 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"options": RedocNormalizedOptions {
|
"options": RedocNormalizedOptions {
|
||||||
"allowedMdComponents": Object {},
|
"allowedMdComponents": Object {},
|
||||||
"disableSearch": false,
|
"disableSearch": false,
|
||||||
|
"downloadDefinitionUrl": undefined,
|
||||||
|
"downloadFileName": undefined,
|
||||||
"enumSkipQuotes": false,
|
"enumSkipQuotes": false,
|
||||||
"expandDefaultServerVariables": false,
|
"expandDefaultServerVariables": false,
|
||||||
"expandResponses": Object {},
|
"expandResponses": Object {},
|
||||||
|
@ -881,6 +892,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"sectionsAtTheEnd": Array [],
|
"sectionsAtTheEnd": Array [],
|
||||||
"showExtensions": false,
|
"showExtensions": false,
|
||||||
"showObjectSchemaExamples": false,
|
"showObjectSchemaExamples": false,
|
||||||
|
"showWebhookVerb": false,
|
||||||
"sideNavStyle": "summary-only",
|
"sideNavStyle": "summary-only",
|
||||||
"simpleOneOfTypeLabel": false,
|
"simpleOneOfTypeLabel": false,
|
||||||
"sortEnumValuesAlphabetically": false,
|
"sortEnumValuesAlphabetically": false,
|
||||||
|
@ -1106,6 +1118,8 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"options": RedocNormalizedOptions {
|
"options": RedocNormalizedOptions {
|
||||||
"allowedMdComponents": Object {},
|
"allowedMdComponents": Object {},
|
||||||
"disableSearch": false,
|
"disableSearch": false,
|
||||||
|
"downloadDefinitionUrl": undefined,
|
||||||
|
"downloadFileName": undefined,
|
||||||
"enumSkipQuotes": false,
|
"enumSkipQuotes": false,
|
||||||
"expandDefaultServerVariables": false,
|
"expandDefaultServerVariables": false,
|
||||||
"expandResponses": Object {},
|
"expandResponses": Object {},
|
||||||
|
@ -1134,6 +1148,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"sectionsAtTheEnd": Array [],
|
"sectionsAtTheEnd": Array [],
|
||||||
"showExtensions": false,
|
"showExtensions": false,
|
||||||
"showObjectSchemaExamples": false,
|
"showObjectSchemaExamples": false,
|
||||||
|
"showWebhookVerb": false,
|
||||||
"sideNavStyle": "summary-only",
|
"sideNavStyle": "summary-only",
|
||||||
"simpleOneOfTypeLabel": false,
|
"simpleOneOfTypeLabel": false,
|
||||||
"sortEnumValuesAlphabetically": false,
|
"sortEnumValuesAlphabetically": false,
|
||||||
|
@ -1334,6 +1349,8 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"options": RedocNormalizedOptions {
|
"options": RedocNormalizedOptions {
|
||||||
"allowedMdComponents": Object {},
|
"allowedMdComponents": Object {},
|
||||||
"disableSearch": false,
|
"disableSearch": false,
|
||||||
|
"downloadDefinitionUrl": undefined,
|
||||||
|
"downloadFileName": undefined,
|
||||||
"enumSkipQuotes": false,
|
"enumSkipQuotes": false,
|
||||||
"expandDefaultServerVariables": false,
|
"expandDefaultServerVariables": false,
|
||||||
"expandResponses": Object {},
|
"expandResponses": Object {},
|
||||||
|
@ -1362,6 +1379,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"sectionsAtTheEnd": Array [],
|
"sectionsAtTheEnd": Array [],
|
||||||
"showExtensions": false,
|
"showExtensions": false,
|
||||||
"showObjectSchemaExamples": false,
|
"showObjectSchemaExamples": false,
|
||||||
|
"showWebhookVerb": false,
|
||||||
"sideNavStyle": "summary-only",
|
"sideNavStyle": "summary-only",
|
||||||
"simpleOneOfTypeLabel": false,
|
"simpleOneOfTypeLabel": false,
|
||||||
"sortEnumValuesAlphabetically": false,
|
"sortEnumValuesAlphabetically": false,
|
||||||
|
@ -1585,6 +1603,8 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"options": RedocNormalizedOptions {
|
"options": RedocNormalizedOptions {
|
||||||
"allowedMdComponents": Object {},
|
"allowedMdComponents": Object {},
|
||||||
"disableSearch": false,
|
"disableSearch": false,
|
||||||
|
"downloadDefinitionUrl": undefined,
|
||||||
|
"downloadFileName": undefined,
|
||||||
"enumSkipQuotes": false,
|
"enumSkipQuotes": false,
|
||||||
"expandDefaultServerVariables": false,
|
"expandDefaultServerVariables": false,
|
||||||
"expandResponses": Object {},
|
"expandResponses": Object {},
|
||||||
|
@ -1613,6 +1633,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"sectionsAtTheEnd": Array [],
|
"sectionsAtTheEnd": Array [],
|
||||||
"showExtensions": false,
|
"showExtensions": false,
|
||||||
"showObjectSchemaExamples": false,
|
"showObjectSchemaExamples": false,
|
||||||
|
"showWebhookVerb": false,
|
||||||
"sideNavStyle": "summary-only",
|
"sideNavStyle": "summary-only",
|
||||||
"simpleOneOfTypeLabel": false,
|
"simpleOneOfTypeLabel": false,
|
||||||
"sortEnumValuesAlphabetically": false,
|
"sortEnumValuesAlphabetically": false,
|
||||||
|
@ -1877,6 +1898,8 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"options": RedocNormalizedOptions {
|
"options": RedocNormalizedOptions {
|
||||||
"allowedMdComponents": Object {},
|
"allowedMdComponents": Object {},
|
||||||
"disableSearch": false,
|
"disableSearch": false,
|
||||||
|
"downloadDefinitionUrl": undefined,
|
||||||
|
"downloadFileName": undefined,
|
||||||
"enumSkipQuotes": false,
|
"enumSkipQuotes": false,
|
||||||
"expandDefaultServerVariables": false,
|
"expandDefaultServerVariables": false,
|
||||||
"expandResponses": Object {},
|
"expandResponses": Object {},
|
||||||
|
@ -1905,6 +1928,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"sectionsAtTheEnd": Array [],
|
"sectionsAtTheEnd": Array [],
|
||||||
"showExtensions": false,
|
"showExtensions": false,
|
||||||
"showObjectSchemaExamples": false,
|
"showObjectSchemaExamples": false,
|
||||||
|
"showWebhookVerb": false,
|
||||||
"sideNavStyle": "summary-only",
|
"sideNavStyle": "summary-only",
|
||||||
"simpleOneOfTypeLabel": false,
|
"simpleOneOfTypeLabel": false,
|
||||||
"sortEnumValuesAlphabetically": false,
|
"sortEnumValuesAlphabetically": false,
|
||||||
|
@ -2130,6 +2154,8 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"options": RedocNormalizedOptions {
|
"options": RedocNormalizedOptions {
|
||||||
"allowedMdComponents": Object {},
|
"allowedMdComponents": Object {},
|
||||||
"disableSearch": false,
|
"disableSearch": false,
|
||||||
|
"downloadDefinitionUrl": undefined,
|
||||||
|
"downloadFileName": undefined,
|
||||||
"enumSkipQuotes": false,
|
"enumSkipQuotes": false,
|
||||||
"expandDefaultServerVariables": false,
|
"expandDefaultServerVariables": false,
|
||||||
"expandResponses": Object {},
|
"expandResponses": Object {},
|
||||||
|
@ -2158,6 +2184,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"sectionsAtTheEnd": Array [],
|
"sectionsAtTheEnd": Array [],
|
||||||
"showExtensions": false,
|
"showExtensions": false,
|
||||||
"showObjectSchemaExamples": false,
|
"showObjectSchemaExamples": false,
|
||||||
|
"showWebhookVerb": false,
|
||||||
"sideNavStyle": "summary-only",
|
"sideNavStyle": "summary-only",
|
||||||
"simpleOneOfTypeLabel": false,
|
"simpleOneOfTypeLabel": false,
|
||||||
"sortEnumValuesAlphabetically": false,
|
"sortEnumValuesAlphabetically": false,
|
||||||
|
@ -2358,6 +2385,8 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"options": RedocNormalizedOptions {
|
"options": RedocNormalizedOptions {
|
||||||
"allowedMdComponents": Object {},
|
"allowedMdComponents": Object {},
|
||||||
"disableSearch": false,
|
"disableSearch": false,
|
||||||
|
"downloadDefinitionUrl": undefined,
|
||||||
|
"downloadFileName": undefined,
|
||||||
"enumSkipQuotes": false,
|
"enumSkipQuotes": false,
|
||||||
"expandDefaultServerVariables": false,
|
"expandDefaultServerVariables": false,
|
||||||
"expandResponses": Object {},
|
"expandResponses": Object {},
|
||||||
|
@ -2386,6 +2415,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"sectionsAtTheEnd": Array [],
|
"sectionsAtTheEnd": Array [],
|
||||||
"showExtensions": false,
|
"showExtensions": false,
|
||||||
"showObjectSchemaExamples": false,
|
"showObjectSchemaExamples": false,
|
||||||
|
"showWebhookVerb": false,
|
||||||
"sideNavStyle": "summary-only",
|
"sideNavStyle": "summary-only",
|
||||||
"simpleOneOfTypeLabel": false,
|
"simpleOneOfTypeLabel": false,
|
||||||
"sortEnumValuesAlphabetically": false,
|
"sortEnumValuesAlphabetically": false,
|
||||||
|
|
|
@ -58,7 +58,7 @@ export class OpenAPIParser {
|
||||||
this.spec = spec;
|
this.spec = spec;
|
||||||
this.allowMergeRefs = spec.openapi.startsWith('3.1');
|
this.allowMergeRefs = spec.openapi.startsWith('3.1');
|
||||||
|
|
||||||
const href = IS_BROWSER ? window.location.href : '';
|
const href = IS_BROWSER ? window.location.href : undefined;
|
||||||
if (typeof specUrl === 'string') {
|
if (typeof specUrl === 'string') {
|
||||||
this.specUrl = new URL(specUrl, href).href;
|
this.specUrl = new URL(specUrl, href).href;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,8 @@ export interface RedocRawOptions {
|
||||||
untrustedSpec?: boolean | string;
|
untrustedSpec?: boolean | string;
|
||||||
hideLoading?: boolean | string;
|
hideLoading?: boolean | string;
|
||||||
hideDownloadButton?: boolean | string;
|
hideDownloadButton?: boolean | string;
|
||||||
|
downloadFileName?: string;
|
||||||
|
downloadDefinitionUrl?: string;
|
||||||
disableSearch?: boolean | string;
|
disableSearch?: boolean | string;
|
||||||
onlyRequiredInSamples?: boolean | string;
|
onlyRequiredInSamples?: boolean | string;
|
||||||
showExtensions?: boolean | string | string[];
|
showExtensions?: boolean | string | string[];
|
||||||
|
@ -58,6 +60,7 @@ export interface RedocRawOptions {
|
||||||
nonce?: string;
|
nonce?: string;
|
||||||
hideFab?: boolean;
|
hideFab?: boolean;
|
||||||
minCharacterLengthToInitSearch?: number;
|
minCharacterLengthToInitSearch?: number;
|
||||||
|
showWebhookVerb?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function argValueToBoolean(val?: string | boolean, defaultValue?: boolean): boolean {
|
export function argValueToBoolean(val?: string | boolean, defaultValue?: boolean): boolean {
|
||||||
|
@ -235,6 +238,8 @@ export class RedocNormalizedOptions {
|
||||||
pathInMiddlePanel: boolean;
|
pathInMiddlePanel: boolean;
|
||||||
untrustedSpec: boolean;
|
untrustedSpec: boolean;
|
||||||
hideDownloadButton: boolean;
|
hideDownloadButton: boolean;
|
||||||
|
downloadFileName?: string;
|
||||||
|
downloadDefinitionUrl?: string;
|
||||||
disableSearch: boolean;
|
disableSearch: boolean;
|
||||||
onlyRequiredInSamples: boolean;
|
onlyRequiredInSamples: boolean;
|
||||||
showExtensions: boolean | string[];
|
showExtensions: boolean | string[];
|
||||||
|
@ -263,6 +268,7 @@ export class RedocNormalizedOptions {
|
||||||
generatedPayloadSamplesMaxDepth: number;
|
generatedPayloadSamplesMaxDepth: number;
|
||||||
hideFab: boolean;
|
hideFab: boolean;
|
||||||
minCharacterLengthToInitSearch: number;
|
minCharacterLengthToInitSearch: number;
|
||||||
|
showWebhookVerb: boolean;
|
||||||
|
|
||||||
nonce?: string;
|
nonce?: string;
|
||||||
|
|
||||||
|
@ -303,6 +309,8 @@ export class RedocNormalizedOptions {
|
||||||
this.pathInMiddlePanel = argValueToBoolean(raw.pathInMiddlePanel);
|
this.pathInMiddlePanel = argValueToBoolean(raw.pathInMiddlePanel);
|
||||||
this.untrustedSpec = argValueToBoolean(raw.untrustedSpec);
|
this.untrustedSpec = argValueToBoolean(raw.untrustedSpec);
|
||||||
this.hideDownloadButton = argValueToBoolean(raw.hideDownloadButton);
|
this.hideDownloadButton = argValueToBoolean(raw.hideDownloadButton);
|
||||||
|
this.downloadFileName = raw.downloadFileName;
|
||||||
|
this.downloadDefinitionUrl = raw.downloadDefinitionUrl;
|
||||||
this.disableSearch = argValueToBoolean(raw.disableSearch);
|
this.disableSearch = argValueToBoolean(raw.disableSearch);
|
||||||
this.onlyRequiredInSamples = argValueToBoolean(raw.onlyRequiredInSamples);
|
this.onlyRequiredInSamples = argValueToBoolean(raw.onlyRequiredInSamples);
|
||||||
this.showExtensions = RedocNormalizedOptions.normalizeShowExtensions(raw.showExtensions);
|
this.showExtensions = RedocNormalizedOptions.normalizeShowExtensions(raw.showExtensions);
|
||||||
|
@ -339,5 +347,6 @@ export class RedocNormalizedOptions {
|
||||||
this.nonce = raw.nonce;
|
this.nonce = raw.nonce;
|
||||||
this.hideFab = argValueToBoolean(raw.hideFab);
|
this.hideFab = argValueToBoolean(raw.hideFab);
|
||||||
this.minCharacterLengthToInitSearch = argValueToNumber(raw.minCharacterLengthToInitSearch) || 3;
|
this.minCharacterLengthToInitSearch = argValueToNumber(raw.minCharacterLengthToInitSearch) || 3;
|
||||||
|
this.showWebhookVerb = argValueToBoolean(raw.showWebhookVerb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ export class SpecStore {
|
||||||
private options: RedocNormalizedOptions,
|
private options: RedocNormalizedOptions,
|
||||||
) {
|
) {
|
||||||
this.parser = new OpenAPIParser(spec, specUrl, options);
|
this.parser = new OpenAPIParser(spec, specUrl, options);
|
||||||
this.info = new ApiInfoModel(this.parser);
|
this.info = new ApiInfoModel(this.parser, this.options);
|
||||||
this.externalDocs = this.parser.spec.externalDocs;
|
this.externalDocs = this.parser.spec.externalDocs;
|
||||||
this.contentItems = MenuBuilder.buildStructure(this.parser, this.options);
|
this.contentItems = MenuBuilder.buildStructure(this.parser, this.options);
|
||||||
this.securitySchemes = new SecuritySchemesModel(this.parser);
|
this.securitySchemes = new SecuritySchemesModel(this.parser);
|
||||||
|
|
|
@ -62,5 +62,80 @@ describe('Models', () => {
|
||||||
const { license = { identifier: null } } = new ApiInfoModel(parser);
|
const { license = { identifier: null } } = new ApiInfoModel(parser);
|
||||||
expect(license.identifier).toEqual('MIT');
|
expect(license.identifier).toEqual('MIT');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should correctly populate default download file name', () => {
|
||||||
|
parser.spec = {
|
||||||
|
openapi: '3.0.0',
|
||||||
|
info: {
|
||||||
|
description: 'Test description',
|
||||||
|
},
|
||||||
|
} as any;
|
||||||
|
|
||||||
|
const info = new ApiInfoModel(parser);
|
||||||
|
expect(info.downloadFileName).toEqual('openapi.json');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should correctly populate default download file is undefined when using specUrl', () => {
|
||||||
|
parser = new OpenAPIParser(
|
||||||
|
{
|
||||||
|
openapi: '3.0.0',
|
||||||
|
info: {
|
||||||
|
description: 'Test description',
|
||||||
|
},
|
||||||
|
} as any,
|
||||||
|
'/demo/openapi.yaml',
|
||||||
|
opts,
|
||||||
|
);
|
||||||
|
|
||||||
|
const info = new ApiInfoModel(parser);
|
||||||
|
expect(info.downloadFileName).toEqual(undefined);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should correctly populate download file name', () => {
|
||||||
|
parser.spec = {
|
||||||
|
info: {
|
||||||
|
description: 'Test description',
|
||||||
|
},
|
||||||
|
} as any;
|
||||||
|
|
||||||
|
const opts = new RedocNormalizedOptions({
|
||||||
|
downloadFileName: 'test.yaml',
|
||||||
|
});
|
||||||
|
|
||||||
|
const info = new ApiInfoModel(parser, opts);
|
||||||
|
expect(info.downloadFileName).toEqual('test.yaml');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should correctly populate download link', () => {
|
||||||
|
parser.spec = {
|
||||||
|
openapi: '3.0.0',
|
||||||
|
info: {
|
||||||
|
description: 'Test description',
|
||||||
|
},
|
||||||
|
} as any;
|
||||||
|
|
||||||
|
const opts = new RedocNormalizedOptions({
|
||||||
|
downloadDefinitionUrl: 'https:test.com/filename.yaml',
|
||||||
|
});
|
||||||
|
const info = new ApiInfoModel(parser, opts);
|
||||||
|
expect(info.downloadLink).toEqual('https:test.com/filename.yaml');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should correctly populate download link and download file name', () => {
|
||||||
|
parser.spec = {
|
||||||
|
openapi: '3.0.0',
|
||||||
|
info: {
|
||||||
|
description: 'Test description',
|
||||||
|
},
|
||||||
|
} as any;
|
||||||
|
|
||||||
|
const opts = new RedocNormalizedOptions({
|
||||||
|
downloadDefinitionUrl: 'https:test.com/filename.yaml',
|
||||||
|
downloadFileName: 'test.yaml',
|
||||||
|
});
|
||||||
|
const info = new ApiInfoModel(parser, opts);
|
||||||
|
expect(info.downloadLink).toEqual('https:test.com/filename.yaml');
|
||||||
|
expect(info.downloadFileName).toEqual('test.yaml');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { OpenAPIContact, OpenAPIInfo, OpenAPILicense } from '../../types';
|
import { OpenAPIContact, OpenAPIInfo, OpenAPILicense } from '../../types';
|
||||||
import { IS_BROWSER } from '../../utils/';
|
import { IS_BROWSER } from '../../utils/';
|
||||||
import { OpenAPIParser } from '../OpenAPIParser';
|
import { OpenAPIParser } from '../OpenAPIParser';
|
||||||
|
import { RedocNormalizedOptions } from '../RedocNormalizedOptions';
|
||||||
|
|
||||||
export class ApiInfoModel implements OpenAPIInfo {
|
export class ApiInfoModel implements OpenAPIInfo {
|
||||||
title: string;
|
title: string;
|
||||||
|
@ -15,7 +16,10 @@ export class ApiInfoModel implements OpenAPIInfo {
|
||||||
downloadLink?: string;
|
downloadLink?: string;
|
||||||
downloadFileName?: string;
|
downloadFileName?: string;
|
||||||
|
|
||||||
constructor(private parser: OpenAPIParser) {
|
constructor(
|
||||||
|
private parser: OpenAPIParser,
|
||||||
|
private options: RedocNormalizedOptions = new RedocNormalizedOptions({}),
|
||||||
|
) {
|
||||||
Object.assign(this, parser.spec.info);
|
Object.assign(this, parser.spec.info);
|
||||||
this.description = parser.spec.info.description || '';
|
this.description = parser.spec.info.description || '';
|
||||||
this.summary = parser.spec.info.summary || '';
|
this.summary = parser.spec.info.summary || '';
|
||||||
|
@ -30,6 +34,10 @@ export class ApiInfoModel implements OpenAPIInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
private getDownloadLink(): string | undefined {
|
private getDownloadLink(): string | undefined {
|
||||||
|
if (this.options.downloadDefinitionUrl) {
|
||||||
|
return this.options.downloadDefinitionUrl;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.parser.specUrl) {
|
if (this.parser.specUrl) {
|
||||||
return this.parser.specUrl;
|
return this.parser.specUrl;
|
||||||
}
|
}
|
||||||
|
@ -43,9 +51,9 @@ export class ApiInfoModel implements OpenAPIInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
private getDownloadFileName(): string | undefined {
|
private getDownloadFileName(): string | undefined {
|
||||||
if (!this.parser.specUrl) {
|
if (!this.parser.specUrl && !this.options.downloadDefinitionUrl) {
|
||||||
return 'swagger.json';
|
return this.options.downloadFileName || 'openapi.json';
|
||||||
}
|
}
|
||||||
return undefined;
|
return this.options.downloadFileName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ export class ExampleModel {
|
||||||
this.summary = example.summary;
|
this.summary = example.summary;
|
||||||
this.description = example.description;
|
this.description = example.description;
|
||||||
if (example.externalValue) {
|
if (example.externalValue) {
|
||||||
this.externalValueUrl = new URL(example.externalValue, parser.specUrl || '').href;
|
this.externalValueUrl = new URL(example.externalValue, parser.specUrl).href;
|
||||||
}
|
}
|
||||||
parser.exitRef(infoOrRef);
|
parser.exitRef(infoOrRef);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user