diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000..14c63f2f --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,22 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: 'type: bug' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Minimal reproducible OpenAPI snippet(if possible)** + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 00000000..041bdc52 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' + +--- + +**Describe the problem to be solved** +A clear and concise description of what problem to be solved + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. \ No newline at end of file diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 00000000..4933c4f3 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,13 @@ +## What/Why/How? + +## Reference + +## Testing + +## Screenshots (optional) + +## Check yourself + +- [ ] Code is linted +- [ ] Tested +- [ ] All new/updated code is covered with tests diff --git a/.github/workflows/demo-deploy-s3.yml b/.github/workflows/demo-deploy-s3.yml deleted file mode 100644 index efb2ca19..00000000 --- a/.github/workflows/demo-deploy-s3.yml +++ /dev/null @@ -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 "/*" diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml new file mode 100644 index 00000000..514a3193 --- /dev/null +++ b/.github/workflows/e2e-tests.yml @@ -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 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..42afcc4c --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,45 @@ +name: Publish Docker image +on: + release: + types: [published] +jobs: + push_to_registry: + name: Push Docker image to GitHub Packages + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + steps: + - name: Check out the repo + uses: actions/checkout@v2 + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Prepare + id: prep + run: | + DOCKER_IMAGE=ghcr.io/redocly/redoc/cli + VERSION=edge + if [[ $GITHUB_REF == refs/tags/* ]]; then + VERSION=${GITHUB_REF#refs/tags/} + elif [[ $GITHUB_REF == refs/heads/* ]]; then + VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g') + elif [[ $GITHUB_REF == refs/pull/* ]]; then + VERSION=pr-${{ github.event.number }} + fi + TAGS="${DOCKER_IMAGE}:${VERSION}" + if [ "${{ github.event_name }}" = "push" ]; then + TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}" + fi + echo ::set-output name=version::${VERSION} + echo ::set-output name=tags::${TAGS} + echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ') + - name: Push to GitHub Packages + uses: docker/build-push-action@v2 + with: + context: ./cli + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.prep.outputs.tags }} diff --git a/.github/workflows/publish-cli.yml b/.github/workflows/publish-cli.yml new file mode 100644 index 00000000..9bfa3fff --- /dev/null +++ b/.github/workflows/publish-cli.yml @@ -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 }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..d1c9ccbf --- /dev/null +++ b/.github/workflows/publish.yml @@ -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 diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml index 6ff78faa..ba673bd0 100644 --- a/.github/workflows/sync.yml +++ b/.github/workflows/sync.yml @@ -14,3 +14,5 @@ jobs: uses: Redocly/repo-file-sync-action@master with: GH_PAT: ${{ secrets.GH_PAT }} + COMMIT_PREFIX: "sync:" + SKIP_PR: true diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 09e54a63..a0a0bbd1 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -9,4 +9,4 @@ jobs: - uses: actions/checkout@v1 - run: npm ci - run: npm run bundle - - run: npm test + - run: npm test \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 03ac1fa4..00000000 --- a/.travis.yml +++ /dev/null @@ -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 diff --git a/CHANGELOG.md b/CHANGELOG.md index 56d0b06f..b73fb105 100644 --- a/CHANGELOG.md +++ b/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) diff --git a/README.md b/README.md index e5db33c1..6d3f335a 100644 --- a/README.md +++ b/README.md @@ -1,62 +1,118 @@
- ReDoc logo + Redoc logo - **OpenAPI/Swagger-generated API Reference Documentation** + # Generate interactive API documentation from OpenAPI definitions [![Build Status](https://travis-ci.com/Redocly/redoc.svg?branch=master)](https://travis-ci.com/Redocly/redoc) [![Coverage Status](https://coveralls.io/repos/Redocly/redoc/badge.svg?branch=master&service=github)](https://coveralls.io/github/Redocly/redoc?branch=master) [![dependencies Status](https://david-dm.org/Redocly/redoc/status.svg)](https://david-dm.org/Redocly/redoc) [![devDependencies Status](https://david-dm.org/Redocly/redoc/dev-status.svg)](https://david-dm.org/Redocly/redoc#info=devDependencies) [![npm](http://img.shields.io/npm/v/redoc.svg)](https://www.npmjs.com/package/redoc) [![License](https://img.shields.io/npm/l/redoc.svg)](https://github.com/Redocly/redoc/blob/master/LICENSE) [![bundle size](http://img.badgesize.io/https://cdn.jsdelivr.net/npm/redoc/bundles/redoc.standalone.js?compression=gzip&max=300000)](https://cdn.jsdelivr.net/npm/redoc/bundles/redoc.standalone.js) [![npm](https://img.shields.io/npm/dm/redoc.svg)](https://www.npmjs.com/package/redoc) [![](https://data.jsdelivr.com/v1/package/npm/redoc/badge)](https://www.jsdelivr.com/package/npm/redoc) [![Docker Build Status](https://img.shields.io/docker/build/redocly/redoc.svg)](https://hub.docker.com/r/redocly/redoc/) - -
-**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 demo](https://raw.githubusercontent.com/Redocly/redoc/master/demo/redoc-demo.png) +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: -[Deploy to Github](https://github.com/Rebilly/generator-openapi-repo#generator-openapi-repo--) [ReDoc as a service](https://redoc.ly) [Customization services](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. + +![Redoc demo](https://raw.githubusercontent.com/Redocly/redoc/master/demo/redoc-demo.png) + +## 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`)
-![](docs/images/discriminator-demo.gif) -- OpenAPI 3.0 support -- Basic OpenAPI 3.1 support -- Neat **interactive** documentation for nested objects
-![](docs/images/nested-demo.gif) -- Code samples support (via vendor extension)
-![](docs/images/code-samples-demo.gif) - 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
+ ![](docs/images/nested-demo.gif) + +## Customization options +[Customization services](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`)
+ ![](docs/images/discriminator-demo.gif) +- Code samples support (via vendor extension)
+ ![](docs/images/code-samples-demo.gif) ## 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 - ReDoc + Redoc + {{{redocHead}}} + {{#unless disableGoogleFont}}{{/unless}} + + + {{{redocHTML}}} + + +``` + +#### Serve + +Serve with the `nativeScrollbars` option set to `true`: + +```bash +redoc-cli serve openapi/dist.yaml --options.nativeScrollbars +``` diff --git a/docs/quickstart/docker.md b/docs/quickstart/docker.md new file mode 100644 index 00000000..31539fdb --- /dev/null +++ b/docs/quickstart/docker.md @@ -0,0 +1,39 @@ +--- +title: Using the Redoc Docker image +--- + +# Using the Redoc Docker image + +Redoc is available as a pre-built Docker image in [Docker Hub](https://hub.docker.com/r/redocly/redoc/). + +If you have [Docker](https://docs.docker.com/get-docker/) installed, pull the image with the following command: + +```docker +docker pull redocly/redoc +``` + +Then run the image with the following command: + +```docker +docker run -p 8080:80 redocly/redoc +``` + +The preview starts on port 8080, based on the port used in the command, +and can be accessed at `http://localhost:8080`. +To exit the preview, use `control+C`. + +By default Redoc starts with a demo Swagger Petstore OpenAPI definition located at +http://petstore.swagger.io/v2/swagger.json. You can update this URL using +the environment variable `SPEC_URL`. + +For example: + +```bash +docker run -p 8080:80 -e SPEC_URL=https://api.example.com/openapi.json redocly/redoc +``` + +## Using a Dockerfile + +You can also create a Dockerfile with some predefined environment variables. Check out +a sample [Dockerfile](https://github.com/Redocly/redoc/blob/master/config/docker/Dockerfile) +in our code repo. \ No newline at end of file diff --git a/docs/quickstart/html.md b/docs/quickstart/html.md new file mode 100644 index 00000000..bfc8d267 --- /dev/null +++ b/docs/quickstart/html.md @@ -0,0 +1,214 @@ +--- +title: Using the Redoc HTML element +--- + +# Using the Redoc HTML element + +## TL;DR final code example + +```html + + + + Redoc + + + + + + + + + + + + + + +``` + +:::attention Running Redoc locally requires an HTTP server +Loading local OpenAPI definitions is impossible without running a web server because of issues with +[same-origin policy](https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy) and +other security reasons. +::: + +### Running Redoc locally + +If you want to view your Redoc output locally, you can simulate an HTTP server. + +#### Using Redocly OpenAPI CLI + +Redocly OpenAPI CLI is an open source command-line tool that includes a command +for simulating an HTTP server to provide a preview of your OpenAPI definition locally. + +If you have [OpenAPI CLI](https://redoc.ly/docs/cli/#installation-and-usage) installed, `cd` into your +project directory and run the following command: + +```bash +openapi preview-docs openapi.yaml +``` + +By default, without providing a port, the preview starts on port 8080, and can be accessed at `http://localhost:8080`. +To exit the preview, use `control+C`. + +#### Using Python + +If you have [Python 3](https://www.python.org/downloads/) installed, `cd` into your +project directory and run the following command: + +```python +python3 -m http.server +``` + +If you have [Python 2](https://www.python.org/downloads/) installed, `cd` into your +project directory and run the following command: + +```python +python -m SimpleHTTPServer 8000 +``` + +The output after entering the command provides the local URL where the preview can be accessed. +To exit the preview, use `control-C`. + +#### Using Node.js + +If you have [Node.js](https://nodejs.org/en/download/) installed, install `http-server` +using the following npm command: + +```bash +npm install -g http-server +``` + +Then, `cd` into your project directory and run the following command: + +```node +http-server +``` + +The output after entering the command provides the local URL where the preview can be accessed. +To exit the preview, use `control-C`. + +## Step 1 - Install Redoc + +You can install Redoc using one of the following package managers: + +- [npm](https://docs.npmjs.com/about-npm) +- [yarn](https://classic.yarnpkg.com/en/docs/getting-started) + +:::attention Initialize your package manager +If you do not have a `package.json` file in your project directory, +you need to add one by initializing npm or yarn in your project. Use the command `npm init` for npm, +or `yarn init` for yarn. These initialization commands will lead you through the process +of creating a `package.json` file in your project. + +For more information, see +[Creating a package.json file](https://docs.npmjs.com/creating-a-package-json-file) +in the npm documentation or [Yarn init](https://classic.yarnpkg.com/en/docs/cli/init/) +in the yarn documentation. + +::: + +### Install Redoc with yarn + +After navigating to your project directory in your terminal, use the following command: + +```bash +yarn add redoc +``` + +### Install Redoc with npm + +After navigating to your project directory in your terminal, use the following command: + +```bash +npm i redoc +``` + +## Step 2 - Reference the Redoc script + +You can reference the Redoc script using either a link to the files hosted on a CDN +or the files located in your `node modules` folder. + +### CDN link + +To reference the Redoc script with a CDN link: + +```html + +``` + +### Node modules link + +To reference the Redoc script with a node modules link: + +```html + +``` + +## Step 3 - Add the element + +You can add the element to your HTML page and reference your OpenAPI +definition using the `spec-url` attribute, or you can initialize Redoc using +a globally exposed Redoc object. + +### Using the `spec-url` attribute + +To add the element with the `spec-url` attribute: + +```html + +``` + +#### Examples + +```html + +``` + +You can also use a local file (JSON or YAML) in your project, for instance: + +```html + +``` + +### Using a Redoc object + +To add the element with a globally exposed Redoc object: + +```js +Redoc.init(specOrSpecUrl, options, element, callback) +``` +- `specOrSpecUrl`: Either a JSON object with the OpenAPI definition or a URL to the + definition in JSON or YAML format. +- `options`: See [options object](https://redoc.ly/docs/api-reference-docs/configuration/) reference. +- `element`: DOM element Redoc will be inserted into. +- `callback`(optional): Callback to be called after Redoc has been fully rendered. + It is also called on errors with `error` as the first argument. + +#### Examples + +```html + +``` + +You can also use a local file (JSON or YAML) in your project, for instance: + +```html + +``` \ No newline at end of file diff --git a/docs/quickstart/intro.md b/docs/quickstart/intro.md new file mode 100644 index 00000000..e23f9d00 --- /dev/null +++ b/docs/quickstart/intro.md @@ -0,0 +1,44 @@ +--- +title: Redoc quickstart guide +--- + +# Redoc quickstart guide + +This guide includes step-by-step instructions for how to get started using +Redoc to render your OpenAPI definition. + +Redoc offers multiple options for rendering your OpenAPI definition. +You should select the option that best fits your needs. + +The following options are supported: + +- **[Live demo](https://redocly.github.io/redoc/):** + The live demo offers a fast way to see how your OpenAPI will render with Redoc. +- **[HTML element](./html.md):** + Using the HTML element works well for typical website deployments. +- **[React component](./react.md):** + Using the React component is an option for users with a React-based application. +- **[Docker image](./docker.md):** + Using the Docker image works in a container-based deployment. +- **[CLI](./cli.md):** + Using the CLI is an option for users who prefer to use a command-line interface. + +## Before you start + +You will need an OpenAPI definition. For testing purposes, you can use one of the following sample OpenAPI definitions: +- OpenAPI 3.0 + - [Rebilly Users OpenAPI Definition](https://raw.githubusercontent.com/Rebilly/api-definitions/main/openapi/users.yaml) + - [Swagger Petstore Sample OpenAPI Definition](https://petstore3.swagger.io/api/v3/openapi.json) +- OpenAPI 2.0 + - [Thingful OpenAPI Definition](https://raw.githubusercontent.com/thingful/openapi-spec/master/spec/swagger.yaml) + - [Fitbit Plus OpenAPI Definition](https://raw.githubusercontent.com/TwineHealth/TwineDeveloperDocs/master/spec/swagger.yaml) + +For more information on the OpenAPI specification, refer to the [Learning OpenAPI 3](https://redoc.ly/docs/resources/learning-openapi/) +section in the documentation. + +## Live demo online + +If you want to see how ReDoc will render your OpenAPI definition, you can try it out online at https://redocly.github.io/redoc/. + +A version of the Swagger Petstore API is displayed by default. To test it with your own OpenAPI definition, enter the URL for your +definition and select the **TRY IT** button. diff --git a/docs/quickstart/react.md b/docs/quickstart/react.md new file mode 100644 index 00000000..ebc19845 --- /dev/null +++ b/docs/quickstart/react.md @@ -0,0 +1,78 @@ +--- +title: Using the Redoc React component +--- + +# Using the Redoc React component + +## Before you start + +Install the following dependencies required by Redoc if you do not already have them installed: + +- `react` +- `react-dom` +- `mobx` +- `styled-components` +- `core-js` + +If you have npm installed, you can install these dependencies using the following command: + +```js +npm i react react-dom mobx styled-components core-js +``` + +## Step 1 - Import the `RedocStandalone` component + +```js +import { RedocStandalone } from 'redoc'; +``` + +## Step 2 - Use the component + +You can either link to your OpenAPI definition with a URL, using the following format: + +```react + +``` + +Or you can pass your OpenAPI definition as an object, using the following format: + +```js + +``` + +## Optional - Pass options + +Options can be passed into the RedocStandalone component to alter how it renders. + +For example: + +```js + +``` + +For more information on configuration options, refer to the +[Configuration options for Reference docs](https://redoc.ly/docs/api-reference-docs/configuration/) +section of the documentation. Options available for Redoc are noted, +"Supported in Redoc CE". + +## Optional - Specify `onLoaded` callback + +You can also specify the `onLoaded` callback, which is called each time Redoc +is fully rendered or when an error occurs (with an error as the first argument). + +```js + { + if (!error) { + console.log('Yay!'); + } + }} +/> +``` diff --git a/docs/sidebars.yaml b/docs/sidebars.yaml new file mode 100644 index 00000000..2189f25b --- /dev/null +++ b/docs/sidebars.yaml @@ -0,0 +1,13 @@ +redoc: + - group: Quickstart + expanded: false + page: redoc/quickstart/intro.md + pages: + - label: HTML element + page: redoc/quickstart/html.md + - label: React component + page: redoc/quickstart/react.md + - label: Docker image + page: redoc/quickstart/docker.md + - label: Command-line interface + page: redoc/quickstart/cli.md \ No newline at end of file diff --git a/e2e/integration/menu.e2e.ts b/e2e/integration/menu.e2e.ts index e1b053d1..533fb0ea 100644 --- a/e2e/integration/menu.e2e.ts +++ b/e2e/integration/menu.e2e.ts @@ -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'); diff --git a/package-lock.json b/package-lock.json index 5601ef16..41b9dcc2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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", diff --git a/package.json b/package.json index 6f85f321..b4fb9912 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/components/ApiInfo/ApiInfo.tsx b/src/components/ApiInfo/ApiInfo.tsx index ae4b4b20..6debaf7e 100644 --- a/src/components/ApiInfo/ApiInfo.tsx +++ b/src/components/ApiInfo/ApiInfo.tsx @@ -14,6 +14,7 @@ import { InfoSpanBox, InfoSpanBoxWrap, } from './styled.elements'; +import { l } from '../../services/Labels'; export interface ApiInfoProps { store: AppStore; @@ -79,14 +80,14 @@ export class ApiInfo extends React.Component { {!hideDownloadButton && (

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

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