mirror of
https://github.com/Redocly/redoc.git
synced 2025-08-06 13:20:19 +03:00
Merge remote-tracking branch 'origin/master' into raghavi92/master
This commit is contained in:
commit
9176a04674
22
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
22
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
|
@ -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.
|
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
|
@ -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.
|
13
.github/pull_request_template.md
vendored
Normal file
13
.github/pull_request_template.md
vendored
Normal file
|
@ -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
|
42
.github/workflows/demo-deploy-s3.yml
vendored
42
.github/workflows/demo-deploy-s3.yml
vendored
|
@ -1,42 +0,0 @@
|
|||
name: Redoc demo CI/CD
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- v[0-9]*.[0-9]*.[0-9]*
|
||||
|
||||
jobs:
|
||||
build-and-unit:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- run: npm ci
|
||||
- run: npm run bundle
|
||||
- run: npm test
|
||||
deploy:
|
||||
needs: build-and-unit
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: cache node modules
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
|
||||
key: npm-${{ hashFiles('package-lock.json') }}
|
||||
restore-keys: |
|
||||
npm-${{ hashFiles('package-lock.json') }}
|
||||
npm-
|
||||
- name: Configure AWS Credentials
|
||||
uses: aws-actions/configure-aws-credentials@v1
|
||||
with:
|
||||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
aws-region: us-east-1
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
- name: Build package
|
||||
run: npm run build:demo
|
||||
- name: Deploy to S3 bucket
|
||||
run: npm run deploy:demo
|
||||
- name: Invalidate
|
||||
run: aws cloudfront create-invalidation --distribution-id ${{ secrets.CF_DEMO_DISTRIBUTION_ID }} --paths "/*"
|
12
.github/workflows/e2e-tests.yml
vendored
Normal file
12
.github/workflows/e2e-tests.yml
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
name: Tests e2e
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
build-and-e2e:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: npm ci
|
||||
- run: npm run bundle
|
||||
- run: npm run e2e
|
45
.github/workflows/main.yml
vendored
Normal file
45
.github/workflows/main.yml
vendored
Normal file
|
@ -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 }}
|
115
.github/workflows/publish-cli.yml
vendored
Normal file
115
.github/workflows/publish-cli.yml
vendored
Normal file
|
@ -0,0 +1,115 @@
|
|||
name: Publish cli
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- v[0-9]*.[0-9]*.[0-9]*
|
||||
|
||||
|
||||
jobs:
|
||||
bundle:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v2
|
||||
- name: Cache node modules
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
|
||||
key: npm-${{ hashFiles('package-lock.json') }}
|
||||
restore-keys: |
|
||||
npm-${{ hashFiles('package-lock.json') }}
|
||||
npm-
|
||||
- run: npm ci
|
||||
- run: npm run bundle
|
||||
- name: Store bundle artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: bundles-cli
|
||||
path: bundles
|
||||
retention-days: 1
|
||||
unit-tests:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- run: npm ci
|
||||
- run: npm test
|
||||
e2e-tests:
|
||||
needs: [bundle]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- run: npm ci
|
||||
- name: Download bundled artifact
|
||||
uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: bundles
|
||||
path: bundles-cli
|
||||
- run: npm run e2e
|
||||
bundle-cli:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v2
|
||||
- name: Cache node modules
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.npm
|
||||
key: npm-${{ hashFiles('package-lock.json') }}
|
||||
restore-keys: |
|
||||
npm-${{ hashFiles('package-lock.json') }}
|
||||
npm-
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
- name: Bundle
|
||||
run: npm run compile:cli
|
||||
- name: Store bundle artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: cli
|
||||
path: cli
|
||||
retention-days: 1
|
||||
check-version-cli:
|
||||
name: Check Version
|
||||
runs-on: ubuntu-latest
|
||||
needs: [bundle-cli, unit-tests, e2e-tests]
|
||||
outputs:
|
||||
changed: ${{ steps.check.outputs.changed }}
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v2
|
||||
- name: Check if version has been updated
|
||||
id: check
|
||||
uses: EndBug/version-check@v2.0.1
|
||||
with:
|
||||
file-name: ./cli/package.json
|
||||
file-url: https://unpkg.com/redoc-cli/package.json
|
||||
static-checking: localIsNew
|
||||
publish-cli:
|
||||
needs: [ check-version-cli ]
|
||||
if: needs.check-version-cli.outputs.changed == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: "14.x"
|
||||
- uses: actions/checkout@v2
|
||||
- name: Download cli bundled artifact
|
||||
uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: cli
|
||||
path: cli
|
||||
- name: Cache node modules
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
|
||||
key: npm-${{ hashFiles('package-lock.json') }}
|
||||
restore-keys: |
|
||||
npm-${{ hashFiles('package-lock.json') }}
|
||||
npm-
|
||||
- name: Publish to NPM
|
||||
run: cd cli/ && npm publish
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
100
.github/workflows/publish.yml
vendored
Normal file
100
.github/workflows/publish.yml
vendored
Normal file
|
@ -0,0 +1,100 @@
|
|||
name: Publish
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- v[0-9]*.[0-9]*.[0-9]*
|
||||
|
||||
jobs:
|
||||
bundle:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v2
|
||||
- name: Cache node modules
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
|
||||
key: npm-${{ hashFiles('package-lock.json') }}
|
||||
restore-keys: |
|
||||
npm-${{ hashFiles('package-lock.json') }}
|
||||
npm-
|
||||
- run: npm ci
|
||||
- run: npm run bundle
|
||||
- name: Store bundle artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: bundles
|
||||
path: bundles
|
||||
retention-days: 1
|
||||
unit-tests:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- run: npm ci
|
||||
- run: npm test
|
||||
e2e-tests:
|
||||
needs: [bundle]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- run: npm ci
|
||||
- name: Download bundled artifact
|
||||
uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: bundles
|
||||
path: bundles
|
||||
- run: npm run e2e
|
||||
deploy-demo:
|
||||
needs: [bundle, unit-tests, e2e-tests]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Configure AWS Credentials
|
||||
uses: aws-actions/configure-aws-credentials@v1
|
||||
with:
|
||||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
aws-region: us-east-1
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
- name: Download bundled artifacts
|
||||
uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: bundles
|
||||
path: bundles
|
||||
- name: Build package
|
||||
run: npm run build:demo
|
||||
- name: Deploy to S3 bucket
|
||||
run: npm run deploy:demo
|
||||
- name: Invalidate
|
||||
run: aws cloudfront create-invalidation --distribution-id ${{ secrets.CF_DEMO_DISTRIBUTION_ID }} --paths "/*"
|
||||
publish:
|
||||
needs: [bundle, unit-tests, e2e-tests]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: "14.x"
|
||||
- uses: actions/checkout@v2
|
||||
- name: Download bundled artifacts
|
||||
uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: bundles
|
||||
path: bundles
|
||||
- name: Cache node modules
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
|
||||
key: npm-${{ hashFiles('package-lock.json') }}
|
||||
restore-keys: |
|
||||
npm-${{ hashFiles('package-lock.json') }}
|
||||
npm-
|
||||
- name: Before deploy
|
||||
run: npm run declarations
|
||||
- name: Publish to NPM
|
||||
run: npm publish
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
- name: After script
|
||||
run: cat ./coverage/lcov.info | coveralls
|
2
.github/workflows/sync.yml
vendored
2
.github/workflows/sync.yml
vendored
|
@ -14,3 +14,5 @@ jobs:
|
|||
uses: Redocly/repo-file-sync-action@master
|
||||
with:
|
||||
GH_PAT: ${{ secrets.GH_PAT }}
|
||||
COMMIT_PREFIX: "sync:"
|
||||
SKIP_PR: true
|
||||
|
|
2
.github/workflows/unit-tests.yml
vendored
2
.github/workflows/unit-tests.yml
vendored
|
@ -9,4 +9,4 @@ jobs:
|
|||
- uses: actions/checkout@v1
|
||||
- run: npm ci
|
||||
- run: npm run bundle
|
||||
- run: npm test
|
||||
- run: npm test
|
32
.travis.yml
32
.travis.yml
|
@ -1,32 +0,0 @@
|
|||
language: node_js
|
||||
node_js:
|
||||
- '12'
|
||||
cache:
|
||||
directories:
|
||||
- "~/.cache"
|
||||
env:
|
||||
global:
|
||||
- GH_REF: github.com/Redocly/redoc.git
|
||||
- GIT_AUTHOR_EMAIL: redoc-bot@users.noreply.github.com
|
||||
- GIT_AUTHOR_NAME: RedocBot
|
||||
- secure: apiavCfCQngL9Een1m7MIXMf3bqO3rY4YY59TMBl/yFKi80CEsHPHhgVUkl6hC+aM5PeBt/vgjh37rHMX31j/pcSZ4Z8SO/4Bwr36iHfhSxSEuAQog8P07qWqH7wYYWGIVmF682stgl0fYF+GN92sx/6edFVzsWVECf2G7imtICKSTbhKGm3Dhn2JwGnhD7eyfgZ33omgiaswumdu0xABoXDfqSZR+16fC4Ap5rhv3fXO9ndvRNy1STn376nT+my6e86UrQL4aS/S+HNHgIe1BUs+5cOp6Jgw6t0ie7phY0EAiECsRxy9K4e3Dctv9m6+Wma4+vy65MS0zGyrqey6oyV4l827sCOjrD1qcqc9bX6FlMSouVoNfE4ZjINNAbgigTaiLSoDSPcf5I5smkkM2ezzFOMSZwZxNdaNL2LKb97vc8m/ZUkv0sKZyT7oqVL7aJweEivsSHj5l2KR8Z7XrVB1y2eI6GvyTSa/d+CL4dSRzjh8+IRN047YBrdTKD5IkdT0upfoBu14WPUfFmLKxX+iMCslXRWb6kwojhrWNYmZvL65KRAzJ6+eIPDG/W5QUOpYyYT77bLlBQjVo6NmVvl9v3HMECq9CHH0ivKFBGPiKMOx7cJkTax3FuyznOW2WCXB9kTb5Zk9toaiNlSp9L6ll/h2Eyxa6n6sWUgmmM=
|
||||
- secure: vVRg9BKGBwF2MbXQnEccFL+XW0/7RaBmge9k7jbGYScBwkP3XjnQ/Xaj0cvTz2CM2EqXsbpwfvr4Jo+enW/E3MGy5RiEzv5hUe/jIFRR0gfAFbZxSTvg5xiFhTDffqQk0fncO4jXu+wPO5lZ2CMRWzyXz3i1MZhjMcAgoDr1+TRss/EGXLNHxr2RM88tpUW0fV2prIRoyGqhCgnYZtrm7hmr41Ej+itg1MqZLml/Rjkt3KsNgI+z0O5Qn3QSAO8GtPZqeftQxAjevOmxZGcssxY8EJvqbjAujr4y51WncXpEmCRPSY2J9R5+fkgZurqwnJapbQpjwKYemok3ps7EHg2gWkAlmPdQO4LKpbffGkM/o5b+8+HdIuQZugsSWQD9hUSftTAFLcfA1isi7V2lHE1m8bX/vk9zIyDdcPSwIaFe9y+w3PexwFmTjPLq+nia/UY2kARFZMEIFAJby6gkA70DcAJ50QOM86InJu5DSzGbIssgTGAXCn0TPPyGveaurVLw8x61j3yh8LDF46gUHey3rqv6WjpCM9h/vg7X/gq5ve/5Q2KHscUKfs/sA53Mt7qPeqRZY1QCaaRjzqJO/ZraHqWWeKmPKaWhPGR0kYEnkvB+K9GZ+HNSWCltjCO4SJ1xeEl7CRqQxAwdiMATF5SKqyiC+bn5oc35mFgbRF8=
|
||||
- secure: ela1tn4wkJQZ8O4iv+4pIZi5cebxeCStVF1tEUe6qa6WWgJYVXmS2tEv3QQ36NUBFrP58Y6yl10XguPnvj/2BCqcZI4FUBHh3BfiBoUtXxDCVKI5LtlniNiOFGUwfzEeYka8T51zFlcUXSCCaxHkRZbmBsIzeJ39UwTi5fy0qwLv9GgL0czhwm8I8sZ8gyWdGmqpXNFEsb9JP4ZA3mw2qpWkGpGAqQPD9XSCkU3LmX1/ltwsBMAgGYKLLo7vU8d5KV2c8L1Gnxfl6BvfmqUD/dsas/1rnk08rU2nez5ekuQa2tJRkDLOv8bqvrGRLjHSUa3yPuisC6SsDGSU7/3DcozZyYsz7WQ6WI8tYabyjqqeJTF1N8a5T3IbZaZNV1J4JHOO9Cb/y7gIg4edANg6tbe7MzZpdEPRBnw6OkdTdirpNsWQ/jnfpY1hn6mraQZz/q8yaz3W21NjbBJhVnvfh5gWLKQ3YAAziCBhmmrThFhUu0czz+G920MuFo477TBcxvlrE7CaNJ0Q6yYkDehEPOv3jvEs1QVHPwuRrlaLTbBhrlTICKZ58gdX30O8N4i0Xgp/v6qrC03bplnMQc8E/uC61wcVLJixnlZVp8FODpUvPjsxVFkpuNSOIAaiqcERmoiPXx05Epzmr78hjU5rYCx/1MmVoeB4gs9YO+4guD4=
|
||||
addons:
|
||||
chrome: stable
|
||||
apt:
|
||||
packages:
|
||||
- libgconf-2-4
|
||||
before_script: npm run bundle
|
||||
script: npm test && ([ "${TRAVIS_PULL_REQUEST}" = "false" ] && npm run e2e-ci || npm
|
||||
run e2e)
|
||||
after_script: cat ./coverage/lcov.info | coveralls
|
||||
before_deploy: npm run compile:cli && npm run declarations
|
||||
deploy:
|
||||
- provider: npm
|
||||
skip_cleanup: true
|
||||
email: gotsijroman@gmail.com
|
||||
tag: next
|
||||
api_key: "$NPM_TOKEN"
|
||||
on:
|
||||
tags: true
|
21
CHANGELOG.md
21
CHANGELOG.md
|
@ -1,3 +1,24 @@
|
|||
# [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)
|
||||
|
||||
|
||||
|
|
277
README.md
277
README.md
|
@ -1,62 +1,118 @@
|
|||
<div align="center">
|
||||
<img alt="ReDoc logo" src="https://raw.githubusercontent.com/Redocly/redoc/master/docs/images/redoc-logo.png" width="400px" />
|
||||
<img alt="Redoc logo" src="https://raw.githubusercontent.com/Redocly/redoc/master//docs/images/redoc.png" width="400px" />
|
||||
|
||||
**OpenAPI/Swagger-generated API Reference Documentation**
|
||||
# Generate interactive API documentation from OpenAPI definitions
|
||||
|
||||
[](https://travis-ci.com/Redocly/redoc) [](https://coveralls.io/github/Redocly/redoc?branch=master) [](https://david-dm.org/Redocly/redoc) [](https://david-dm.org/Redocly/redoc#info=devDependencies) [](https://www.npmjs.com/package/redoc) [](https://github.com/Redocly/redoc/blob/master/LICENSE)
|
||||
|
||||
[](https://cdn.jsdelivr.net/npm/redoc/bundles/redoc.standalone.js) [](https://www.npmjs.com/package/redoc) [](https://www.jsdelivr.com/package/npm/redoc) [](https://hub.docker.com/r/redocly/redoc/)
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
**This is README for `2.0` version of ReDoc (React based). README for `1.x` version is on the branch [v1.x](https://github.com/Redocly/redoc/tree/v1.x)**
|
||||
**This is the README for the `2.x` version of Redoc (React-based).**
|
||||
**The README for the `1.x` version is on the [v1.x](https://github.com/Redocly/redoc/tree/v1.x) branch**
|
||||
|
||||
## About Redoc
|
||||
|
||||

|
||||
Redoc is an open-source tool for generating documentation from OpenAPI (fka Swagger) definitions.
|
||||
|
||||
## [Live demo](http://redocly.github.io/redoc/)
|
||||
By default Redoc offers a three-panel, responsive layout:
|
||||
|
||||
[<img alt="Deploy to Github" src="http://i.imgur.com/YZmaqk3.png" height="60px">](https://github.com/Rebilly/generator-openapi-repo#generator-openapi-repo--) [<img alt="ReDoc as a service" src="http://i.imgur.com/edqdCv6.png" height="60px">](https://redoc.ly) [<img alt="Customization services" src="http://i.imgur.com/c4sUF7M.png" height="60px">](https://redoc.ly/#services)
|
||||
- The left panel contains a search bar and navigation menu.
|
||||
- The central panel contains the documentation.
|
||||
- The right panel contains request and response examples.
|
||||
|
||||

|
||||
|
||||
## Live demo
|
||||
|
||||
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 **TRY IT**.
|
||||
|
||||
## Redoc vs. Reference vs. Portals
|
||||
|
||||
Redoc is Redocly's community-edition product. Looking for something more?
|
||||
Checkout the following feature comparison of Redocly's premium products versus Redoc:
|
||||
|
||||
| Features | Redoc | Reference | Portals |
|
||||
|------------------------------|:---------:|:---------:|:-----------:|
|
||||
| **Specs** | | | |
|
||||
| Swagger 2.0 | √ | √ | √ |
|
||||
| OpenAPI 3.0 | √ | √ | √ |
|
||||
| OpenAPI 3.1 | √ (basic) | √ | √ |
|
||||
| | | | |
|
||||
| **Theming** | | | |
|
||||
| Fonts/colors | √ | √ | √ |
|
||||
| Extra theme options | | √ | √ |
|
||||
| | | | |
|
||||
| **Performance** | | | |
|
||||
| Pagination | | √ | √ |
|
||||
| Search (enhanced) | | √ | √ |
|
||||
| Search (server-side) | | | √ |
|
||||
| | | | |
|
||||
| **Multiple APIs** | | | |
|
||||
| Multiple versions | | √ | √ |
|
||||
| Multiple APIs | | | √ |
|
||||
| API catalog | | | √ |
|
||||
| | | | |
|
||||
| **Additional features** | | | |
|
||||
| Try-it console | | √ | √ |
|
||||
| Automated code samples | | √ | √ |
|
||||
| Deep links | | √ | √ |
|
||||
| More SEO control | | | √ |
|
||||
| Contextual docs | | | √ |
|
||||
| Landing pages | | | √ |
|
||||
| React hooks for more control | | | √ |
|
||||
| Personalization | | | √ |
|
||||
| Analytics integrations | | | √ |
|
||||
| Feedback | | | Coming Soon |
|
||||
|
||||
Refer to the Redocly's documentation for more information on these products:
|
||||
|
||||
- [Portals](https://redoc.ly/docs/developer-portal/introduction/)
|
||||
- [Reference](https://redoc.ly/docs/api-reference-docs/getting-started/)
|
||||
- [Redoc](https://redoc.ly/docs/redoc/quickstart/intro/)
|
||||
|
||||
## Features
|
||||
- Extremely easy deployment
|
||||
- [redoc-cli](https://github.com/Redocly/redoc/blob/master/cli/README.md) with ability to bundle your docs into **zero-dependency** HTML file
|
||||
- Server Side Rendering ready
|
||||
- The widest OpenAPI v2.0 features support (yes, it supports even `discriminator`) <br>
|
||||

|
||||
- OpenAPI 3.0 support
|
||||
- Basic OpenAPI 3.1 support
|
||||
- Neat **interactive** documentation for nested objects <br>
|
||||

|
||||
- Code samples support (via vendor extension) <br>
|
||||

|
||||
- Responsive three-panel design with menu/scrolling synchronization
|
||||
- Integrate API Introduction into side menu - ReDoc takes advantage of markdown headings from OpenAPI description field. It pulls them into side menu and also supports deep linking.
|
||||
- High-level grouping in side-menu via [`x-tagGroups`](docs/redoc-vendor-extensions.md#x-tagGroups) vendor extension
|
||||
- Simple integration with `create-react-app` ([sample](https://github.com/APIs-guru/create-react-app-redoc))
|
||||
- Branding/customizations via [`theme` option](#redoc-options-object)
|
||||
- [Multiple deployment options](https://redoc.ly/docs/redoc/quickstart/intro/)
|
||||
- [Server-side rendering (SSR) ready](https://redoc.ly/docs/redoc/quickstart/cli/#redoc-cli-commands)
|
||||
- Ability to integrate your API introduction into the side menu
|
||||
- [Simple integration with `create-react-app`](https://redoc.ly/docs/redoc/quickstart/react/)
|
||||
|
||||
## Roadmap
|
||||
- [x] ~~[OpenAPI v3.0 support](https://github.com/Redocly/redoc/issues/312)~~
|
||||
- [x] ~~performance optimizations~~
|
||||
- [x] ~~better navigation (menu improvements + search)~~
|
||||
- [x] ~~React rewrite~~
|
||||
- [x] ~~docs pre-rendering (performance and SEO)~~
|
||||
- [ ] ability to simple branding/styling
|
||||
[Example repo](https://github.com/APIs-guru/create-react-app-redoc)
|
||||
- [Command-line interface to bundle your docs into a **zero-dependency** HTML file](https://redoc.ly/docs/redoc/quickstart/cli/)
|
||||
- Neat **interactive** documentation for nested objects <br>
|
||||

|
||||
|
||||
## Customization options
|
||||
[<img alt="Customization services" src="http://i.imgur.com/c4sUF7M.png" height="60px">](https://redoc.ly/#services)
|
||||
- High-level grouping in side-menu with the [`x-tagGroups`](https://redoc.ly/docs/api-reference-docs/specification-extensions/x-tag-groups/) specification extension
|
||||
- Branding/customizations using the [`theme` option](https://redoc.ly/docs/api-reference-docs/configuration/theming/)
|
||||
|
||||
## Support
|
||||
- OpenAPI v3.0 support
|
||||
- Basic OpenAPI v3.1 support
|
||||
- Broad OpenAPI v2.0 feature support (yes, it supports even `discriminator`) <br>
|
||||

|
||||
- Code samples support (via vendor extension) <br>
|
||||

|
||||
|
||||
## Releases
|
||||
**Important:** all the 2.x releases are deployed to npm and can be used via jsdeliver:
|
||||
- particular release, e.g. `v2.0.0-alpha.15`: https://cdn.jsdelivr.net/npm/redoc@2.0.0-alpha.17/bundles/redoc.standalone.js
|
||||
**Important:** all the 2.x releases are deployed to npm and can be used with jsdeliver:
|
||||
- particular release, for example, `v2.0.0-alpha.15`: https://cdn.jsdelivr.net/npm/redoc@2.0.0-alpha.17/bundles/redoc.standalone.js
|
||||
- `next` release: https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js
|
||||
|
||||
Additionally, all the 1.x releases are hosted on our GitHub Pages-based CDN **(deprecated)**:
|
||||
- particular release, e.g. `v1.2.0`: https://rebilly.github.io/ReDoc/releases/v1.2.0/redoc.min.js
|
||||
- particular release, for example `v1.2.0`: https://rebilly.github.io/ReDoc/releases/v1.2.0/redoc.min.js
|
||||
- `v1.x.x` release: https://rebilly.github.io/ReDoc/releases/v1.x.x/redoc.min.js
|
||||
- `latest` release: https://rebilly.github.io/ReDoc/releases/latest/redoc.min.js - it will point to latest 1.x.x release since 2.x releases are not hosted on this CDN but on unpkg.
|
||||
|
||||
## Version Guidance
|
||||
| ReDoc Release | OpenAPI Specification |
|
||||
| Redoc Release | OpenAPI Specification |
|
||||
|:--------------|:----------------------|
|
||||
| 2.0.0-alpha.54| 3.1, 3.0.x, 2.0 |
|
||||
| 2.0.0-alpha.x | 3.0, 2.0 |
|
||||
|
@ -64,31 +120,42 @@ Additionally, all the 1.x releases are hosted on our GitHub Pages-based CDN **(d
|
|||
| 1.18.x | 2.0 |
|
||||
| 1.17.x | 2.0 |
|
||||
|
||||
## Some Real-life usages
|
||||
## Showcase
|
||||
- [Rebilly](https://api-reference.rebilly.com/)
|
||||
- [Docker Engine](https://docs.docker.com/engine/api/v1.25/)
|
||||
- [Zuora](https://www.zuora.com/developer/api-reference/)
|
||||
- [Discourse](http://docs.discourse.org)
|
||||
- [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/)
|
||||
|
||||
## Lint OpenAPI definitions
|
||||
|
||||
Redocly's OpenAPI CLI is an open source command-line tool that you can use to lint
|
||||
your OpenAPI definition. Linting helps you to catch errors and inconsistencies in your
|
||||
OpenAPI definition before publishing.
|
||||
|
||||
Refer to [Lint configuration](https://redoc.ly/docs/cli/guides/lint/) in the OpenAPI documentation for more information.
|
||||
|
||||
## Deployment
|
||||
|
||||
### TL;DR
|
||||
### TL;DR final code example
|
||||
|
||||
To render your OpenAPI definition using Redoc, use the following HTML code sample and
|
||||
replace the `spec-url` attribute with the url or local file address to your definition.
|
||||
|
||||
```html
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>ReDoc</title>
|
||||
<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
|
||||
Redoc doesn't change outer page styles
|
||||
-->
|
||||
<style>
|
||||
body {
|
||||
|
@ -99,117 +166,31 @@ Additionally, all the 1.x releases are hosted on our GitHub Pages-based CDN **(d
|
|||
</head>
|
||||
<body>
|
||||
<redoc spec-url='http://petstore.swagger.io/v2/swagger.json'></redoc>
|
||||
<script src="https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js"> </script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/redoc@latest/bundles/redoc.standalone.js"> </script>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
That's all folks!
|
||||
|
||||
**IMPORTANT NOTE:** if you work with untrusted user spec, use `untrusted-spec` [option](#redoc-options-object) to prevent XSS security risks.
|
||||
|
||||
### 1. Install ReDoc (skip this step for CDN)
|
||||
Install using [npm](https://docs.npmjs.com/getting-started/what-is-npm):
|
||||
|
||||
npm i redoc
|
||||
|
||||
or using [yarn](https://yarnpkg.com):
|
||||
|
||||
yarn add redoc
|
||||
|
||||
### 2. Reference redoc script in HTML
|
||||
For **CDN**:
|
||||
```html
|
||||
<script src="https://cdn.jsdelivr.net/npm/redoc/bundles/redoc.standalone.js"> </script>
|
||||
```
|
||||
|
||||
For npm:
|
||||
```html
|
||||
<script src="node_modules/redoc/bundles/redoc.standalone.js"> </script>
|
||||
```
|
||||
For step-by-step instructions for how to get started using Redoc
|
||||
to render your OpenAPI definition, refer to the
|
||||
[**Redoc quickstart guide**](https://redoc.ly/docs/redoc/quickstart/intro/).
|
||||
|
||||
### 3. Add `<redoc>` element to your page
|
||||
```html
|
||||
<redoc spec-url="url/to/your/spec"></redoc>
|
||||
```
|
||||
See [**IE11 Support Notes**](docs/usage-with-ie11.md) for information on
|
||||
IE support for Redoc.
|
||||
|
||||
### 4. Enjoy :smile:
|
||||
|
||||
|
||||
## Usage as a React component
|
||||
|
||||
Install peer dependencies required by ReDoc if you don't have them installed already:
|
||||
|
||||
npm i react react-dom mobx styled-components core-js
|
||||
|
||||
Import `RedocStandalone` component from 'redoc' module:
|
||||
|
||||
```js
|
||||
import { RedocStandalone } from 'redoc';
|
||||
```
|
||||
|
||||
and use it somewhere in your component:
|
||||
|
||||
```js
|
||||
<RedocStandalone specUrl="url/to/your/spec"/>
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```js
|
||||
<RedocStandalone spec={/* spec as an object */}/>
|
||||
```
|
||||
|
||||
Also you can pass options:
|
||||
|
||||
```js
|
||||
<RedocStandalone
|
||||
specUrl="https://api.redoc.ly/registry/rebilly/core-api/core/bundle/master/openapi.yaml"
|
||||
options={{
|
||||
nativeScrollbars: true,
|
||||
theme: { colors: { primary: { main: '#dd5522' } } },
|
||||
}}
|
||||
/>
|
||||
```
|
||||
|
||||
Here are detailed [options docs](#redoc-options-object).
|
||||
|
||||
You can also specify `onLoaded` callback which will be called each time Redoc has been fully rendered or when error occurs (with an error as the first argument). *NOTE*: It may be called multiply times if you change component properties
|
||||
|
||||
```js
|
||||
<RedocStandalone
|
||||
specUrl="https://api.redoc.ly/registry/rebilly/core-api/core/bundle/master/openapi.yaml"
|
||||
onLoaded={error => {
|
||||
if (!error) {
|
||||
console.log('Yay!');
|
||||
}
|
||||
}}
|
||||
/>
|
||||
```
|
||||
|
||||
[**IE11 Support Notes**](docs/usage-with-ie11.md)
|
||||
|
||||
## The Docker way
|
||||
|
||||
ReDoc is available as pre-built Docker image in official [Docker Hub repository](https://hub.docker.com/r/redocly/redoc/). You may simply pull & run it:
|
||||
|
||||
docker pull redocly/redoc
|
||||
docker run -p 8080:80 redocly/redoc
|
||||
|
||||
Also you may rewrite some predefined environment variables defined in [Dockerfile](./config/docker/Dockerfile). By default ReDoc starts with demo Petstore spec located at `http://petstore.swagger.io/v2/swagger.json`, but you may change this URL using environment variable `SPEC_URL`:
|
||||
|
||||
docker run -p 8080:80 -e SPEC_URL=https://api.example.com/openapi.json redocly/redoc
|
||||
|
||||
## ReDoc CLI
|
||||
|
||||
[See here](https://github.com/Redocly/redoc/blob/master/cli/README.md)
|
||||
## Redoc CLI
|
||||
For more information on Redoc's commmand-line interface, refer to
|
||||
[**Using the Redoc CLI**](https://redoc.ly/docs/redoc/quickstart/cli/).
|
||||
|
||||
## Configuration
|
||||
|
||||
### Security Definition location
|
||||
You can inject Security Definitions widget into any place of your specification `description`. Check out details [here](docs/security-definitions-injection.md).
|
||||
You can inject the Security Definitions widget into any place in your definition `description`.
|
||||
For more information, refer to [Security definitions injection](docs/security-definitions-injection.md).
|
||||
|
||||
### Swagger vendor extensions
|
||||
ReDoc makes use of the following [vendor extensions](https://swagger.io/specification/#specificationExtensions):
|
||||
### OpenAPI specification extensions
|
||||
Redoc uses the following [specification extensions](https://swagger.io/specification/#specificationExtensions):
|
||||
* [`x-logo`](docs/redoc-vendor-extensions.md#x-logo) - is used to specify API logo
|
||||
* [`x-traitTag`](docs/redoc-vendor-extensions.md#x-traitTag) - useful for handling out common things like Pagination, Rate-Limits, etc
|
||||
* [`x-codeSamples`](docs/redoc-vendor-extensions.md#x-codeSamples) - specify operation code samples
|
||||
|
@ -225,11 +206,12 @@ ReDoc makes use of the following [vendor extensions](https://swagger.io/specific
|
|||
* [`x-explicitMappingOnly`](docs/redoc-vendor-extensions.md#x-explicitMappingOnly) - In Schemas, display a more descriptive property name in objects with additionalProperties when viewing the property list with an object
|
||||
|
||||
### `<redoc>` options object
|
||||
You can use all of the following options with standalone version on <redoc> tag by kebab-casing them, e.g. `scrollYOffset` becomes `scroll-y-offset` and `expandResponses` becomes `expand-responses`.
|
||||
You can use all of the following options with the standalone version of the <redoc> tag by kebab-casing them. For example, `scrollYOffset` becomes `scroll-y-offset`, and `expandResponses` becomes `expand-responses`.
|
||||
|
||||
* `disableSearch` - disable search indexing and search box.
|
||||
* `expandDefaultServerVariables` - enable expanding default server variables, default `false`.
|
||||
* `expandResponses` - specify which responses to expand by default by response codes. Values should be passed as comma-separated list without spaces e.g. `expandResponses="200,201"`. Special value `"all"` expands all responses by default. Be careful: this option can slow-down documentation rendering time.
|
||||
* `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.
|
||||
* `hideDownloadButton` - do not show "Download" spec button. **THIS DOESN'T MAKE YOUR SPEC PRIVATE**, it just hides the button.
|
||||
* `hideHostname` - if set, the protocol and hostname is not shown in the operation definition.
|
||||
|
@ -315,23 +297,6 @@ You can use all of the following options with standalone version on <redoc> tag
|
|||
* `width`: '40%'
|
||||
* `textColor`: '#ffffff'
|
||||
|
||||
## Advanced usage of standalone version
|
||||
Instead of adding `spec-url` attribute to the `<redoc>` element you can initialize ReDoc via globally exposed `Redoc` object:
|
||||
```js
|
||||
Redoc.init(specOrSpecUrl, options, element, callback?)
|
||||
```
|
||||
|
||||
- `specOrSpecUrl` is either JSON object with specification or an URL to the spec in `JSON` or `YAML` format
|
||||
- `options` [options object](#redoc-options-object)
|
||||
- `element` DOM element to put ReDoc 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
|
||||
|
||||
```js
|
||||
Redoc.init('http://petstore.swagger.io/v2/swagger.json', {
|
||||
scrollYOffset: 50
|
||||
}, document.getElementById('redoc-container'))
|
||||
```
|
||||
|
||||
-----------
|
||||
## Development
|
||||
see [CONTRIBUTING.md](.github/CONTRIBUTING.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`: <br> `$ redoc-cli bundle [spec] --options.theme.colors.primary.main=orange`
|
||||
- Serve with `nativeScrollbars` option set to true: <br> `$ 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): <br> `$ redoc-cli bundle [spec] -t custom.hbs`
|
||||
- Bundle using custom template and add custom `templateOptions`: <br> `$ redoc-cli bundle [spec] -t custom.hbs --templateOptions.metaDescription "Page meta description"`
|
||||
- Bundle with the main color changed to `orange`:<br/>
|
||||
`$ redoc-cli bundle [spec] --options.theme.colors.primary.main=orange`
|
||||
- Serve with the `nativeScrollbars` option set to true:<br/>
|
||||
`$ 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):<br/>
|
||||
`$ redoc-cli bundle [spec] -t custom.hbs`
|
||||
- Bundle using a custom template and add custom `templateOptions`:<br/>
|
||||
`$ 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`.
|
||||
|
|
116
cli/npm-shrinkwrap.json
generated
116
cli/npm-shrinkwrap.json
generated
|
@ -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",
|
||||
|
|
|
@ -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"
|
||||
},
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -533,6 +533,20 @@ paths:
|
|||
subscriptionId:
|
||||
type: string
|
||||
example: AAA-123-BBB-456
|
||||
'200':
|
||||
description: Successful operation
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
maxItems: 999
|
||||
minItems: 0
|
||||
items:
|
||||
type: array
|
||||
maxItems: 777
|
||||
minItems: 111
|
||||
items:
|
||||
type: number
|
||||
callbacks:
|
||||
orderInProgress:
|
||||
'{$request.body#/callbackUrl}?event={$request.body#/eventName}':
|
||||
|
@ -1166,6 +1180,11 @@ components:
|
|||
description: User status
|
||||
type: integer
|
||||
format: int32
|
||||
image:
|
||||
description: User image
|
||||
type: string
|
||||
contentEncoding: base64
|
||||
contentMediaType: image/png
|
||||
xml:
|
||||
name: User
|
||||
requestBodies:
|
||||
|
|
|
@ -377,7 +377,9 @@ paths:
|
|||
application/xml:
|
||||
schema:
|
||||
type: array
|
||||
maxItems: 999
|
||||
items:
|
||||
maxItems: 111
|
||||
$ref: '#/components/schemas/Pet'
|
||||
'400':
|
||||
description: Invalid tag value
|
||||
|
@ -1193,7 +1195,7 @@ x-webhooks:
|
|||
summary: New pet
|
||||
description: Information about a new pet in the systems
|
||||
operationId: newPet
|
||||
tags:
|
||||
tags:
|
||||
- pet
|
||||
requestBody:
|
||||
content:
|
||||
|
@ -1202,4 +1204,4 @@ x-webhooks:
|
|||
$ref: "#/components/schemas/Pet"
|
||||
responses:
|
||||
"200":
|
||||
description: Return a 200 status to indicate that the data was received successfully
|
||||
description: Return a 200 status to indicate that the data was received successfully
|
||||
|
|
BIN
docs/images/redoc.png
Normal file
BIN
docs/images/redoc.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.9 KiB |
112
docs/quickstart/cli.md
Normal file
112
docs/quickstart/cli.md
Normal file
|
@ -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
|
||||
<!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
|
||||
```
|
39
docs/quickstart/docker.md
Normal file
39
docs/quickstart/docker.md
Normal file
|
@ -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.
|
214
docs/quickstart/html.md
Normal file
214
docs/quickstart/html.md
Normal file
|
@ -0,0 +1,214 @@
|
|||
---
|
||||
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 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
|
||||
<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://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
|
||||
<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>
|
||||
```
|
44
docs/quickstart/intro.md
Normal file
44
docs/quickstart/intro.md
Normal file
|
@ -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.
|
78
docs/quickstart/react.md
Normal file
78
docs/quickstart/react.md
Normal file
|
@ -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
|
||||
<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://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
|
||||
<RedocStandalone
|
||||
specUrl="http://petstore.swagger.io/v2/swagger.json"
|
||||
onLoaded={error => {
|
||||
if (!error) {
|
||||
console.log('Yay!');
|
||||
}
|
||||
}}
|
||||
/>
|
||||
```
|
13
docs/sidebars.yaml
Normal file
13
docs/sidebars.yaml
Normal file
|
@ -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
|
|
@ -25,6 +25,29 @@ describe('Menu', () => {
|
|||
.should('be.visible');
|
||||
});
|
||||
|
||||
it('should sync active menu items while scroll back and scroll again', () => {
|
||||
cy.contains('h2', 'Add a new pet to the store')
|
||||
.scrollIntoView()
|
||||
.wait(100)
|
||||
.get('[role=menuitem].active')
|
||||
.children()
|
||||
.last()
|
||||
.should('have.text', 'Add a new pet to the store')
|
||||
.should('be.visible');
|
||||
|
||||
cy.contains('h1', 'Swagger Petstore')
|
||||
.scrollIntoView()
|
||||
.wait(100)
|
||||
|
||||
cy.contains('h1', 'Introduction')
|
||||
.scrollIntoView()
|
||||
.wait(100)
|
||||
.get('[role=menuitem].active')
|
||||
.should('have.text', 'Introduction');
|
||||
|
||||
cy.url().should('include', '#section/Introduction');
|
||||
});
|
||||
|
||||
it('should update URL hash when clicking on menu items', () => {
|
||||
cy.contains('[role=menuitem].-depth1', 'pet').click({ force: true });
|
||||
cy.location('hash').should('equal', '#tag/pet');
|
||||
|
|
92
package-lock.json
generated
92
package-lock.json
generated
|
@ -1,17 +1,16 @@
|
|||
{
|
||||
"name": "redoc",
|
||||
"version": "2.0.0-rc.55",
|
||||
"version": "2.0.0-rc.56",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"version": "2.0.0-rc.55",
|
||||
"version": "2.0.0-rc.56",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.14.0",
|
||||
"@redocly/openapi-core": "^1.0.0-beta.50",
|
||||
"@redocly/openapi-core": "^1.0.0-beta.54",
|
||||
"@redocly/react-dropdown-aria": "^2.0.11",
|
||||
"@types/node": "^15.6.1",
|
||||
"classnames": "^2.3.1",
|
||||
"decko": "^1.2.0",
|
||||
"dompurify": "^2.2.8",
|
||||
|
@ -26,7 +25,7 @@
|
|||
"path-browserify": "^1.0.1",
|
||||
"perfect-scrollbar": "^1.5.1",
|
||||
"polished": "^4.1.3",
|
||||
"prismjs": "^1.24.0",
|
||||
"prismjs": "^1.24.1",
|
||||
"prop-types": "^15.7.2",
|
||||
"react-tabs": "^3.2.2",
|
||||
"slugify": "~1.4.7",
|
||||
|
@ -59,6 +58,7 @@
|
|||
"@types/lunr": "^2.3.3",
|
||||
"@types/mark.js": "^8.11.5",
|
||||
"@types/marked": "^1.1.0",
|
||||
"@types/node": "^15.6.1",
|
||||
"@types/prismjs": "^1.16.5",
|
||||
"@types/prop-types": "^15.7.3",
|
||||
"@types/react": "^17.0.8",
|
||||
|
@ -2672,13 +2672,13 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@redocly/ajv": {
|
||||
"version": "6.12.4",
|
||||
"resolved": "https://registry.npmjs.org/@redocly/ajv/-/ajv-6.12.4.tgz",
|
||||
"integrity": "sha512-RB6vWO78v6c+SW/3bZh+XZMr4nGdJKAiPGsBALuUZnLuCiQ7aXCT1AuFHqnfS2gyXbEUEj+kw8p4ux8KdAfs3A==",
|
||||
"version": "8.6.2",
|
||||
"resolved": "https://registry.npmjs.org/@redocly/ajv/-/ajv-8.6.2.tgz",
|
||||
"integrity": "sha512-tU8fQs0D76ZKhJ2cWtnfQthWqiZgGBx0gH0+5D8JvaBEBaqA8foPPBt3Nonwr3ygyv5xrw2IzKWgIY86BlGs+w==",
|
||||
"dependencies": {
|
||||
"fast-deep-equal": "^3.1.1",
|
||||
"fast-json-stable-stringify": "^2.0.0",
|
||||
"json-schema-traverse": "^0.4.1",
|
||||
"json-schema-traverse": "^1.0.0",
|
||||
"require-from-string": "^2.0.2",
|
||||
"uri-js": "^4.2.2"
|
||||
},
|
||||
"funding": {
|
||||
|
@ -2686,12 +2686,17 @@
|
|||
"url": "https://github.com/sponsors/epoberezkin"
|
||||
}
|
||||
},
|
||||
"node_modules/@redocly/ajv/node_modules/json-schema-traverse": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz",
|
||||
"integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="
|
||||
},
|
||||
"node_modules/@redocly/openapi-core": {
|
||||
"version": "1.0.0-beta.50",
|
||||
"resolved": "https://registry.npmjs.org/@redocly/openapi-core/-/openapi-core-1.0.0-beta.50.tgz",
|
||||
"integrity": "sha512-GuXn4IETxpbRd8dlAQDQPtvqOpbMvPMeC/e5mv5MOXkLIznNk4vjiQVe6QSCbZbCHzzpb2+89B6S7asebPm4Rg==",
|
||||
"version": "1.0.0-beta.54",
|
||||
"resolved": "https://registry.npmjs.org/@redocly/openapi-core/-/openapi-core-1.0.0-beta.54.tgz",
|
||||
"integrity": "sha512-uYs0N1Trjkh7u8IMIuCU2VxCXhMyGWSZUkP/WNdTR1OgBUtvNdF9C32zoQV+hyCIH4gVu42ROHkjisy333ZX+w==",
|
||||
"dependencies": {
|
||||
"@redocly/ajv": "^6.12.3",
|
||||
"@redocly/ajv": "^8.6.2",
|
||||
"@types/node": "^14.11.8",
|
||||
"colorette": "^1.2.0",
|
||||
"js-levenshtein": "^1.1.6",
|
||||
|
@ -3038,7 +3043,8 @@
|
|||
"node_modules/@types/node": {
|
||||
"version": "15.12.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-15.12.2.tgz",
|
||||
"integrity": "sha512-zjQ69G564OCIWIOHSXyQEEDpdpGl+G348RAKY0XXy9Z5kU9Vzv1GMNnkar/ZJ8dzXB3COzD9Mo9NtRZ4xfgUww=="
|
||||
"integrity": "sha512-zjQ69G564OCIWIOHSXyQEEDpdpGl+G348RAKY0XXy9Z5kU9Vzv1GMNnkar/ZJ8dzXB3COzD9Mo9NtRZ4xfgUww==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/normalize-package-data": {
|
||||
"version": "2.4.0",
|
||||
|
@ -8358,7 +8364,8 @@
|
|||
"node_modules/fast-json-stable-stringify": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz",
|
||||
"integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw=="
|
||||
"integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/fast-levenshtein": {
|
||||
"version": "2.0.6",
|
||||
|
@ -13267,7 +13274,8 @@
|
|||
"node_modules/json-schema-traverse": {
|
||||
"version": "0.4.1",
|
||||
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
|
||||
"integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg=="
|
||||
"integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/json-stable-stringify-without-jsonify": {
|
||||
"version": "1.0.1",
|
||||
|
@ -15962,9 +15970,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/prismjs": {
|
||||
"version": "1.24.0",
|
||||
"resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.24.0.tgz",
|
||||
"integrity": "sha512-SqV5GRsNqnzCL8k5dfAjCNhUrF3pR0A9lTDSCUZeh/LIshheXJEaP0hwLz2t4XHivd2J/v2HR+gRnigzeKe3cQ=="
|
||||
"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",
|
||||
|
@ -16757,7 +16765,6 @@
|
|||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz",
|
||||
"integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
|
@ -22961,22 +22968,29 @@
|
|||
}
|
||||
},
|
||||
"@redocly/ajv": {
|
||||
"version": "6.12.4",
|
||||
"resolved": "https://registry.npmjs.org/@redocly/ajv/-/ajv-6.12.4.tgz",
|
||||
"integrity": "sha512-RB6vWO78v6c+SW/3bZh+XZMr4nGdJKAiPGsBALuUZnLuCiQ7aXCT1AuFHqnfS2gyXbEUEj+kw8p4ux8KdAfs3A==",
|
||||
"version": "8.6.2",
|
||||
"resolved": "https://registry.npmjs.org/@redocly/ajv/-/ajv-8.6.2.tgz",
|
||||
"integrity": "sha512-tU8fQs0D76ZKhJ2cWtnfQthWqiZgGBx0gH0+5D8JvaBEBaqA8foPPBt3Nonwr3ygyv5xrw2IzKWgIY86BlGs+w==",
|
||||
"requires": {
|
||||
"fast-deep-equal": "^3.1.1",
|
||||
"fast-json-stable-stringify": "^2.0.0",
|
||||
"json-schema-traverse": "^0.4.1",
|
||||
"json-schema-traverse": "^1.0.0",
|
||||
"require-from-string": "^2.0.2",
|
||||
"uri-js": "^4.2.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"json-schema-traverse": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz",
|
||||
"integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"@redocly/openapi-core": {
|
||||
"version": "1.0.0-beta.50",
|
||||
"resolved": "https://registry.npmjs.org/@redocly/openapi-core/-/openapi-core-1.0.0-beta.50.tgz",
|
||||
"integrity": "sha512-GuXn4IETxpbRd8dlAQDQPtvqOpbMvPMeC/e5mv5MOXkLIznNk4vjiQVe6QSCbZbCHzzpb2+89B6S7asebPm4Rg==",
|
||||
"version": "1.0.0-beta.54",
|
||||
"resolved": "https://registry.npmjs.org/@redocly/openapi-core/-/openapi-core-1.0.0-beta.54.tgz",
|
||||
"integrity": "sha512-uYs0N1Trjkh7u8IMIuCU2VxCXhMyGWSZUkP/WNdTR1OgBUtvNdF9C32zoQV+hyCIH4gVu42ROHkjisy333ZX+w==",
|
||||
"requires": {
|
||||
"@redocly/ajv": "^6.12.3",
|
||||
"@redocly/ajv": "^8.6.2",
|
||||
"@types/node": "^14.11.8",
|
||||
"colorette": "^1.2.0",
|
||||
"js-levenshtein": "^1.1.6",
|
||||
|
@ -23312,7 +23326,8 @@
|
|||
"@types/node": {
|
||||
"version": "15.12.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-15.12.2.tgz",
|
||||
"integrity": "sha512-zjQ69G564OCIWIOHSXyQEEDpdpGl+G348RAKY0XXy9Z5kU9Vzv1GMNnkar/ZJ8dzXB3COzD9Mo9NtRZ4xfgUww=="
|
||||
"integrity": "sha512-zjQ69G564OCIWIOHSXyQEEDpdpGl+G348RAKY0XXy9Z5kU9Vzv1GMNnkar/ZJ8dzXB3COzD9Mo9NtRZ4xfgUww==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/normalize-package-data": {
|
||||
"version": "2.4.0",
|
||||
|
@ -27480,7 +27495,8 @@
|
|||
"fast-json-stable-stringify": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz",
|
||||
"integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw=="
|
||||
"integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==",
|
||||
"dev": true
|
||||
},
|
||||
"fast-levenshtein": {
|
||||
"version": "2.0.6",
|
||||
|
@ -31180,7 +31196,8 @@
|
|||
"json-schema-traverse": {
|
||||
"version": "0.4.1",
|
||||
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
|
||||
"integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg=="
|
||||
"integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==",
|
||||
"dev": true
|
||||
},
|
||||
"json-stable-stringify-without-jsonify": {
|
||||
"version": "1.0.1",
|
||||
|
@ -33230,9 +33247,9 @@
|
|||
}
|
||||
},
|
||||
"prismjs": {
|
||||
"version": "1.24.0",
|
||||
"resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.24.0.tgz",
|
||||
"integrity": "sha512-SqV5GRsNqnzCL8k5dfAjCNhUrF3pR0A9lTDSCUZeh/LIshheXJEaP0hwLz2t4XHivd2J/v2HR+gRnigzeKe3cQ=="
|
||||
"version": "1.24.1",
|
||||
"resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.24.1.tgz",
|
||||
"integrity": "sha512-mNPsedLuk90RVJioIky8ANZEwYm5w9LcvCXrxHlwf4fNVSn8jEipMybMkWUyyF0JhnC+C4VcOVSBuHRKs1L5Ow=="
|
||||
},
|
||||
"process": {
|
||||
"version": "0.11.10",
|
||||
|
@ -33869,8 +33886,7 @@
|
|||
"require-from-string": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz",
|
||||
"integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==",
|
||||
"dev": true
|
||||
"integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw=="
|
||||
},
|
||||
"require-main-filename": {
|
||||
"version": "2.0.0",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "redoc",
|
||||
"version": "2.0.0-rc.55",
|
||||
"version": "2.0.0-rc.56",
|
||||
"description": "ReDoc",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
@ -79,6 +79,7 @@
|
|||
"@types/json-pointer": "^1.0.30",
|
||||
"@types/lodash": "^4.14.170",
|
||||
"@types/lunr": "^2.3.3",
|
||||
"@types/node": "^15.6.1",
|
||||
"@types/mark.js": "^8.11.5",
|
||||
"@types/marked": "^1.1.0",
|
||||
"@types/prismjs": "^1.16.5",
|
||||
|
@ -146,9 +147,8 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.14.0",
|
||||
"@redocly/openapi-core": "^1.0.0-beta.50",
|
||||
"@redocly/openapi-core": "^1.0.0-beta.54",
|
||||
"@redocly/react-dropdown-aria": "^2.0.11",
|
||||
"@types/node": "^15.6.1",
|
||||
"classnames": "^2.3.1",
|
||||
"decko": "^1.2.0",
|
||||
"dompurify": "^2.2.8",
|
||||
|
@ -163,7 +163,7 @@
|
|||
"path-browserify": "^1.0.1",
|
||||
"perfect-scrollbar": "^1.5.1",
|
||||
"polished": "^4.1.3",
|
||||
"prismjs": "^1.24.0",
|
||||
"prismjs": "^1.24.1",
|
||||
"prop-types": "^15.7.2",
|
||||
"react-tabs": "^3.2.2",
|
||||
"slugify": "~1.4.7",
|
||||
|
|
|
@ -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<ApiInfoProps> {
|
|||
</ApiHeader>
|
||||
{!hideDownloadButton && (
|
||||
<p>
|
||||
Download OpenAPI specification:
|
||||
{l('downloadSpecification')}:
|
||||
<DownloadButton
|
||||
download={downloadFilename || true}
|
||||
target="_blank"
|
||||
href={downloadLink}
|
||||
onClick={this.handleDownloadClick}
|
||||
>
|
||||
Download
|
||||
{l('download')}
|
||||
</DownloadButton>
|
||||
</p>
|
||||
)}
|
||||
|
|
|
@ -59,7 +59,7 @@ export class FieldDetails extends React.PureComponent<FieldProps, { patternShown
|
|||
} else {
|
||||
const label = l('example') + ':';
|
||||
const raw = !!field.in;
|
||||
renderedExamples = <FieldDetail label={label} value={getSerializedValue(field, field.example)} raw={raw} />;
|
||||
renderedExamples = <FieldDetail label={label} value={getSerializedValue(field, field.example)} raw={raw} />;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,6 +76,20 @@ export class FieldDetails extends React.PureComponent<FieldProps, { patternShown
|
|||
>{' '}
|
||||
</TypeFormat>
|
||||
)}
|
||||
{schema.contentEncoding && (
|
||||
<TypeFormat>
|
||||
{' '}<
|
||||
{schema.contentEncoding}
|
||||
>{' '}
|
||||
</TypeFormat>
|
||||
)}
|
||||
{schema.contentMediaType && (
|
||||
<TypeFormat>
|
||||
{' '}<
|
||||
{schema.contentMediaType}
|
||||
>{' '}
|
||||
</TypeFormat>
|
||||
)}
|
||||
{schema.title && !hideSchemaTitles && <TypeTitle> ({schema.title}) </TypeTitle>}
|
||||
<ConstraintsView constraints={schema.constraints} />
|
||||
{schema.pattern && !hideSchemaPattern && (
|
||||
|
@ -110,7 +124,7 @@ export class FieldDetails extends React.PureComponent<FieldProps, { patternShown
|
|||
<ExternalDocumentation externalDocs={schema.externalDocs} compact={true} />
|
||||
)}
|
||||
{(renderDiscriminatorSwitch && renderDiscriminatorSwitch(this.props)) || null}
|
||||
{field.const && (<FieldDetail label={l('const') + ':'} value={field.const}/>) || null}
|
||||
{field.const && (<FieldDetail label={l('const') + ':'} value={field.const} />) || null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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 (
|
||||
<MediaTypesSwitch content={content} renderDropdown={DropdownWithinHeader}>
|
||||
{({ schema }) => {
|
||||
return (
|
||||
<>
|
||||
{description !== undefined && <Markdown source={description} />}
|
||||
<Schema skipReadOnly={true} key="schema" schema={schema} />
|
||||
<Schema skipReadOnly={isRequestType} key="schema" schema={schema} />
|
||||
</>
|
||||
);
|
||||
}}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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<RequestSamplesProps> {
|
|||
return (
|
||||
(hasSamples && (
|
||||
<div>
|
||||
<RightPanelHeader> Request samples </RightPanelHeader>
|
||||
<RightPanelHeader> {l('requestSamples')} </RightPanelHeader>
|
||||
|
||||
<Tabs defaultIndex={0}>
|
||||
<TabList hidden={hideTabList}>
|
||||
|
|
|
@ -5,6 +5,7 @@ import { OperationModel } from '../../services/models';
|
|||
|
||||
import { RightPanelHeader, Tab, TabList, TabPanel, Tabs } from '../../common-elements';
|
||||
import { PayloadSamples } from '../PayloadSamples/PayloadSamples';
|
||||
import { l } from '../../services/Labels';
|
||||
|
||||
export interface ResponseSamplesProps {
|
||||
operation: OperationModel;
|
||||
|
@ -23,7 +24,7 @@ export class ResponseSamples extends React.Component<ResponseSamplesProps> {
|
|||
return (
|
||||
(responses.length > 0 && (
|
||||
<div>
|
||||
<RightPanelHeader> Response samples </RightPanelHeader>
|
||||
<RightPanelHeader> {l('responseSamples')} </RightPanelHeader>
|
||||
|
||||
<Tabs defaultIndex={0}>
|
||||
<TabList>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import * as React from 'react';
|
||||
import { l } from '../../services/Labels';
|
||||
import { ResponseModel } from '../../services/models';
|
||||
import styled from '../../styled-components';
|
||||
import { ResponseView } from './Response';
|
||||
|
@ -26,7 +27,7 @@ export class ResponsesList extends React.PureComponent<ResponseListProps> {
|
|||
|
||||
return (
|
||||
<div>
|
||||
<ResponsesHeader>{isCallback ? 'Callback responses' : 'Responses'}</ResponsesHeader>
|
||||
<ResponsesHeader>{isCallback ? l('callbackResponses') : l('responses')}</ResponsesHeader>
|
||||
{responses.map(response => {
|
||||
return <ResponseView key={response.code} response={response} />;
|
||||
})}
|
||||
|
|
|
@ -4,7 +4,8 @@ import { Schema, SchemaProps } from './Schema';
|
|||
|
||||
import { ArrayClosingLabel, ArrayOpenningLabel } from '../../common-elements';
|
||||
import styled from '../../styled-components';
|
||||
import {humanizeConstraints} from "../../utils";
|
||||
import { humanizeConstraints } from '../../utils';
|
||||
import { TypeName } from '../../common-elements/fields';
|
||||
|
||||
const PaddedSchema = styled.div`
|
||||
padding-left: ${({ theme }) => theme.spacing.unit * 2}px;
|
||||
|
@ -12,17 +13,22 @@ const PaddedSchema = styled.div`
|
|||
|
||||
export class ArraySchema extends React.PureComponent<SchemaProps> {
|
||||
render() {
|
||||
const itemsSchema = this.props.schema.items!;
|
||||
const itemConstraintSchema = (
|
||||
min: number | undefined = undefined,
|
||||
max: number | undefined = undefined,
|
||||
) => ({ type: 'array', minItems: min, maxItems: max });
|
||||
const schema = this.props.schema;
|
||||
const itemsSchema = schema.items;
|
||||
|
||||
const minMaxItems = humanizeConstraints(itemConstraintSchema(itemsSchema.schema.minItems, itemsSchema.schema.maxItems));
|
||||
const minMaxItems = schema.minItems === undefined && schema.maxItems === undefined ?
|
||||
'' :
|
||||
`(${humanizeConstraints(schema)})`;
|
||||
|
||||
if (schema.displayType && !itemsSchema && !minMaxItems.length) {
|
||||
return (<div>
|
||||
<TypeName>{schema.displayType}</TypeName>
|
||||
</div>);
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<ArrayOpenningLabel> Array ({minMaxItems})</ArrayOpenningLabel>
|
||||
<ArrayOpenningLabel> Array {minMaxItems}</ArrayOpenningLabel>
|
||||
<PaddedSchema>
|
||||
<Schema {...this.props} schema={itemsSchema} />
|
||||
</PaddedSchema>
|
||||
|
|
|
@ -63,20 +63,15 @@ export class Schema extends React.Component<Partial<SchemaProps>> {
|
|||
return <OneOfSchema schema={schema} {...this.props} />;
|
||||
}
|
||||
|
||||
if (type && Array.isArray(type)) {
|
||||
const types = Array.isArray(type) ? type : [type];
|
||||
if (types.includes('object')) {
|
||||
if (schema.fields?.length) {
|
||||
return <ObjectSchema {...(this.props as any)} />;
|
||||
}
|
||||
} else if (types.includes('array')) {
|
||||
return <ArraySchema {...(this.props as any)} />;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case 'object':
|
||||
if (schema.fields?.length) {
|
||||
return <ObjectSchema {...(this.props as any)} />;
|
||||
}
|
||||
break;
|
||||
case 'array':
|
||||
return <ArraySchema {...(this.props as any)} />;
|
||||
}
|
||||
|
||||
// TODO: maybe adjust FieldDetails to accept schema
|
||||
const field = ({
|
||||
schema,
|
||||
|
|
|
@ -8,8 +8,8 @@ import { SecurityRequirementModel } from '../../services/models/SecurityRequirem
|
|||
import { linksCss } from '../Markdown/styled.elements';
|
||||
|
||||
const ScopeName = styled.code`
|
||||
font-size: ${props => props.theme.typography.code.fontSize};
|
||||
font-family: ${props => props.theme.typography.code.fontFamily};
|
||||
font-size: ${(props) => props.theme.typography.code.fontSize};
|
||||
font-family: ${(props) => props.theme.typography.code.fontFamily};
|
||||
border: 1px solid ${({ theme }) => theme.colors.border.dark};
|
||||
margin: 0 3px;
|
||||
padding: 0.2em;
|
||||
|
@ -67,18 +67,22 @@ export class SecurityRequirement extends React.PureComponent<SecurityRequirement
|
|||
const security = this.props.security;
|
||||
return (
|
||||
<SecurityRequirementOrWrap>
|
||||
{security.schemes.map(scheme => {
|
||||
return (
|
||||
<SecurityRequirementAndWrap key={scheme.id}>
|
||||
<Link to={scheme.sectionId}>{scheme.id}</Link>
|
||||
{scheme.scopes.length > 0 && ' ('}
|
||||
{scheme.scopes.map(scope => (
|
||||
<ScopeName key={scope}>{scope}</ScopeName>
|
||||
))}
|
||||
{scheme.scopes.length > 0 && ') '}
|
||||
</SecurityRequirementAndWrap>
|
||||
);
|
||||
})}
|
||||
{security.schemes.length ? (
|
||||
security.schemes.map((scheme) => {
|
||||
return (
|
||||
<SecurityRequirementAndWrap key={scheme.id}>
|
||||
<Link to={scheme.sectionId}>{scheme.id}</Link>
|
||||
{scheme.scopes.length > 0 && ' ('}
|
||||
{scheme.scopes.map((scope) => (
|
||||
<ScopeName key={scope}>{scope}</ScopeName>
|
||||
))}
|
||||
{scheme.scopes.length > 0 && ') '}
|
||||
</SecurityRequirementAndWrap>
|
||||
);
|
||||
})
|
||||
) : (
|
||||
<SecurityRequirementAndWrap>None</SecurityRequirementAndWrap>
|
||||
)}
|
||||
</SecurityRequirementOrWrap>
|
||||
);
|
||||
}
|
||||
|
@ -89,7 +93,7 @@ const AuthHeaderColumn = styled.div`
|
|||
`;
|
||||
|
||||
const SecuritiesColumn = styled.div`
|
||||
width: ${props => props.theme.schema.defaultDetailsWidth};
|
||||
width: ${(props) => props.theme.schema.defaultDetailsWidth};
|
||||
${media.lessThan('small')`
|
||||
margin-top: 10px;
|
||||
`}
|
||||
|
|
27
src/components/__tests__/SecurityRequirement.test.tsx
Normal file
27
src/components/__tests__/SecurityRequirement.test.tsx
Normal file
|
@ -0,0 +1,27 @@
|
|||
import * as React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
|
||||
import { OpenAPIParser } from '../../services';
|
||||
import { SecurityRequirementModel } from '../../services/models/SecurityRequirement';
|
||||
import { SecurityRequirement } from '../SecurityRequirement/SecurityRequirement';
|
||||
import { RedocNormalizedOptions } from '../../services/RedocNormalizedOptions';
|
||||
|
||||
const options = new RedocNormalizedOptions({});
|
||||
describe('Components', () => {
|
||||
describe('SecurityRequirement', () => {
|
||||
describe('SecurityRequirement', () => {
|
||||
it('should render \'None\' when empty object in security open api', () => {
|
||||
const parser = new OpenAPIParser({ openapi: '3.0', info: { title: 'test', version: '0' }, paths: {} },
|
||||
undefined,
|
||||
options,
|
||||
);
|
||||
const securityRequirement = new SecurityRequirementModel({}, parser);
|
||||
const securityElement = shallow(
|
||||
<SecurityRequirement key={1} security={securityRequirement} />
|
||||
).getElement();
|
||||
expect(securityElement.props.children.type.target).toEqual('span');
|
||||
expect(securityElement.props.children.props.children).toEqual('None');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
|
@ -20,6 +20,8 @@ exports[`Components SchemaView discriminator should correctly render discriminat
|
|||
"activeOneOf": 0,
|
||||
"const": "",
|
||||
"constraints": Array [],
|
||||
"contentEncoding": undefined,
|
||||
"contentMediaType": undefined,
|
||||
"default": undefined,
|
||||
"deprecated": false,
|
||||
"description": "",
|
||||
|
@ -31,6 +33,8 @@ exports[`Components SchemaView discriminator should correctly render discriminat
|
|||
"format": undefined,
|
||||
"isCircular": undefined,
|
||||
"isPrimitive": true,
|
||||
"maxItems": undefined,
|
||||
"minItems": undefined,
|
||||
"options": "<<<filtered>>>",
|
||||
"pattern": undefined,
|
||||
"pointer": "#/components/schemas/Dog/properties/packSize",
|
||||
|
@ -71,6 +75,8 @@ exports[`Components SchemaView discriminator should correctly render discriminat
|
|||
"activeOneOf": 0,
|
||||
"const": "",
|
||||
"constraints": Array [],
|
||||
"contentEncoding": undefined,
|
||||
"contentMediaType": undefined,
|
||||
"default": undefined,
|
||||
"deprecated": false,
|
||||
"description": "",
|
||||
|
@ -82,6 +88,8 @@ exports[`Components SchemaView discriminator should correctly render discriminat
|
|||
"format": undefined,
|
||||
"isCircular": undefined,
|
||||
"isPrimitive": true,
|
||||
"maxItems": undefined,
|
||||
"minItems": undefined,
|
||||
"options": "<<<filtered>>>",
|
||||
"pattern": undefined,
|
||||
"pointer": "#/components/schemas/Dog/properties/type",
|
||||
|
|
|
@ -11,6 +11,12 @@ export interface LabelsConfig {
|
|||
webhook: string;
|
||||
const: string;
|
||||
noResultsFound: string;
|
||||
download: string;
|
||||
downloadSpecification: string;
|
||||
responses: string;
|
||||
callbackResponses: string;
|
||||
requestSamples: string;
|
||||
responseSamples: string;
|
||||
}
|
||||
|
||||
export type LabelsConfigRaw = Partial<LabelsConfig>;
|
||||
|
@ -28,6 +34,12 @@ const labels: LabelsConfig = {
|
|||
webhook: 'Event',
|
||||
const: 'Value',
|
||||
noResultsFound: 'No results found',
|
||||
download: 'Download',
|
||||
downloadSpecification: 'Download OpenAPI specification',
|
||||
responses: 'Responses',
|
||||
callbackResponses: 'Callback responses',
|
||||
requestSamples: 'Request samples',
|
||||
responseSamples: 'Response samples',
|
||||
};
|
||||
|
||||
export function setRedocLabels(_labels?: LabelsConfigRaw) {
|
||||
|
|
|
@ -210,6 +210,7 @@ export class MenuStore {
|
|||
|
||||
this.deactivate(this.activeItem);
|
||||
if (!item) {
|
||||
this.activeItemIdx = -1;
|
||||
this.history.replace('', rewriteHistory);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -174,6 +174,18 @@ export class OpenAPIParser {
|
|||
return obj;
|
||||
}
|
||||
|
||||
shallowDeref<T extends unknown>(obj: OpenAPIRef | T): T {
|
||||
if (this.isRef(obj)) {
|
||||
const schemaName = getDefinitionName(obj.$ref);
|
||||
if (schemaName && this.options.ignoreNamedSchemas.has(schemaName)) {
|
||||
return { type: 'object', title: schemaName } as T;
|
||||
}
|
||||
const resolved = this.byRef<T>(obj.$ref);
|
||||
return this.allowMergeRefs ? this.mergeRefs(obj, resolved, false) : (resolved as T);
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
mergeRefs(ref, resolved, mergeAsAllOf: boolean) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { $ref, ...rest } = ref;
|
||||
|
@ -183,7 +195,7 @@ export class OpenAPIParser {
|
|||
}
|
||||
if (mergeAsAllOf && keys.some((k) => k !== 'description' && k !== 'title' && k !== 'externalDocs')) {
|
||||
return {
|
||||
allOf: [resolved, rest],
|
||||
allOf: [rest, resolved],
|
||||
};
|
||||
} else {
|
||||
// small optimization
|
||||
|
@ -194,13 +206,6 @@ export class OpenAPIParser {
|
|||
}
|
||||
}
|
||||
|
||||
shalowDeref<T extends object>(obj: OpenAPIRef | T): T {
|
||||
if (this.isRef(obj)) {
|
||||
return this.byRef<T>(obj.$ref)!;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge allOf constraints.
|
||||
* @param schema schema with allOF
|
||||
|
|
|
@ -42,14 +42,15 @@ export interface RedocRawOptions {
|
|||
maxDisplayedEnumValues?: number;
|
||||
ignoreNamedSchemas?: string[] | string;
|
||||
hideSchemaPattern?: boolean;
|
||||
generatedPayloadSamplesMaxDepth?: number;
|
||||
}
|
||||
|
||||
function argValueToBoolean(val?: string | boolean, defaultValue?: boolean): boolean {
|
||||
export function argValueToBoolean(val?: string | boolean, defaultValue?: boolean): boolean {
|
||||
if (val === undefined) {
|
||||
return defaultValue || false;
|
||||
}
|
||||
if (typeof val === 'string') {
|
||||
return val === 'false' ? false : true;
|
||||
return val !== 'false';
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
@ -163,6 +164,16 @@ export class RedocNormalizedOptions {
|
|||
return 2;
|
||||
}
|
||||
|
||||
private static normalizeGeneratedPayloadSamplesMaxDepth(
|
||||
value?: number | string | undefined,
|
||||
): number {
|
||||
if (!isNaN(Number(value))) {
|
||||
return Math.max(0, Number(value));
|
||||
}
|
||||
|
||||
return 10;
|
||||
}
|
||||
|
||||
theme: ResolvedThemeInterface;
|
||||
scrollYOffset: () => number;
|
||||
hideHostname: boolean;
|
||||
|
@ -196,6 +207,7 @@ export class RedocNormalizedOptions {
|
|||
|
||||
ignoreNamedSchemas: Set<string>;
|
||||
hideSchemaPattern: boolean;
|
||||
generatedPayloadSamplesMaxDepth: number;
|
||||
|
||||
constructor(raw: RedocRawOptions, defaults: RedocRawOptions = {}) {
|
||||
raw = { ...defaults, ...raw };
|
||||
|
@ -257,5 +269,9 @@ export class RedocNormalizedOptions {
|
|||
: raw.ignoreNamedSchemas?.split(',').map((s) => s.trim());
|
||||
this.ignoreNamedSchemas = new Set(ignoreNamedSchemas);
|
||||
this.hideSchemaPattern = argValueToBoolean(raw.hideSchemaPattern);
|
||||
this.generatedPayloadSamplesMaxDepth =
|
||||
RedocNormalizedOptions.normalizeGeneratedPayloadSamplesMaxDepth(
|
||||
raw.generatedPayloadSamplesMaxDepth,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { OpenAPIParser } from '../OpenAPIParser';
|
||||
import { RedocNormalizedOptions } from '../RedocNormalizedOptions';
|
||||
import { OpenAPIParameter, Referenced } from '../../types';
|
||||
|
||||
const opts = new RedocNormalizedOptions({});
|
||||
|
||||
|
@ -13,5 +14,18 @@ describe('Models', () => {
|
|||
parser = new OpenAPIParser(spec, undefined, opts);
|
||||
expect(parser.mergeAllOf(spec.components.schemas.test)).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('should override description from $ref of the referenced component, when sibling description exists ', () => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const spec = require('./fixtures/siblingRefDescription.json');
|
||||
parser = new OpenAPIParser(spec, undefined, opts);
|
||||
const schemaOrRef: Referenced<OpenAPIParameter> = {
|
||||
$ref: '#/components/schemas/Test',
|
||||
description: 'Overriden description',
|
||||
};
|
||||
|
||||
expect(parser.shallowDeref(schemaOrRef)).toMatchSnapshot();
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
@ -86,3 +86,10 @@ Object {
|
|||
],
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Models Schema should override description from $ref of the referenced component, when sibling description exists 1`] = `
|
||||
Object {
|
||||
"description": "Overriden description",
|
||||
"type": "object",
|
||||
}
|
||||
`;
|
||||
|
|
39
src/services/__tests__/fixtures/siblingRefDescription.json
Normal file
39
src/services/__tests__/fixtures/siblingRefDescription.json
Normal file
|
@ -0,0 +1,39 @@
|
|||
{
|
||||
"openapi": "3.1.0",
|
||||
"info": {
|
||||
"title": "AA",
|
||||
"version": "1.0"
|
||||
},
|
||||
"paths": {
|
||||
"/test": {
|
||||
"get": {
|
||||
"operationId": "test",
|
||||
"responses": {
|
||||
"200": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"testAttr": {
|
||||
"description": "Overriden description",
|
||||
"$ref": "#/components/schemas/Test"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"Test": {
|
||||
"type": "object",
|
||||
"description": "Refed description"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
27
src/services/__tests__/models/RequestBody.test.ts
Normal file
27
src/services/__tests__/models/RequestBody.test.ts
Normal file
|
@ -0,0 +1,27 @@
|
|||
import { RequestBodyModel } from '../../models/RequestBody';
|
||||
import { OpenAPIParser } from '../../OpenAPIParser';
|
||||
import { RedocNormalizedOptions } from '../../RedocNormalizedOptions';
|
||||
|
||||
const opts = new RedocNormalizedOptions({});
|
||||
describe('Models', () => {
|
||||
describe('RequestBodyModel', () => {
|
||||
let parser, props;
|
||||
|
||||
beforeEach(() => {
|
||||
parser = new OpenAPIParser({ openapi: '3.0.0' } as any, undefined, opts);
|
||||
props = {
|
||||
parser,
|
||||
infoOrRef: {},
|
||||
options: opts,
|
||||
isEvent: false,
|
||||
};
|
||||
});
|
||||
|
||||
test('should work with default props', () => {
|
||||
const consoleError = jest.spyOn(global.console, 'error');
|
||||
const req = new RequestBodyModel(props);
|
||||
expect(consoleError).not.toHaveBeenCalled();
|
||||
expect(req).toEqual({ description: '', required: false });
|
||||
});
|
||||
});
|
||||
});
|
|
@ -5,30 +5,38 @@ import { RedocNormalizedOptions } from '../../RedocNormalizedOptions';
|
|||
const opts = new RedocNormalizedOptions({});
|
||||
describe('Models', () => {
|
||||
describe('ResponseModel', () => {
|
||||
let parser;
|
||||
let parser, props;
|
||||
|
||||
beforeEach(() => {
|
||||
parser = new OpenAPIParser({ openapi: '3.0.0' } as any, undefined, opts);
|
||||
props = {
|
||||
parser,
|
||||
defaultAsError: false,
|
||||
infoOrRef: {},
|
||||
options: opts,
|
||||
isEvent: false,
|
||||
code: 'default',
|
||||
};
|
||||
});
|
||||
|
||||
test('should calculate response type based on code', () => {
|
||||
let resp = new ResponseModel(parser, '200', false, {}, opts);
|
||||
let resp = new ResponseModel({...props, code: '200' });
|
||||
expect(resp.type).toEqual('success');
|
||||
resp = new ResponseModel(parser, '120', false, {}, opts);
|
||||
resp = new ResponseModel({...props, code: '120' });
|
||||
expect(resp.type).toEqual('info');
|
||||
resp = new ResponseModel(parser, '301', false, {}, opts);
|
||||
resp = new ResponseModel({...props, code: '301' });
|
||||
expect(resp.type).toEqual('redirect');
|
||||
resp = new ResponseModel(parser, '400', false, {}, opts);
|
||||
resp = new ResponseModel({...props, code: '400' });
|
||||
expect(resp.type).toEqual('error');
|
||||
});
|
||||
|
||||
test('default should be successful by default', () => {
|
||||
const resp = new ResponseModel(parser, 'default', false, {}, opts);
|
||||
const resp = new ResponseModel({...props, code: 'default' });
|
||||
expect(resp.type).toEqual('success');
|
||||
});
|
||||
|
||||
test('default should be error if defaultAsError is true', () => {
|
||||
const resp = new ResponseModel(parser, 'default', true, {}, opts);
|
||||
const resp = new ResponseModel({...props, code: 'default', defaultAsError: true });
|
||||
expect(resp.type).toEqual('error');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -14,6 +14,7 @@ export class MediaTypeModel {
|
|||
name: string;
|
||||
isRequestType: boolean;
|
||||
onlyRequiredInSamples: boolean;
|
||||
generatedPayloadSamplesMaxDepth: number;
|
||||
|
||||
/**
|
||||
* @param isRequestType needed to know if skipe RO/RW fields in objects
|
||||
|
@ -29,6 +30,7 @@ export class MediaTypeModel {
|
|||
this.isRequestType = isRequestType;
|
||||
this.schema = info.schema && new SchemaModel(parser, info.schema, '', options);
|
||||
this.onlyRequiredInSamples = options.onlyRequiredInSamples;
|
||||
this.generatedPayloadSamplesMaxDepth = options.generatedPayloadSamplesMaxDepth;
|
||||
if (info.examples !== undefined) {
|
||||
this.examples = mapValues(
|
||||
info.examples,
|
||||
|
@ -38,7 +40,7 @@ export class MediaTypeModel {
|
|||
this.examples = {
|
||||
default: new ExampleModel(
|
||||
parser,
|
||||
{ value: parser.shalowDeref(info.example) },
|
||||
{ value: parser.shallowDeref(info.example) },
|
||||
name,
|
||||
info.encoding,
|
||||
),
|
||||
|
@ -51,9 +53,9 @@ export class MediaTypeModel {
|
|||
generateExample(parser: OpenAPIParser, info: OpenAPIMediaType) {
|
||||
const samplerOptions = {
|
||||
skipReadOnly: this.isRequestType,
|
||||
skipNonRequired: this.isRequestType && this.onlyRequiredInSamples,
|
||||
skipWriteOnly: !this.isRequestType,
|
||||
maxSampleDepth: 10,
|
||||
skipNonRequired: this.isRequestType && this.onlyRequiredInSamples,
|
||||
maxSampleDepth: this.generatedPayloadSamplesMaxDepth,
|
||||
};
|
||||
if (this.schema && this.schema.oneOf) {
|
||||
this.examples = {};
|
||||
|
|
|
@ -76,6 +76,7 @@ export class OperationModel implements IMenuItem {
|
|||
extensions: Record<string, any>;
|
||||
isCallback: boolean;
|
||||
isWebhook: boolean;
|
||||
isEvent: boolean;
|
||||
|
||||
constructor(
|
||||
private parser: OpenAPIParser,
|
||||
|
@ -98,7 +99,8 @@ export class OperationModel implements IMenuItem {
|
|||
this.operationId = operationSpec.operationId;
|
||||
this.path = operationSpec.pathName;
|
||||
this.isCallback = isCallback;
|
||||
this.isWebhook = !!operationSpec.isWebhook;
|
||||
this.isWebhook = operationSpec.isWebhook;
|
||||
this.isEvent = this.isCallback || this.isWebhook;
|
||||
|
||||
this.name = getOperationSummary(operationSpec);
|
||||
|
||||
|
@ -171,8 +173,12 @@ export class OperationModel implements IMenuItem {
|
|||
@memoize
|
||||
get requestBody() {
|
||||
return (
|
||||
this.operationSpec.requestBody &&
|
||||
new RequestBodyModel(this.parser, this.operationSpec.requestBody, this.options)
|
||||
this.operationSpec.requestBody && new RequestBodyModel({
|
||||
parser: this.parser,
|
||||
infoOrRef: this.operationSpec.requestBody,
|
||||
options: this.options,
|
||||
isEvent: this.isEvent,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -240,13 +246,14 @@ export class OperationModel implements IMenuItem {
|
|||
return isStatusCode(code);
|
||||
}) // filter out other props (e.g. x-props)
|
||||
.map((code) => {
|
||||
return new ResponseModel(
|
||||
this.parser,
|
||||
return new ResponseModel({
|
||||
parser: this.parser,
|
||||
code,
|
||||
hasSuccessResponses,
|
||||
this.operationSpec.responses[code],
|
||||
this.options,
|
||||
);
|
||||
defaultAsError: hasSuccessResponses,
|
||||
infoOrRef: this.operationSpec.responses[code],
|
||||
options: this.options,
|
||||
isEvent: this.isEvent,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -4,22 +4,27 @@ import { OpenAPIParser } from '../OpenAPIParser';
|
|||
import { RedocNormalizedOptions } from '../RedocNormalizedOptions';
|
||||
import { MediaContentModel } from './MediaContent';
|
||||
|
||||
type RequestBodyProps = {
|
||||
parser: OpenAPIParser;
|
||||
infoOrRef: Referenced<OpenAPIRequestBody>;
|
||||
options: RedocNormalizedOptions;
|
||||
isEvent: boolean;
|
||||
}
|
||||
|
||||
export class RequestBodyModel {
|
||||
description: string;
|
||||
required: boolean;
|
||||
content?: MediaContentModel;
|
||||
|
||||
constructor(
|
||||
parser: OpenAPIParser,
|
||||
infoOrRef: Referenced<OpenAPIRequestBody>,
|
||||
options: RedocNormalizedOptions,
|
||||
) {
|
||||
constructor(props: RequestBodyProps) {
|
||||
const { parser, infoOrRef, options, isEvent } = props;
|
||||
const isRequest = isEvent ? false : true;
|
||||
const info = parser.deref(infoOrRef);
|
||||
this.description = info.description || '';
|
||||
this.required = !!info.required;
|
||||
parser.exitRef(infoOrRef);
|
||||
if (info.content !== undefined) {
|
||||
this.content = new MediaContentModel(parser, info.content, true, options);
|
||||
this.content = new MediaContentModel(parser, info.content, isRequest, options);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,15 @@ import { RedocNormalizedOptions } from '../RedocNormalizedOptions';
|
|||
import { FieldModel } from './Field';
|
||||
import { MediaContentModel } from './MediaContent';
|
||||
|
||||
type ResponseProps = {
|
||||
parser: OpenAPIParser,
|
||||
code: string,
|
||||
defaultAsError: boolean,
|
||||
infoOrRef: Referenced<OpenAPIResponse>,
|
||||
options: RedocNormalizedOptions,
|
||||
isEvent: boolean,
|
||||
}
|
||||
|
||||
export class ResponseModel {
|
||||
@observable
|
||||
expanded: boolean = false;
|
||||
|
@ -19,13 +28,9 @@ export class ResponseModel {
|
|||
type: string;
|
||||
headers: FieldModel[] = [];
|
||||
|
||||
constructor(
|
||||
parser: OpenAPIParser,
|
||||
code: string,
|
||||
defaultAsError: boolean,
|
||||
infoOrRef: Referenced<OpenAPIResponse>,
|
||||
options: RedocNormalizedOptions,
|
||||
) {
|
||||
constructor(props: ResponseProps) {
|
||||
const { parser, code, defaultAsError, infoOrRef, options, isEvent } = props;
|
||||
const isRequest = isEvent ? true : false;
|
||||
makeObservable(this);
|
||||
|
||||
this.expanded = options.expandResponses === 'all' || options.expandResponses[code];
|
||||
|
@ -34,7 +39,7 @@ export class ResponseModel {
|
|||
parser.exitRef(infoOrRef);
|
||||
this.code = code;
|
||||
if (info.content !== undefined) {
|
||||
this.content = new MediaContentModel(parser, info.content, false, options);
|
||||
this.content = new MediaContentModel(parser, info.content, isRequest, options);
|
||||
}
|
||||
|
||||
if (info['x-summary'] !== undefined) {
|
||||
|
|
|
@ -61,6 +61,10 @@ export class SchemaModel {
|
|||
schema: MergedOpenAPISchema;
|
||||
extensions?: Record<string, any>;
|
||||
const: any;
|
||||
contentEncoding?: string;
|
||||
contentMediaType?: string;
|
||||
minItems?: number;
|
||||
maxItems?: number;
|
||||
|
||||
/**
|
||||
* @param isChild if schema discriminator Child
|
||||
|
@ -98,6 +102,10 @@ export class SchemaModel {
|
|||
this.activeOneOf = idx;
|
||||
}
|
||||
|
||||
hasType(type: string) {
|
||||
return this.type === type || (Array.isArray(this.type) && this.type.includes(type));
|
||||
}
|
||||
|
||||
init(parser: OpenAPIParser, isChild: boolean) {
|
||||
const schema = this.schema;
|
||||
this.isCircular = schema['x-circular-ref'];
|
||||
|
@ -120,10 +128,16 @@ export class SchemaModel {
|
|||
this.readOnly = !!schema.readOnly;
|
||||
this.writeOnly = !!schema.writeOnly;
|
||||
this.const = schema.const || '';
|
||||
this.contentEncoding = schema.contentEncoding;
|
||||
this.contentMediaType = schema.contentMediaType;
|
||||
this.minItems = schema.minItems;
|
||||
this.maxItems = schema.maxItems;
|
||||
|
||||
if (!!schema.nullable) {
|
||||
if (Array.isArray(this.type) && !this.type.includes('null')) {
|
||||
if (!!schema.nullable || schema['x-nullable']) {
|
||||
if (Array.isArray(this.type) && !this.type.some((value) => value === null || value === 'null')) {
|
||||
this.type = [...this.type, 'null'];
|
||||
} else if (!Array.isArray(this.type) && (this.type !== null || this.type !== 'null')) {
|
||||
this.type = [this.type, 'null'];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -164,9 +178,9 @@ export class SchemaModel {
|
|||
return;
|
||||
}
|
||||
|
||||
if (this.type === 'object') {
|
||||
if (this.hasType('object')) {
|
||||
this.fields = buildFields(parser, schema, this.pointer, this.options);
|
||||
} else if ((this.type === 'array' || Array.isArray(this.type)) && schema.items) {
|
||||
} else if (this.hasType('array') && schema.items) {
|
||||
this.items = new SchemaModel(parser, schema.items, this.pointer + '/items', this.options);
|
||||
this.displayType = pluralizeType(this.items.displayType);
|
||||
this.displayFormat = this.items.format;
|
||||
|
@ -349,7 +363,7 @@ function buildFields(
|
|||
): FieldModel[] {
|
||||
const props = schema.properties || {};
|
||||
const additionalProps = schema.additionalProperties;
|
||||
const defaults = schema.default || {};
|
||||
const defaults = schema.default;
|
||||
let fields = Object.keys(props || []).map((fieldName) => {
|
||||
let field = props[fieldName];
|
||||
|
||||
|
@ -370,7 +384,7 @@ function buildFields(
|
|||
required,
|
||||
schema: {
|
||||
...field,
|
||||
default: field.default === undefined ? defaults[fieldName] : field.default,
|
||||
default: field.default === undefined && defaults ? defaults[fieldName] : field.default,
|
||||
},
|
||||
},
|
||||
$ref + '/properties/' + fieldName,
|
||||
|
|
|
@ -147,6 +147,8 @@ export interface OpenAPISchema {
|
|||
enum?: any[];
|
||||
example?: any;
|
||||
const?: string;
|
||||
contentEncoding?: string;
|
||||
contentMediaType?: string;
|
||||
}
|
||||
|
||||
export interface OpenAPIDiscriminator {
|
||||
|
|
|
@ -729,7 +729,9 @@ try {
|
|||
"schema": Object {
|
||||
"items": Object {
|
||||
"$ref": "#/components/schemas/Pet",
|
||||
"maxItems": 111,
|
||||
},
|
||||
"maxItems": 999,
|
||||
"type": "array",
|
||||
},
|
||||
},
|
||||
|
@ -2187,6 +2189,12 @@ Object {
|
|||
"id": Object {
|
||||
"$ref": "#/components/schemas/Id",
|
||||
},
|
||||
"image": Object {
|
||||
"contentEncoding": "base64",
|
||||
"contentMediaType": "image/png",
|
||||
"description": "User image",
|
||||
"type": "string",
|
||||
},
|
||||
"lastName": Object {
|
||||
"description": "User last name",
|
||||
"example": "Smith",
|
||||
|
@ -3239,6 +3247,26 @@ culpa qui officia deserunt mollit anim id est laborum.
|
|||
},
|
||||
},
|
||||
"responses": Object {
|
||||
"200": Object {
|
||||
"content": Object {
|
||||
"application/json": Object {
|
||||
"schema": Object {
|
||||
"items": Object {
|
||||
"items": Object {
|
||||
"type": "number",
|
||||
},
|
||||
"maxItems": 777,
|
||||
"minItems": 111,
|
||||
"type": "array",
|
||||
},
|
||||
"maxItems": 999,
|
||||
"minItems": 0,
|
||||
"type": "array",
|
||||
},
|
||||
},
|
||||
},
|
||||
"description": "Successful operation",
|
||||
},
|
||||
"201": Object {
|
||||
"content": Object {
|
||||
"application/json": Object {
|
||||
|
|
|
@ -412,10 +412,10 @@ describe('Utils', () => {
|
|||
|
||||
describe('openapi humanizeConstraints', () => {
|
||||
const itemConstraintSchema = (
|
||||
min: number | undefined = undefined,
|
||||
max: number | undefined = undefined,
|
||||
multipleOf: number | undefined = undefined,
|
||||
uniqueItems?: boolean,
|
||||
min?: number,
|
||||
max?: number,
|
||||
multipleOf?: number,
|
||||
uniqueItems?: boolean
|
||||
) => ({ type: 'array', minItems: min, maxItems: max, multipleOf, uniqueItems });
|
||||
|
||||
it('should not have a humanized constraint without schema constraints', () => {
|
||||
|
|
|
@ -15,10 +15,12 @@ import 'prismjs/components/prism-objectivec.js';
|
|||
import 'prismjs/components/prism-perl.js';
|
||||
import 'prismjs/components/prism-php.js';
|
||||
import 'prismjs/components/prism-python.js';
|
||||
import 'prismjs/components/prism-q.js';
|
||||
import 'prismjs/components/prism-ruby.js';
|
||||
import 'prismjs/components/prism-scala.js';
|
||||
import 'prismjs/components/prism-sql.js';
|
||||
import 'prismjs/components/prism-swift.js';
|
||||
import 'prismjs/components/prism-yaml.js';
|
||||
|
||||
const DEFAULT_LANG = 'clike';
|
||||
|
||||
|
|
|
@ -83,6 +83,8 @@ const schemaKeywordTypes = {
|
|||
maxLength: 'string',
|
||||
minLength: 'string',
|
||||
pattern: 'string',
|
||||
contentEncoding: 'string',
|
||||
contentMediaType: 'string',
|
||||
|
||||
items: 'array',
|
||||
maxItems: 'array',
|
||||
|
@ -503,13 +505,13 @@ export function mergeParams(
|
|||
): Array<Referenced<OpenAPIParameter>> {
|
||||
const operationParamNames = {};
|
||||
operationParams.forEach(param => {
|
||||
param = parser.shalowDeref(param);
|
||||
param = parser.shallowDeref(param);
|
||||
operationParamNames[param.name + '_' + param.in] = true;
|
||||
});
|
||||
|
||||
// filter out path params overridden by operation ones with the same name
|
||||
pathParams = pathParams.filter(param => {
|
||||
param = parser.shalowDeref(param);
|
||||
param = parser.shallowDeref(param);
|
||||
return !operationParamNames[param.name + '_' + param.in];
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user