diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000..14c63f2f --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,22 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: 'type: bug' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Minimal reproducible OpenAPI snippet(if possible)** + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 00000000..041bdc52 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' + +--- + +**Describe the problem to be solved** +A clear and concise description of what problem to be solved + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. \ No newline at end of file diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 00000000..4933c4f3 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,13 @@ +## What/Why/How? + +## Reference + +## Testing + +## Screenshots (optional) + +## Check yourself + +- [ ] Code is linted +- [ ] Tested +- [ ] All new/updated code is covered with tests diff --git a/.github/sync.yml b/.github/sync.yml new file mode 100644 index 00000000..6d3a4e35 --- /dev/null +++ b/.github/sync.yml @@ -0,0 +1,6 @@ +group: + - files: + - source: docs/ + dest: docs/redoc + repos: | + Redocly/docs diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..42afcc4c --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,45 @@ +name: Publish Docker image +on: + release: + types: [published] +jobs: + push_to_registry: + name: Push Docker image to GitHub Packages + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + steps: + - name: Check out the repo + uses: actions/checkout@v2 + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Prepare + id: prep + run: | + DOCKER_IMAGE=ghcr.io/redocly/redoc/cli + VERSION=edge + if [[ $GITHUB_REF == refs/tags/* ]]; then + VERSION=${GITHUB_REF#refs/tags/} + elif [[ $GITHUB_REF == refs/heads/* ]]; then + VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g') + elif [[ $GITHUB_REF == refs/pull/* ]]; then + VERSION=pr-${{ github.event.number }} + fi + TAGS="${DOCKER_IMAGE}:${VERSION}" + if [ "${{ github.event_name }}" = "push" ]; then + TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}" + fi + echo ::set-output name=version::${VERSION} + echo ::set-output name=tags::${TAGS} + echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ') + - name: Push to GitHub Packages + uses: docker/build-push-action@v2 + with: + context: ./cli + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.prep.outputs.tags }} diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml new file mode 100644 index 00000000..ba673bd0 --- /dev/null +++ b/.github/workflows/sync.yml @@ -0,0 +1,18 @@ +name: Sync Files +on: + push: + branches: + - master + workflow_dispatch: +jobs: + sync: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@master + - name: Run GitHub File Sync + uses: Redocly/repo-file-sync-action@master + with: + GH_PAT: ${{ secrets.GH_PAT }} + COMMIT_PREFIX: "sync:" + SKIP_PR: true diff --git a/CHANGELOG.md b/CHANGELOG.md index 20c686c3..b73fb105 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,39 @@ +# [2.0.0-rc.56](https://github.com/Redocly/redoc/compare/v2.0.0-rc.53...v2.0.0-rc.56) (2021-08-11) + + +### Bug Fixes + +* handle empty object in security array ([#1678](https://github.com/Redocly/redoc/issues/1678)) ([9e1ea70](https://github.com/Redocly/redoc/commit/9e1ea703e56a71567b13d0d22e2d69945a22de4d)) +* hideLoading options in redoc standalone ([#1709](https://github.com/Redocly/redoc/issues/1709)) ([6a52a16](https://github.com/Redocly/redoc/commit/6a52a16d5b75a2955da7217c4a264f0fa8e98c89)) +* improve openapi 3.1 ([#1700](https://github.com/Redocly/redoc/issues/1700)) ([cd2d6f7](https://github.com/Redocly/redoc/commit/cd2d6f76e87c8385786a9c8e51c0d11c79d9707c)) + - show contentEncoding on fields + - crash with OpenAPI 3.1 type as array of strings in requestBody + - nullable label not shown +* nullable object's fields were missing ([#1721](https://github.com/Redocly/redoc/issues/1721)) ([ddf297b](https://github.com/Redocly/redoc/commit/ddf297b11269ef515bd62771912a5609721d5e39)) + + +### Features + +* add github action to build docker images and push to ghcr.io on release ([#1614](https://github.com/Redocly/redoc/issues/1614)) ([919a5f0](https://github.com/Redocly/redoc/commit/919a5f02fb94ca869011d5eaf63ee71b61b60150)) +* add yaml highlight ([#1684](https://github.com/Redocly/redoc/issues/1684)) ([d724440](https://github.com/Redocly/redoc/commit/d72444008533623c87f238fe8758b1dd518b89eb)) +* added localization for some labels ([#1675](https://github.com/Redocly/redoc/issues/1675)) ([ec50858](https://github.com/Redocly/redoc/commit/ec50858ec47af08c5fe553266fe3c209fba97eae)) + + +# [2.0.0-rc.55](https://github.com/Redocly/redoc/compare/v2.0.0-rc.54...v2.0.0-rc.55) (2021-07-01) + + +### Bug Fixes + +* broken linkify ([3df72fb](https://github.com/Redocly/redoc/commit/3df72fb99ff24fb9a551565b7568d96f8614ed6f)), closes [#1655](https://github.com/Redocly/redoc/issues/1655) +* fix accidentally removed onLoaded ([b41a8b4](https://github.com/Redocly/redoc/commit/b41a8b4ac714084dc25de7914fa1f99386e907e2)), closes [#1656](https://github.com/Redocly/redoc/issues/1656) + + +### Features + +* added git folder sync config ([a69f0fb](https://github.com/Redocly/redoc/commit/a69f0fb00986a04c812ab273711e8f3501b98139)) + + + # [2.0.0-rc.54](https://github.com/Redocly/redoc/compare/v2.0.0-rc.53...v2.0.0-rc.54) (2021-06-09) diff --git a/README.md b/README.md index 13287f89..81af5f37 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,7 @@ Additionally, all the 1.x releases are hosted on our GitHub Pages-based CDN **(d - [Commbox](https://www.commbox.io/api/) - [APIs.guru](https://apis.guru/api-doc/) - [FastAPI](https://github.com/tiangolo/fastapi) +- [BoxKnight](https://www.docs.boxknight.com/) ## Deployment diff --git a/cli/README.md b/cli/README.md index 32bb0e0e..bc6d8bcf 100644 --- a/cli/README.md +++ b/cli/README.md @@ -3,20 +3,29 @@ **[ReDoc](https://github.com/Redocly/redoc)'s Command Line Interface** ## Installation -You can use redoc cli by installing `redoc-cli` globally or using [npx](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b). + +You can use `redoc-cli` by installing [the package](https://www.npmjs.com/package/redoc-cli) globally, +or using [npx](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b). ## Usage -Two following commands are available: +The two following commands are available: -- `redoc-cli serve [spec]` - starts the server with `spec` rendered with ReDoc. Supports SSR mode (`--ssr`) and can watch the spec (`--watch`) -- `redoc-cli bundle [spec]` - bundles spec and ReDoc into **zero-dependency** HTML file. +- `redoc-cli serve [spec]` - starts the server with `spec` rendered with ReDoc. + Supports a server-side rendering mode (`--ssr`), + and can watch the spec (`--watch`) to automatically reload the page whenever it changes. +- `redoc-cli bundle [spec]` - bundles `spec` and ReDoc into a **zero-dependency** HTML file. Some examples: -- Bundle with main color changed to `orange`:
`$ redoc-cli bundle [spec] --options.theme.colors.primary.main=orange` -- Serve with `nativeScrollbars` option set to true:
`$ redoc-cli serve [spec] --options.nativeScrollbars` -- Bundle using custom template (check [default template](https://github.com/Redocly/redoc/blob/master/cli/template.hbs) for reference):
`$ redoc-cli bundle [spec] -t custom.hbs` -- Bundle using custom template and add custom `templateOptions`:
`$ redoc-cli bundle [spec] -t custom.hbs --templateOptions.metaDescription "Page meta description"` +- Bundle with the main color changed to `orange`:
+ `$ redoc-cli bundle [spec] --options.theme.colors.primary.main=orange` +- Serve with the `nativeScrollbars` option set to true:
+ `$ redoc-cli serve [spec] --options.nativeScrollbars` +- Bundle using a custom [Handlebars](https://handlebarsjs.com/) template + (check the [default template](https://github.com/Redocly/redoc/blob/master/cli/template.hbs) for an example):
+ `$ redoc-cli bundle [spec] -t custom.hbs` +- Bundle using a custom template and add custom `templateOptions`:
+ `$ redoc-cli bundle [spec] -t custom.hbs --templateOptions.metaDescription "Page meta description"` -For more details run `redoc-cli --help`. +For more details, run `redoc-cli --help`. diff --git a/cli/npm-shrinkwrap.json b/cli/npm-shrinkwrap.json index 4df4fbaf..117d9c06 100644 --- a/cli/npm-shrinkwrap.json +++ b/cli/npm-shrinkwrap.json @@ -1,12 +1,12 @@ { "name": "redoc-cli", - "version": "0.12.1", + "version": "0.12.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "redoc-cli", - "version": "0.12.1", + "version": "0.12.3", "license": "MIT", "dependencies": { "chokidar": "^3.5.1", @@ -17,7 +17,7 @@ "node-libs-browser": "^2.2.1", "react": "^17.0.1", "react-dom": "^17.0.1", - "redoc": "2.0.0-rc.54", + "redoc": "2.0.0-rc.56", "styled-components": "^5.3.0", "yargs": "^17.0.1" }, @@ -605,17 +605,6 @@ "resolved": "https://registry.npmjs.org/classnames/-/classnames-2.3.1.tgz", "integrity": "sha512-OlQdbZ7gLfGarSqxesMesDa5uz7KFbID8Kpq/SxIoNGDqY8lSYs0D+hhtBXhcdB3rcbXArFr7vlHheLk1voeNA==" }, - "node_modules/clipboard": { - "version": "2.0.8", - "resolved": "https://registry.npmjs.org/clipboard/-/clipboard-2.0.8.tgz", - "integrity": "sha512-Y6WO0unAIQp5bLmk1zdThRhgJt/x3ks6f30s3oE3H1mgIEU33XyQjEf8gsf6DxC7NPX8Y1SsNWjUjL/ywLnnbQ==", - "optional": true, - "dependencies": { - "good-listener": "^1.2.2", - "select": "^1.1.2", - "tiny-emitter": "^2.0.0" - } - }, "node_modules/cliui": { "version": "7.0.4", "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", @@ -782,12 +771,6 @@ "resolved": "https://registry.npmjs.org/decko/-/decko-1.2.0.tgz", "integrity": "sha1-/UPHNelnuAEzBohKVvvmZZlraBc=" }, - "node_modules/delegate": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/delegate/-/delegate-3.2.0.tgz", - "integrity": "sha512-IofjkYBZaZivn0V8nnsMJGBr4jVLxHDheKSW88PyxS5QC4Vo9ZbZVvhzlSxY87fVq3STR6r+4cGepyHkcWOQSw==", - "optional": true - }, "node_modules/des.js": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.1.tgz", @@ -976,15 +959,6 @@ "node": ">=4" } }, - "node_modules/good-listener": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/good-listener/-/good-listener-1.2.2.tgz", - "integrity": "sha1-1TswzfkxPf+33JoNR3CWqm0UXFA=", - "optional": true, - "dependencies": { - "delegate": "^3.1.2" - } - }, "node_modules/handlebars": { "version": "4.7.7", "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.7.tgz", @@ -1602,12 +1576,9 @@ "integrity": "sha512-97DXOFbQJhk71ne5/Mt6cOu6yxsSfM0QGQyl0L25Gca4yGWEGJaig7l7gbCX623VqTBNGLRLaVUCnNkcedlRSQ==" }, "node_modules/prismjs": { - "version": "1.23.0", - "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.23.0.tgz", - "integrity": "sha512-c29LVsqOaLbBHuIbsTxaKENh1N2EQBOHaWv7gkHN4dgRbxSREqDnDbtFJYdpPauS4YCplMSNCABQ6Eeor69bAA==", - "optionalDependencies": { - "clipboard": "^2.0.0" - } + "version": "1.24.1", + "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.24.1.tgz", + "integrity": "sha512-mNPsedLuk90RVJioIky8ANZEwYm5w9LcvCXrxHlwf4fNVSn8jEipMybMkWUyyF0JhnC+C4VcOVSBuHRKs1L5Ow==" }, "node_modules/process": { "version": "0.11.10", @@ -1780,9 +1751,9 @@ } }, "node_modules/redoc": { - "version": "2.0.0-rc.54", - "resolved": "https://registry.npmjs.org/redoc/-/redoc-2.0.0-rc.54.tgz", - "integrity": "sha512-xwukaWdoktkDAoQuhajekdC54+/lSLwIUqJCNSTVEjeYEuZPq2tFUj9H5SBt8/YSq5UF/zOmDQrXPWMgildQpQ==", + "version": "2.0.0-rc.56", + "resolved": "https://registry.npmjs.org/redoc/-/redoc-2.0.0-rc.56.tgz", + "integrity": "sha512-ir2TtQ2d/1FqZWIoLmUZ3qvAAnO6jg8dt0SV75TanmfCXpEABcElXWH3mtUf6qKlvgDVt40diDCVuSvyPPxkAw==", "dependencies": { "@babel/runtime": "^7.14.0", "@redocly/openapi-core": "^1.0.0-beta.50", @@ -1802,7 +1773,7 @@ "path-browserify": "^1.0.1", "perfect-scrollbar": "^1.5.1", "polished": "^4.1.3", - "prismjs": "^1.23.0", + "prismjs": "^1.24.1", "prop-types": "^15.7.2", "react-tabs": "^3.2.2", "slugify": "~1.4.7", @@ -1890,12 +1861,6 @@ "object-assign": "^4.1.1" } }, - "node_modules/select": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/select/-/select-1.1.2.tgz", - "integrity": "sha1-DnNQrN7ICxEIUoeG7B1EGNEbOW0=", - "optional": true - }, "node_modules/setimmediate": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", @@ -2122,12 +2087,6 @@ "node": ">=0.6.0" } }, - "node_modules/tiny-emitter": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/tiny-emitter/-/tiny-emitter-2.1.0.tgz", - "integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==", - "optional": true - }, "node_modules/to-arraybuffer": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz", @@ -2853,17 +2812,6 @@ "resolved": "https://registry.npmjs.org/classnames/-/classnames-2.3.1.tgz", "integrity": "sha512-OlQdbZ7gLfGarSqxesMesDa5uz7KFbID8Kpq/SxIoNGDqY8lSYs0D+hhtBXhcdB3rcbXArFr7vlHheLk1voeNA==" }, - "clipboard": { - "version": "2.0.8", - "resolved": "https://registry.npmjs.org/clipboard/-/clipboard-2.0.8.tgz", - "integrity": "sha512-Y6WO0unAIQp5bLmk1zdThRhgJt/x3ks6f30s3oE3H1mgIEU33XyQjEf8gsf6DxC7NPX8Y1SsNWjUjL/ywLnnbQ==", - "optional": true, - "requires": { - "good-listener": "^1.2.2", - "select": "^1.1.2", - "tiny-emitter": "^2.0.0" - } - }, "cliui": { "version": "7.0.4", "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", @@ -3010,12 +2958,6 @@ "resolved": "https://registry.npmjs.org/decko/-/decko-1.2.0.tgz", "integrity": "sha1-/UPHNelnuAEzBohKVvvmZZlraBc=" }, - "delegate": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/delegate/-/delegate-3.2.0.tgz", - "integrity": "sha512-IofjkYBZaZivn0V8nnsMJGBr4jVLxHDheKSW88PyxS5QC4Vo9ZbZVvhzlSxY87fVq3STR6r+4cGepyHkcWOQSw==", - "optional": true - }, "des.js": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.1.tgz", @@ -3169,15 +3111,6 @@ "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==" }, - "good-listener": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/good-listener/-/good-listener-1.2.2.tgz", - "integrity": "sha1-1TswzfkxPf+33JoNR3CWqm0UXFA=", - "optional": true, - "requires": { - "delegate": "^3.1.2" - } - }, "handlebars": { "version": "4.7.7", "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.7.tgz", @@ -3648,12 +3581,9 @@ "integrity": "sha512-97DXOFbQJhk71ne5/Mt6cOu6yxsSfM0QGQyl0L25Gca4yGWEGJaig7l7gbCX623VqTBNGLRLaVUCnNkcedlRSQ==" }, "prismjs": { - "version": "1.23.0", - "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.23.0.tgz", - "integrity": "sha512-c29LVsqOaLbBHuIbsTxaKENh1N2EQBOHaWv7gkHN4dgRbxSREqDnDbtFJYdpPauS4YCplMSNCABQ6Eeor69bAA==", - "requires": { - "clipboard": "^2.0.0" - } + "version": "1.24.1", + "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.24.1.tgz", + "integrity": "sha512-mNPsedLuk90RVJioIky8ANZEwYm5w9LcvCXrxHlwf4fNVSn8jEipMybMkWUyyF0JhnC+C4VcOVSBuHRKs1L5Ow==" }, "process": { "version": "0.11.10", @@ -3811,9 +3741,9 @@ } }, "redoc": { - "version": "2.0.0-rc.54", - "resolved": "https://registry.npmjs.org/redoc/-/redoc-2.0.0-rc.54.tgz", - "integrity": "sha512-xwukaWdoktkDAoQuhajekdC54+/lSLwIUqJCNSTVEjeYEuZPq2tFUj9H5SBt8/YSq5UF/zOmDQrXPWMgildQpQ==", + "version": "2.0.0-rc.56", + "resolved": "https://registry.npmjs.org/redoc/-/redoc-2.0.0-rc.56.tgz", + "integrity": "sha512-ir2TtQ2d/1FqZWIoLmUZ3qvAAnO6jg8dt0SV75TanmfCXpEABcElXWH3mtUf6qKlvgDVt40diDCVuSvyPPxkAw==", "requires": { "@babel/runtime": "^7.14.0", "@redocly/openapi-core": "^1.0.0-beta.50", @@ -3833,7 +3763,7 @@ "path-browserify": "^1.0.1", "perfect-scrollbar": "^1.5.1", "polished": "^4.1.3", - "prismjs": "^1.23.0", + "prismjs": "^1.24.1", "prop-types": "^15.7.2", "react-tabs": "^3.2.2", "slugify": "~1.4.7", @@ -3892,12 +3822,6 @@ "object-assign": "^4.1.1" } }, - "select": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/select/-/select-1.1.2.tgz", - "integrity": "sha1-DnNQrN7ICxEIUoeG7B1EGNEbOW0=", - "optional": true - }, "setimmediate": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", @@ -4083,12 +4007,6 @@ "setimmediate": "^1.0.4" } }, - "tiny-emitter": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/tiny-emitter/-/tiny-emitter-2.1.0.tgz", - "integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==", - "optional": true - }, "to-arraybuffer": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz", diff --git a/cli/package.json b/cli/package.json index cb55452e..379f5cfe 100644 --- a/cli/package.json +++ b/cli/package.json @@ -1,6 +1,6 @@ { "name": "redoc-cli", - "version": "0.12.1", + "version": "0.12.3", "description": "ReDoc's Command Line Interface", "main": "index.js", "bin": "index.js", @@ -19,7 +19,7 @@ "node-libs-browser": "^2.2.1", "react": "^17.0.1", "react-dom": "^17.0.1", - "redoc": "2.0.0-rc.54", + "redoc": "2.0.0-rc.56", "styled-components": "^5.3.0", "yargs": "^17.0.1" }, diff --git a/config/docker/Dockerfile b/config/docker/Dockerfile index fc7481f4..94e1762d 100644 --- a/config/docker/Dockerfile +++ b/config/docker/Dockerfile @@ -16,7 +16,8 @@ RUN npm ci --no-optional --ignore-scripts # copy only required for the build files COPY src /build/src -COPY webpack.config.ts tsconfig.json custom.d.ts /build/ +COPY webpack.config.ts tsconfig.json custom.d.ts /build/ +COPY config/webpack-utils.ts /build/config/ COPY typings/styled-patch.d.ts /build/typings/styled-patch.d.ts RUN npm run bundle:standalone diff --git a/demo/index.tsx b/demo/index.tsx index 28c89522..a92b940a 100644 --- a/demo/index.tsx +++ b/demo/index.tsx @@ -15,7 +15,7 @@ const demos = [ value: 'https://api.apis.guru/v2/specs/googleapis.com/calendar/v3/openapi.yaml', label: 'Google Calendar', }, - { value: 'https://api.apis.guru/v2/specs/slack.com/1.5.0/openapi.yaml', label: 'Slack' }, + { value: 'https://api.apis.guru/v2/specs/slack.com/1.7.0/openapi.yaml', label: 'Slack' }, { value: 'https://api.apis.guru/v2/specs/zoom.us/2.0.0/openapi.yaml', label: 'Zoom.us' }, { value: 'https://docs.graphhopper.com/openapi.json', label: 'GraphHopper' }, ]; @@ -77,7 +77,7 @@ class DemoApp extends React.Component< let proxiedUrl = specUrl; if (specUrl !== DEFAULT_SPEC) { proxiedUrl = cors - ? '\\\\cors.apis.guru/' + urlResolve(window.location.href, specUrl) + ? '\\\\cors.redoc.ly/' + urlResolve(window.location.href, specUrl) : specUrl; } return ( diff --git a/demo/openapi-3-1.yaml b/demo/openapi-3-1.yaml index c905d4d8..31063d4b 100644 --- a/demo/openapi-3-1.yaml +++ b/demo/openapi-3-1.yaml @@ -1166,6 +1166,11 @@ components: description: User status type: integer format: int32 + image: + description: User image + type: string + contentEncoding: base64 + contentMediaType: image/png xml: name: User requestBodies: diff --git a/demo/openapi.yaml b/demo/openapi.yaml index 74c16b70..c570cc60 100644 --- a/demo/openapi.yaml +++ b/demo/openapi.yaml @@ -1193,7 +1193,7 @@ x-webhooks: summary: New pet description: Information about a new pet in the systems operationId: newPet - tags: + tags: - pet requestBody: content: @@ -1202,4 +1202,4 @@ x-webhooks: $ref: "#/components/schemas/Pet" responses: "200": - description: Return a 200 status to indicate that the data was received successfully \ No newline at end of file + description: Return a 200 status to indicate that the data was received successfully diff --git a/docs/quickstart/cli.md b/docs/quickstart/cli.md new file mode 100644 index 00000000..b0f2af85 --- /dev/null +++ b/docs/quickstart/cli.md @@ -0,0 +1,112 @@ +--- +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://redoc.ly/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 + + + + + {{title}} + + + + + {{{redocHead}}} + {{#unless disableGoogleFont}}{{/unless}} + + + {{{redocHTML}}} + + +``` + +#### Serve + +Serve with the `nativeScrollbars` option set to `true`: + +```bash +redoc-cli serve openapi/dist.yaml --options.nativeScrollbars +``` diff --git a/docs/quickstart/docker.md b/docs/quickstart/docker.md new file mode 100644 index 00000000..31539fdb --- /dev/null +++ b/docs/quickstart/docker.md @@ -0,0 +1,39 @@ +--- +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. \ No newline at end of file diff --git a/docs/quickstart/html.md b/docs/quickstart/html.md new file mode 100644 index 00000000..bfc8d267 --- /dev/null +++ b/docs/quickstart/html.md @@ -0,0 +1,214 @@ +--- +title: Using the Redoc HTML element +--- + +# Using the Redoc HTML element + +## TL;DR final code example + +```html + + + + Redoc + + + + + + + + + + + + + + +``` + +:::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 OpenAPI CLI + +Redocly OpenAPI CLI is an open source command-line tool that includes a command +for simulating an HTTP server to provide a preview of your OpenAPI definition locally. + +If you have [OpenAPI CLI](https://redoc.ly/docs/cli/#installation-and-usage) installed, `cd` into your +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 + +``` + +### Node modules link + +To reference the Redoc script with a node modules link: + +```html + +``` + +## Step 3 - Add the element + +You can add the 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 element with the `spec-url` attribute: + +```html + +``` + +#### Examples + +```html + +``` + +You can also use a local file (JSON or YAML) in your project, for instance: + +```html + +``` + +### Using a Redoc object + +To add the 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://redoc.ly/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 + +``` + +You can also use a local file (JSON or YAML) in your project, for instance: + +```html + +``` \ No newline at end of file diff --git a/docs/quickstart/intro.md b/docs/quickstart/intro.md new file mode 100644 index 00000000..e23f9d00 --- /dev/null +++ b/docs/quickstart/intro.md @@ -0,0 +1,44 @@ +--- +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://redoc.ly/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. diff --git a/docs/quickstart/react.md b/docs/quickstart/react.md new file mode 100644 index 00000000..ebc19845 --- /dev/null +++ b/docs/quickstart/react.md @@ -0,0 +1,78 @@ +--- +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 + +``` + +Or you can pass your OpenAPI definition as an object, using the following format: + +```js + +``` + +## Optional - Pass options + +Options can be passed into the RedocStandalone component to alter how it renders. + +For example: + +```js + +``` + +For more information on configuration options, refer to the +[Configuration options for Reference docs](https://redoc.ly/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 + { + if (!error) { + console.log('Yay!'); + } + }} +/> +``` diff --git a/docs/sidebars.yaml b/docs/sidebars.yaml new file mode 100644 index 00000000..2189f25b --- /dev/null +++ b/docs/sidebars.yaml @@ -0,0 +1,13 @@ +redoc: + - group: Quickstart + expanded: false + page: redoc/quickstart/intro.md + pages: + - label: HTML element + page: redoc/quickstart/html.md + - label: React component + page: redoc/quickstart/react.md + - label: Docker image + page: redoc/quickstart/docker.md + - label: Command-line interface + page: redoc/quickstart/cli.md \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 35a720d2..73cfe473 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { "name": "redoc", - "version": "2.0.0-rc.54", + "version": "2.0.0-rc.56", "lockfileVersion": 2, "requires": true, "packages": { "": { - "version": "2.0.0-rc.54", + "version": "2.0.0-rc.56", "license": "MIT", "dependencies": { "@babel/runtime": "^7.14.0", @@ -26,7 +26,7 @@ "path-browserify": "^1.0.1", "perfect-scrollbar": "^1.5.1", "polished": "^4.1.3", - "prismjs": "^1.23.0", + "prismjs": "^1.24.1", "prop-types": "^15.7.2", "react-tabs": "^3.2.2", "slugify": "~1.4.7", @@ -5186,17 +5186,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/clipboard": { - "version": "2.0.8", - "resolved": "https://registry.npmjs.org/clipboard/-/clipboard-2.0.8.tgz", - "integrity": "sha512-Y6WO0unAIQp5bLmk1zdThRhgJt/x3ks6f30s3oE3H1mgIEU33XyQjEf8gsf6DxC7NPX8Y1SsNWjUjL/ywLnnbQ==", - "optional": true, - "dependencies": { - "good-listener": "^1.2.2", - "select": "^1.1.2", - "tiny-emitter": "^2.0.0" - } - }, "node_modules/cliui": { "version": "7.0.4", "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", @@ -6686,12 +6675,6 @@ "node": ">=0.4.0" } }, - "node_modules/delegate": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/delegate/-/delegate-3.2.0.tgz", - "integrity": "sha512-IofjkYBZaZivn0V8nnsMJGBr4jVLxHDheKSW88PyxS5QC4Vo9ZbZVvhzlSxY87fVq3STR6r+4cGepyHkcWOQSw==", - "optional": true - }, "node_modules/delegates": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", @@ -9589,15 +9572,6 @@ "node": ">= 4" } }, - "node_modules/good-listener": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/good-listener/-/good-listener-1.2.2.tgz", - "integrity": "sha1-1TswzfkxPf+33JoNR3CWqm0UXFA=", - "optional": true, - "dependencies": { - "delegate": "^3.1.2" - } - }, "node_modules/graceful-fs": { "version": "4.2.6", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.6.tgz", @@ -15988,12 +15962,9 @@ } }, "node_modules/prismjs": { - "version": "1.23.0", - "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.23.0.tgz", - "integrity": "sha512-c29LVsqOaLbBHuIbsTxaKENh1N2EQBOHaWv7gkHN4dgRbxSREqDnDbtFJYdpPauS4YCplMSNCABQ6Eeor69bAA==", - "optionalDependencies": { - "clipboard": "^2.0.0" - } + "version": "1.24.1", + "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.24.1.tgz", + "integrity": "sha512-mNPsedLuk90RVJioIky8ANZEwYm5w9LcvCXrxHlwf4fNVSn8jEipMybMkWUyyF0JhnC+C4VcOVSBuHRKs1L5Ow==" }, "node_modules/process": { "version": "0.11.10", @@ -17029,12 +17000,6 @@ "url": "https://opencollective.com/webpack" } }, - "node_modules/select": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/select/-/select-1.1.2.tgz", - "integrity": "sha1-DnNQrN7ICxEIUoeG7B1EGNEbOW0=", - "optional": true - }, "node_modules/select-hose": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/select-hose/-/select-hose-2.0.0.tgz", @@ -18755,12 +18720,6 @@ "integrity": "sha512-eHY7nBftgThBqOyHGVN+l8gF0BucP09fMo0oO/Lb0w1OF80dJv+lDVpXG60WMQvkcxAkNybKsrEIE3ZtKGmPrA==", "dev": true }, - "node_modules/tiny-emitter": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/tiny-emitter/-/tiny-emitter-2.1.0.tgz", - "integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==", - "optional": true - }, "node_modules/tmp": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz", @@ -25034,17 +24993,6 @@ "string-width": "^4.2.0" } }, - "clipboard": { - "version": "2.0.8", - "resolved": "https://registry.npmjs.org/clipboard/-/clipboard-2.0.8.tgz", - "integrity": "sha512-Y6WO0unAIQp5bLmk1zdThRhgJt/x3ks6f30s3oE3H1mgIEU33XyQjEf8gsf6DxC7NPX8Y1SsNWjUjL/ywLnnbQ==", - "optional": true, - "requires": { - "good-listener": "^1.2.2", - "select": "^1.1.2", - "tiny-emitter": "^2.0.0" - } - }, "cliui": { "version": "7.0.4", "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", @@ -26202,12 +26150,6 @@ "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", "dev": true }, - "delegate": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/delegate/-/delegate-3.2.0.tgz", - "integrity": "sha512-IofjkYBZaZivn0V8nnsMJGBr4jVLxHDheKSW88PyxS5QC4Vo9ZbZVvhzlSxY87fVq3STR6r+4cGepyHkcWOQSw==", - "optional": true - }, "delegates": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", @@ -28470,15 +28412,6 @@ } } }, - "good-listener": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/good-listener/-/good-listener-1.2.2.tgz", - "integrity": "sha1-1TswzfkxPf+33JoNR3CWqm0UXFA=", - "optional": true, - "requires": { - "delegate": "^3.1.2" - } - }, "graceful-fs": { "version": "4.2.6", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.6.tgz", @@ -33297,12 +33230,9 @@ } }, "prismjs": { - "version": "1.23.0", - "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.23.0.tgz", - "integrity": "sha512-c29LVsqOaLbBHuIbsTxaKENh1N2EQBOHaWv7gkHN4dgRbxSREqDnDbtFJYdpPauS4YCplMSNCABQ6Eeor69bAA==", - "requires": { - "clipboard": "^2.0.0" - } + "version": "1.24.1", + "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.24.1.tgz", + "integrity": "sha512-mNPsedLuk90RVJioIky8ANZEwYm5w9LcvCXrxHlwf4fNVSn8jEipMybMkWUyyF0JhnC+C4VcOVSBuHRKs1L5Ow==" }, "process": { "version": "0.11.10", @@ -34124,12 +34054,6 @@ "ajv-keywords": "^3.5.2" } }, - "select": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/select/-/select-1.1.2.tgz", - "integrity": "sha1-DnNQrN7ICxEIUoeG7B1EGNEbOW0=", - "optional": true - }, "select-hose": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/select-hose/-/select-hose-2.0.0.tgz", @@ -35533,12 +35457,6 @@ "integrity": "sha512-eHY7nBftgThBqOyHGVN+l8gF0BucP09fMo0oO/Lb0w1OF80dJv+lDVpXG60WMQvkcxAkNybKsrEIE3ZtKGmPrA==", "dev": true }, - "tiny-emitter": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/tiny-emitter/-/tiny-emitter-2.1.0.tgz", - "integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==", - "optional": true - }, "tmp": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz", diff --git a/package.json b/package.json index 4c28fd58..6f57959e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "redoc", - "version": "2.0.0-rc.54", + "version": "2.0.0-rc.56", "description": "ReDoc", "repository": { "type": "git", @@ -163,7 +163,7 @@ "path-browserify": "^1.0.1", "perfect-scrollbar": "^1.5.1", "polished": "^4.1.3", - "prismjs": "^1.23.0", + "prismjs": "^1.24.1", "prop-types": "^15.7.2", "react-tabs": "^3.2.2", "slugify": "~1.4.7", diff --git a/src/common-elements/linkify.tsx b/src/common-elements/linkify.tsx index 5fa31afc..0b059968 100644 --- a/src/common-elements/linkify.tsx +++ b/src/common-elements/linkify.tsx @@ -39,9 +39,9 @@ const isModifiedEvent = (event) => export function Link(props: { to: string; className?: string; children?: any }) { const store = React.useContext(StoreContext); const clickHandler = React.useCallback( - (event) => { + (event: React.MouseEvent) => { if (!store) return; - navigate(store.menu.history, event); + navigate(store.menu.history, event, props.to); }, [store], ); @@ -60,14 +60,14 @@ export function Link(props: { to: string; className?: string; children?: any }) ); } -function navigate(history: HistoryService, event) { +function navigate(history: HistoryService, event: React.MouseEvent, to: string) { if ( !event.defaultPrevented && // onClick prevented default event.button === 0 && // ignore everything but left clicks !isModifiedEvent(event) // ignore clicks with modifier keys ) { event.preventDefault(); - history.replace(this.props.to); + history.replace(to); } } diff --git a/src/components/ApiInfo/ApiInfo.tsx b/src/components/ApiInfo/ApiInfo.tsx index ae4b4b20..6debaf7e 100644 --- a/src/components/ApiInfo/ApiInfo.tsx +++ b/src/components/ApiInfo/ApiInfo.tsx @@ -14,6 +14,7 @@ import { InfoSpanBox, InfoSpanBoxWrap, } from './styled.elements'; +import { l } from '../../services/Labels'; export interface ApiInfoProps { store: AppStore; @@ -79,14 +80,14 @@ export class ApiInfo extends React.Component { {!hideDownloadButton && (

- Download OpenAPI specification: + {l('downloadSpecification')}: - Download + {l('download')}

)} diff --git a/src/components/Fields/FieldDetails.tsx b/src/components/Fields/FieldDetails.tsx index 9ac6cea2..1aad8c61 100644 --- a/src/components/Fields/FieldDetails.tsx +++ b/src/components/Fields/FieldDetails.tsx @@ -59,7 +59,7 @@ export class FieldDetails extends React.PureComponent; + renderedExamples = ; } } @@ -76,6 +76,20 @@ export class FieldDetails extends React.PureComponent )} + {schema.contentEncoding && ( + + {' '}< + {schema.contentEncoding} + >{' '} + + )} + {schema.contentMediaType && ( + + {' '}< + {schema.contentMediaType} + >{' '} + + )} {schema.title && !hideSchemaTitles && ({schema.title}) } {schema.pattern && !hideSchemaPattern && ( @@ -110,7 +124,7 @@ export class FieldDetails extends React.PureComponent )} {(renderDiscriminatorSwitch && renderDiscriminatorSwitch(this.props)) || null} - {field.const && () || null} + {field.const && () || null} ); } diff --git a/src/components/Parameters/Parameters.tsx b/src/components/Parameters/Parameters.tsx index 17ab9c48..eb3d2d61 100644 --- a/src/components/Parameters/Parameters.tsx +++ b/src/components/Parameters/Parameters.tsx @@ -69,13 +69,14 @@ function DropdownWithinHeader(props) { export function BodyContent(props: { content: MediaContentModel; description?: string }): JSX.Element { const { content, description } = props; + const { isRequestType } = content; return ( {({ schema }) => { return ( <> {description !== undefined && } - + ); }} diff --git a/src/components/RedocStandalone.tsx b/src/components/RedocStandalone.tsx index a4c2837c..40bf73cb 100644 --- a/src/components/RedocStandalone.tsx +++ b/src/components/RedocStandalone.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; -import { RedocNormalizedOptions, RedocRawOptions } from '../services/RedocNormalizedOptions'; +import { argValueToBoolean, RedocNormalizedOptions, RedocRawOptions } from '../services/RedocNormalizedOptions'; import { ErrorBoundary } from './ErrorBoundary'; import { Loading } from './Loading/Loading'; import { Redoc } from './Redoc/Redoc'; @@ -15,7 +15,7 @@ export interface RedocStandaloneProps { export const RedocStandalone = function (props: RedocStandaloneProps) { const { spec, specUrl, options = {}, onLoaded } = props; - const hideLoading = options.hideLoading !== undefined; + const hideLoading = argValueToBoolean(options.hideLoading, false); const normalizedOpts = new RedocNormalizedOptions(options); diff --git a/src/components/RequestSamples/RequestSamples.tsx b/src/components/RequestSamples/RequestSamples.tsx index 89b12d74..7a06d89f 100644 --- a/src/components/RequestSamples/RequestSamples.tsx +++ b/src/components/RequestSamples/RequestSamples.tsx @@ -6,6 +6,7 @@ import { SourceCodeWithCopy } from '../SourceCode/SourceCode'; import { RightPanelHeader, Tab, TabList, TabPanel, Tabs } from '../../common-elements'; import { OptionsContext } from '../OptionsProvider'; +import { l } from '../../services/Labels'; export interface RequestSamplesProps { operation: OperationModel; @@ -26,7 +27,7 @@ export class RequestSamples extends React.Component { return ( (hasSamples && (
- Request samples + {l('requestSamples')}