Initial commit (as a partial copy of md:quality)
This commit is contained in:
1
public/static/js/README.md
Normal file
1
public/static/js/README.md
Normal file
@ -0,0 +1 @@
|
||||
# JS for building the web interface of the quality assessment tools of md
|
1129
public/static/js/qa.js
Normal file
1129
public/static/js/qa.js
Normal file
File diff suppressed because it is too large
Load Diff
1
public/static/js/qa.min.js
vendored
Normal file
1
public/static/js/qa.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
public/static/js/swagger/swagger-ui-5.17.14/.agignore
Normal file
1
public/static/js/swagger/swagger-ui-5.17.14/.agignore
Normal file
@ -0,0 +1 @@
|
||||
dist/
|
29
public/static/js/swagger/swagger-ui-5.17.14/.browserslistrc
Normal file
29
public/static/js/swagger/swagger-ui-5.17.14/.browserslistrc
Normal file
@ -0,0 +1,29 @@
|
||||
[node-production]
|
||||
maintained node versions
|
||||
|
||||
[node-development]
|
||||
node 20.3.0
|
||||
|
||||
[browser-production]
|
||||
> 1%
|
||||
last 2 versions
|
||||
Firefox ESR
|
||||
not dead
|
||||
|
||||
[browser-development]
|
||||
last 1 chrome version
|
||||
last 1 firefox version
|
||||
last 1 safari version
|
||||
|
||||
[isomorphic-production]
|
||||
> 1%
|
||||
last 2 versions
|
||||
Firefox ESR
|
||||
not dead
|
||||
maintained node versions
|
||||
|
||||
[isomorphic-development]
|
||||
last 1 chrome version
|
||||
last 1 firefox version
|
||||
last 1 safari version
|
||||
node 20.3.0
|
@ -0,0 +1,25 @@
|
||||
{
|
||||
"extends": [
|
||||
"@commitlint/config-conventional"
|
||||
],
|
||||
"rules": {
|
||||
"header-max-length": [
|
||||
2,
|
||||
"always",
|
||||
69
|
||||
],
|
||||
"scope-case": [
|
||||
2,
|
||||
"always",
|
||||
[
|
||||
"camel-case",
|
||||
"kebab-case",
|
||||
"upper-case"
|
||||
]
|
||||
],
|
||||
"subject-case": [
|
||||
0,
|
||||
"always"
|
||||
]
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
/.git
|
||||
/.github
|
||||
/dev-helpers
|
||||
/docs
|
||||
/src
|
||||
/swagger-ui-dist-package
|
||||
/test
|
||||
/node_modules
|
10
public/static/js/swagger/swagger-ui-5.17.14/.editorconfig
Normal file
10
public/static/js/swagger/swagger-ui-5.17.14/.editorconfig
Normal file
@ -0,0 +1,10 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
end_of_line = lf
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
@ -0,0 +1,3 @@
|
||||
dist/
|
||||
node_modules/
|
||||
test/e2e-selenium/
|
38
public/static/js/swagger/swagger-ui-5.17.14/.eslintrc
Normal file
38
public/static/js/swagger/swagger-ui-5.17.14/.eslintrc
Normal file
@ -0,0 +1,38 @@
|
||||
parser: "@babel/eslint-parser"
|
||||
env:
|
||||
browser: true
|
||||
node: true
|
||||
es6: true
|
||||
jest: true
|
||||
jest/globals: true
|
||||
parserOptions:
|
||||
ecmaFeatures:
|
||||
jsx: true
|
||||
extends:
|
||||
- eslint:recommended
|
||||
- plugin:react/recommended
|
||||
plugins:
|
||||
- react
|
||||
- import
|
||||
- jest
|
||||
settings:
|
||||
react:
|
||||
pragma: React
|
||||
version: '15.0'
|
||||
rules:
|
||||
semi: [2, never]
|
||||
strict: 0
|
||||
quotes: [2, double, { avoidEscape: true, allowTemplateLiterals: true }]
|
||||
no-unused-vars: 2
|
||||
no-multi-spaces: 1
|
||||
camelcase: 1
|
||||
no-use-before-define: [2, nofunc]
|
||||
no-underscore-dangle: 0
|
||||
no-unused-expressions: 1
|
||||
comma-dangle: 0
|
||||
no-console: [2, { allow: [warn, error] }]
|
||||
react/jsx-no-bind: 1
|
||||
react/jsx-no-target-blank: 2
|
||||
react/display-name: 0
|
||||
import/no-extraneous-dependencies: 2
|
||||
react/jsx-filename-extension: 2
|
1
public/static/js/swagger/swagger-ui-5.17.14/.gitattributes
vendored
Normal file
1
public/static/js/swagger/swagger-ui-5.17.14/.gitattributes
vendored
Normal file
@ -0,0 +1 @@
|
||||
docker-run.sh text eol=lf
|
73
public/static/js/swagger/swagger-ui-5.17.14/.github/ISSUE_TEMPLATE/Bug_report.md
vendored
Normal file
73
public/static/js/swagger/swagger-ui-5.17.14/.github/ISSUE_TEMPLATE/Bug_report.md
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Report an issue you're experiencing
|
||||
|
||||
---
|
||||
|
||||
<!---
|
||||
Thanks for filing a bug report! 😄
|
||||
|
||||
Before you submit, please read the following:
|
||||
|
||||
If you're here to report a security issue, please STOP writing an issue and
|
||||
contact us at security@swagger.io instead!
|
||||
|
||||
Search open/closed issues before submitting!
|
||||
|
||||
Issues on GitHub are only related to problems of Swagger-UI itself. We'll try
|
||||
to offer support here for your use case, but we can't offer help with projects
|
||||
that use Swagger-UI indirectly, like Springfox or swagger-node.
|
||||
|
||||
Likewise, we can't accept bugs in the Swagger/OpenAPI specifications
|
||||
themselves, or anything that violates the specifications.
|
||||
-->
|
||||
|
||||
### Q&A (please complete the following information)
|
||||
- OS: [e.g. macOS]
|
||||
- Browser: [e.g. chrome, safari]
|
||||
- Version: [e.g. 22]
|
||||
- Method of installation: [e.g. npm, dist assets]
|
||||
- Swagger-UI version: [e.g. 3.10.0]
|
||||
- Swagger/OpenAPI version: [e.g. Swagger 2.0, OpenAPI 3.0]
|
||||
|
||||
### Content & configuration
|
||||
<!--
|
||||
Provide us with a way to see what you're seeing,
|
||||
so that we can fix your issue.
|
||||
-->
|
||||
|
||||
Example Swagger/OpenAPI definition:
|
||||
```yaml
|
||||
# your YAML here
|
||||
```
|
||||
|
||||
Swagger-UI configuration options:
|
||||
```js
|
||||
SwaggerUI({
|
||||
// your config options here
|
||||
})
|
||||
```
|
||||
|
||||
```
|
||||
?yourQueryStringConfig
|
||||
```
|
||||
|
||||
### Describe the bug you're encountering
|
||||
<!-- A clear and concise description of what the bug is. -->
|
||||
|
||||
### To reproduce...
|
||||
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
### Expected behavior
|
||||
<!-- A clear and concise description of what you expected to happen. -->
|
||||
|
||||
### Screenshots
|
||||
<!-- If applicable, add screenshots to help explain your problem. -->
|
||||
|
||||
### Additional context or thoughts
|
||||
<!-- Add any other context about the problem here. -->
|
42
public/static/js/swagger/swagger-ui-5.17.14/.github/ISSUE_TEMPLATE/Feature_request.md
vendored
Normal file
42
public/static/js/swagger/swagger-ui-5.17.14/.github/ISSUE_TEMPLATE/Feature_request.md
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest a new feature or enhancement for this project
|
||||
|
||||
---
|
||||
|
||||
### Content & configuration
|
||||
|
||||
Swagger/OpenAPI definition:
|
||||
```yaml
|
||||
# your YAML here
|
||||
```
|
||||
|
||||
Swagger-UI configuration options:
|
||||
```js
|
||||
SwaggerUI({
|
||||
// your config options here
|
||||
})
|
||||
```
|
||||
|
||||
```
|
||||
?yourQueryStringConfig
|
||||
```
|
||||
|
||||
|
||||
### Is your feature request related to a problem?
|
||||
<!--
|
||||
Please provide a clear and concise description of what the problem is.
|
||||
"I'm always frustrated when..."
|
||||
-->
|
||||
|
||||
### 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. -->
|
46
public/static/js/swagger/swagger-ui-5.17.14/.github/ISSUE_TEMPLATE/Support.md
vendored
Normal file
46
public/static/js/swagger/swagger-ui-5.17.14/.github/ISSUE_TEMPLATE/Support.md
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
---
|
||||
name: Support
|
||||
about: Ask a question or request help with your implementation.
|
||||
|
||||
---
|
||||
|
||||
<!--
|
||||
We can only offer support for Swagger-UI itself.
|
||||
|
||||
If you're having a problem with a library that uses Swagger-UI
|
||||
(for example, Springfox or swagger-node), please open an issue
|
||||
in that project's repository instead.
|
||||
-->
|
||||
|
||||
### Q&A (please complete the following information)
|
||||
- OS: [e.g. macOS]
|
||||
- Browser: [e.g. chrome, safari]
|
||||
- Version: [e.g. 22]
|
||||
- Method of installation: [e.g. npm, dist assets]
|
||||
- Swagger-UI version: [e.g. 3.10.0]
|
||||
- Swagger/OpenAPI version: [e.g. Swagger 2.0, OpenAPI 3.0]
|
||||
|
||||
### Content & configuration
|
||||
<!-- Provide us with a way to see what you're seeing, so that we can help. -->
|
||||
|
||||
Swagger/OpenAPI definition:
|
||||
```yaml
|
||||
# your YAML here
|
||||
```
|
||||
|
||||
Swagger-UI configuration options:
|
||||
```js
|
||||
SwaggerUI({
|
||||
// your config options here
|
||||
})
|
||||
```
|
||||
|
||||
```
|
||||
?yourQueryStringConfig
|
||||
```
|
||||
|
||||
### Screenshots
|
||||
<!-- If applicable, add screenshots to help give context to your problem. -->
|
||||
|
||||
### How can we help?
|
||||
<!-- Your question or problem goes here! -->
|
35
public/static/js/swagger/swagger-ui-5.17.14/.github/dependabot.yaml
vendored
Normal file
35
public/static/js/swagger/swagger-ui-5.17.14/.github/dependabot.yaml
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: npm
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: daily
|
||||
time: "23:00"
|
||||
commit-message:
|
||||
prefix: "chore"
|
||||
include: "scope"
|
||||
open-pull-requests-limit: 3
|
||||
ignore:
|
||||
# node-fetch must be synced manually
|
||||
- dependency-name: "node-fetch"
|
||||
|
||||
- package-ecosystem: "docker"
|
||||
# Look for a `Dockerfile` in the `root` directory
|
||||
directory: "/"
|
||||
# Check for updates once a week
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
time: "23:00"
|
||||
|
||||
- package-ecosystem: "github-actions"
|
||||
target-branch: "master"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
time: "23:00"
|
||||
commit-message:
|
||||
prefix: "chore"
|
||||
include: "scope"
|
||||
open-pull-requests-limit: 3
|
||||
|
||||
|
15
public/static/js/swagger/swagger-ui-5.17.14/.github/lock.yml
vendored
Normal file
15
public/static/js/swagger/swagger-ui-5.17.14/.github/lock.yml
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
daysUntilLock: 365
|
||||
skipCreatedBefore: 2017-03-29 # initial release of Swagger UI 3.0.0
|
||||
exemptLabels: []
|
||||
lockLabel: "locked-by: lock-bot"
|
||||
setLockReason: false
|
||||
only: issues
|
||||
lockComment: false
|
||||
# lockComment: |
|
||||
# Locking due to inactivity.
|
||||
|
||||
# This is done to avoid resurrecting old issues and bumping long threads with new, possibly unrelated content.
|
||||
|
||||
# If you think you're experiencing something similar to what you've found here: please [open a new issue](https://github.com/swagger-api/swagger-ui/issues/new/choose), follow the template, and reference this issue in your report.
|
||||
|
||||
# Thanks!
|
55
public/static/js/swagger/swagger-ui-5.17.14/.github/pull_request_template.md
vendored
Normal file
55
public/static/js/swagger/swagger-ui-5.17.14/.github/pull_request_template.md
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
<!--- Provide a general summary of your changes in the Title above -->
|
||||
|
||||
### Description
|
||||
<!--- Describe your changes in detail -->
|
||||
|
||||
|
||||
|
||||
### Motivation and Context
|
||||
<!--- Why is this change required? What problem does it solve? -->
|
||||
<!--- If it fixes an open issue, please link to the issue here. -->
|
||||
<!--- Use the magic "Fixes #1234" format, so the issues are -->
|
||||
<!--- automatically closed when this PR is merged. -->
|
||||
|
||||
|
||||
|
||||
### How Has This Been Tested?
|
||||
<!--- Please describe in detail how you manually tested your changes. -->
|
||||
<!--- Include details of your testing environment, and the tests you ran to -->
|
||||
<!--- see how your change affects other areas of the code, etc. -->
|
||||
|
||||
|
||||
|
||||
### Screenshots (if appropriate):
|
||||
|
||||
|
||||
|
||||
## Checklist
|
||||
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
|
||||
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
|
||||
|
||||
### My PR contains...
|
||||
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
|
||||
- [ ] No code changes (`src/` is unmodified: changes to documentation, CI, metadata, etc.)
|
||||
- [ ] Dependency changes (any modification to dependencies in `package.json`)
|
||||
- [ ] Bug fixes (non-breaking change which fixes an issue)
|
||||
- [ ] Improvements (misc. changes to existing features)
|
||||
- [ ] Features (non-breaking change which adds functionality)
|
||||
|
||||
### My changes...
|
||||
- [ ] are breaking changes to a public API (config options, System API, major UI change, etc).
|
||||
- [ ] are breaking changes to a private API (Redux, component props, utility functions, etc.).
|
||||
- [ ] are breaking changes to a developer API (npm script behavior changes, new dev system dependencies, etc).
|
||||
- [ ] are not breaking changes.
|
||||
|
||||
### Documentation
|
||||
- [ ] My changes do not require a change to the project documentation.
|
||||
- [ ] My changes require a change to the project documentation.
|
||||
- [ ] If yes to above: I have updated the documentation accordingly.
|
||||
|
||||
### Automated tests
|
||||
- [ ] My changes can not or do not need to be tested.
|
||||
- [ ] My changes can and should be tested by unit and/or integration tests.
|
||||
- [ ] If yes to above: I have added tests to cover my changes.
|
||||
- [ ] If yes to above: I have taken care to cover edge cases in my tests.
|
||||
- [ ] All new and existing tests passed.
|
63
public/static/js/swagger/swagger-ui-5.17.14/.github/workflows/codeql.yml
vendored
Normal file
63
public/static/js/swagger/swagger-ui-5.17.14/.github/workflows/codeql.yml
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
# For most projects, this workflow file will not need changing; you simply need
|
||||
# to commit it to your repository.
|
||||
#
|
||||
# You may wish to alter this file to override the set of languages analyzed,
|
||||
# or to provide custom queries or build logic.
|
||||
#
|
||||
# ******** NOTE ********
|
||||
# We have attempted to detect the languages in your repository. Please check
|
||||
# the `language` matrix defined below to confirm you have the correct set of
|
||||
# supported CodeQL languages.
|
||||
#
|
||||
name: "CodeQL"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "master" ]
|
||||
pull_request:
|
||||
# The branches below must be a subset of the branches above
|
||||
branches: [ "master" ]
|
||||
schedule:
|
||||
- cron: '16 04 * * 2'
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
security-events: write
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: [ 'javascript' ]
|
||||
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
|
||||
# Use only 'java' to analyze code written in Java, Kotlin or both
|
||||
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
|
||||
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v3
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
# By default, queries listed here will override any specified in a config file.
|
||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||
|
||||
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
|
||||
# queries: security-extended,security-and-quality
|
||||
config: |
|
||||
paths-ignore:
|
||||
- 'dist/'
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v3
|
||||
with:
|
||||
category: "/language:${{matrix.language}}"
|
40
public/static/js/swagger/swagger-ui-5.17.14/.github/workflows/dependabot-merge.yml
vendored
Normal file
40
public/static/js/swagger/swagger-ui-5.17.14/.github/workflows/dependabot-merge.yml
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
name: Merge me!
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
branches: [ master, next ]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
merge-me:
|
||||
name: Merge me!
|
||||
if: github.actor == 'dependabot[bot]'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
# This first step will fail if there's no metadata and so the approval
|
||||
# will not occur.
|
||||
- name: Dependabot metadata
|
||||
id: dependabot-metadata
|
||||
uses: dependabot/fetch-metadata@v2.1.0
|
||||
with:
|
||||
github-token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
# Here the PR gets approved.
|
||||
- name: Approve a PR
|
||||
if: ${{ steps.dependabot-metadata.outputs.update-type != 'version-update:semver-major' }}
|
||||
run: gh pr review --approve "$PR_URL"
|
||||
env:
|
||||
PR_URL: ${{ github.event.pull_request.html_url }}
|
||||
GITHUB_TOKEN: ${{ secrets.SWAGGER_BOT_GITHUB_TOKEN }}
|
||||
# Finally, tell dependabot to merge the PR if all checks are successful
|
||||
- name: Instruct dependabot to squash & merge
|
||||
if: ${{ steps.dependabot-metadata.outputs.update-type != 'version-update:semver-major' }}
|
||||
uses: mshick/add-pr-comment@v2
|
||||
with:
|
||||
repo-token: ${{ secrets.SWAGGER_BOT_GITHUB_TOKEN }}
|
||||
allow-repeats: true
|
||||
message: |
|
||||
@dependabot squash and merge
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.SWAGGER_BOT_GITHUB_TOKEN }}
|
143
public/static/js/swagger/swagger-ui-5.17.14/.github/workflows/docker-build-push.yml
vendored
Normal file
143
public/static/js/swagger/swagger-ui-5.17.14/.github/workflows/docker-build-push.yml
vendored
Normal file
@ -0,0 +1,143 @@
|
||||
# inspired by https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
|
||||
name: Build & Push SwaggerUI multi platform Docker image
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
git_ref:
|
||||
description: Git branch, tag or SHA to checkout.
|
||||
type: string
|
||||
required: true
|
||||
docker_tag:
|
||||
description: Docker tag associated with the `git_ref`
|
||||
type: string
|
||||
required: true
|
||||
|
||||
repository_dispatch:
|
||||
type: [docker_build_push]
|
||||
|
||||
env:
|
||||
REGISTRY_IMAGE: swaggerapi/swagger-ui
|
||||
|
||||
jobs:
|
||||
inputs:
|
||||
name: Normalize inputs
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
git_ref: ${{ steps.workflow_dispatch.outputs.git_ref || steps.repository_dispatch.outputs.git_ref }}
|
||||
docker_tag: ${{ steps.workflow_dispatch.outputs.docker_tag || steps.repository_dispatch.outputs.docker_tag }}
|
||||
|
||||
steps:
|
||||
- name: Normalize inputs of `workflow_dispatch` event
|
||||
id: workflow_dispatch
|
||||
if: ${{ github.event_name == 'workflow_dispatch' }}
|
||||
run: |
|
||||
echo "git_ref=${{ inputs.git_ref }}" >> "$GITHUB_OUTPUT"
|
||||
echo "docker_tag=${{ inputs.docker_tag }}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Normalize inputs of `repository_dispatch` event
|
||||
id: repository_dispatch
|
||||
if: ${{ github.event_name == 'repository_dispatch' }}
|
||||
run: |
|
||||
echo "git_ref=${{ github.event.client_payload.git_ref }}" >> "$GITHUB_OUTPUT"
|
||||
echo "docker_tag=${{ github.event.client_payload.docker_tag }}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
|
||||
|
||||
build:
|
||||
name: Build & Push SwaggerUI platform specific Docker images
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
platform:
|
||||
# linux/amd64 is already built by Jenkins
|
||||
- linux/arm/v6
|
||||
- linux/arm64
|
||||
- linux/386
|
||||
- linux/ppc64le
|
||||
needs:
|
||||
- inputs
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ needs.inputs.outputs.git_ref }}
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Log in to DockerHub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_SB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_SB_PASSWORD }}
|
||||
|
||||
- name: Build and push by digest
|
||||
id: build
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
platforms: ${{ matrix.platform }}
|
||||
provenance: false
|
||||
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
|
||||
|
||||
- name: Export digest
|
||||
run: |
|
||||
mkdir -p /tmp/digests
|
||||
digest="${{ steps.build.outputs.digest }}"
|
||||
touch "/tmp/digests/${digest#sha256:}"
|
||||
|
||||
- name: Sanitize platform variable
|
||||
id: sanitize_platform
|
||||
run: |
|
||||
SANITIZED_PLATFORM="${{ matrix.platform }}" # Assuming direct usage for simplicity
|
||||
SANITIZED_PLATFORM="${SANITIZED_PLATFORM//[^a-zA-Z0-9_-]/}" # Remove special chars
|
||||
echo "SANITIZED_PLATFORM=${SANITIZED_PLATFORM}" # Echo for debug
|
||||
echo "::set-output name=sanitized_platform::${SANITIZED_PLATFORM}"
|
||||
|
||||
- name: Upload digest
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: digest-${{ steps.sanitize_platform.outputs.sanitized_platform }}
|
||||
path: /tmp/digests/*
|
||||
if-no-files-found: error
|
||||
retention-days: 1
|
||||
|
||||
merge:
|
||||
name: Merge platform specific Docker image into multi platform image
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- inputs
|
||||
- build
|
||||
|
||||
steps:
|
||||
- name: Download digests
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
pattern: digest-*
|
||||
path: /tmp/digests
|
||||
merge-multiple: true
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_SB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_SB_PASSWORD }}
|
||||
|
||||
- name: Create manifest list and push
|
||||
working-directory: /tmp/digests
|
||||
run: |
|
||||
docker buildx imagetools create -t ${{ env.REGISTRY_IMAGE }}:${{ needs.inputs.outputs.docker_tag }} \
|
||||
${{ env.REGISTRY_IMAGE }}:${{ needs.inputs.outputs.docker_tag }} \
|
||||
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
|
||||
|
||||
- name: Inspect image
|
||||
run: |
|
||||
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ needs.inputs.outputs.docker_tag }}
|
23
public/static/js/swagger/swagger-ui-5.17.14/.github/workflows/docker-image-check.yml
vendored
Normal file
23
public/static/js/swagger/swagger-ui-5.17.14/.github/workflows/docker-image-check.yml
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
name: Security scan for docker image
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: '30 4 * * *'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Run Trivy vulnerability scanner
|
||||
uses: aquasecurity/trivy-action@master
|
||||
with:
|
||||
image-ref: 'docker.io/swaggerapi/swagger-ui:unstable'
|
||||
format: 'table'
|
||||
exit-code: '1'
|
||||
ignore-unfixed: true
|
||||
vuln-type: 'os,library'
|
||||
severity: 'CRITICAL,HIGH'
|
86
public/static/js/swagger/swagger-ui-5.17.14/.github/workflows/nodejs.yml
vendored
Normal file
86
public/static/js/swagger/swagger-ui-5.17.14/.github/workflows/nodejs.yml
vendored
Normal file
@ -0,0 +1,86 @@
|
||||
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
|
||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
|
||||
|
||||
name: Node.js CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master, next ]
|
||||
pull_request:
|
||||
branches: [ master, next ]
|
||||
|
||||
env:
|
||||
CYPRESS_CACHE_FOLDER: cypress/cache
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Use Node.js 20.x
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- name: Cache Node Modules and Cypress binary
|
||||
uses: actions/cache@v4
|
||||
id: cache-primes
|
||||
with:
|
||||
path: |
|
||||
node_modules
|
||||
${{ env.CYPRESS_CACHE_FOLDER }}
|
||||
key: ${{ runner.os }}-node-and-cypress-${{ hashFiles('package-lock.json') }}
|
||||
|
||||
- name: Install dependencies
|
||||
if: steps.cache-primes.outputs.cache-hit != 'true'
|
||||
run: npm ci
|
||||
|
||||
- name: Lint code for errors only
|
||||
run: npm run lint-errors
|
||||
|
||||
- name: Run all tests
|
||||
run: npm run test:unit
|
||||
env:
|
||||
CI: true
|
||||
|
||||
- name: Build SwaggerUI
|
||||
run: npm run build
|
||||
|
||||
- name: Test build artifacts
|
||||
run: npm run test:artifact
|
||||
|
||||
e2e-tests:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
containers: ['+(a11y|security|bugs)/**/*cy.js', 'features/**/+(o|d)*.cy.js', 'features/**/m*.cy.js', 'features/**/!(o|d|m)*.cy.js']
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Use Node.js 20.x
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- name: Cache Node Modules and Cypress binary
|
||||
uses: actions/cache@v4
|
||||
id: cache-primes
|
||||
with:
|
||||
path: |
|
||||
node_modules
|
||||
${{ env.CYPRESS_CACHE_FOLDER }}
|
||||
key: ${{ runner.os }}-node-and-cypress-${{ hashFiles('package-lock.json') }}
|
||||
|
||||
- name: Install dependencies
|
||||
if: steps.cache-primes.outputs.cache-hit != 'true'
|
||||
run: npm ci
|
||||
|
||||
- name: Cypress Test
|
||||
run: npx start-server-and-test cy:start http://localhost:3204 'npm run cy:run -- --spec "test/e2e-cypress/e2e/${{ matrix.containers }}"'
|
79
public/static/js/swagger/swagger-ui-5.17.14/.github/workflows/release-swagger-ui-react.yml
vendored
Normal file
79
public/static/js/swagger/swagger-ui-5.17.14/.github/workflows/release-swagger-ui-react.yml
vendored
Normal file
@ -0,0 +1,79 @@
|
||||
name: Build & Release SwaggerUI-React@next
|
||||
|
||||
# single-stage
|
||||
on:
|
||||
workflow_dispatch:
|
||||
branches:
|
||||
- next
|
||||
|
||||
# multi-stage automation
|
||||
# on:
|
||||
# workflow_run:
|
||||
# workflows: ["Release SwaggerUI@next"]
|
||||
# types:
|
||||
# - completed
|
||||
# branches: [next]
|
||||
|
||||
defaults:
|
||||
run:
|
||||
working-directory: flavors/swagger-ui-react/release
|
||||
jobs:
|
||||
release-swagger-ui-react:
|
||||
name: Release SwaggerUI React
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
ref: next
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- name: Prepare SwaggerUI dist
|
||||
run: |
|
||||
cd ../../../
|
||||
npm ci
|
||||
npm run build
|
||||
|
||||
- name: Install dependencies (to create package manifest)
|
||||
run: npm ci
|
||||
|
||||
- name: MKDIR `dist` working directory
|
||||
run: mkdir -p ../dist
|
||||
|
||||
- name: Copy SwaggerUI dist files to MKDIR
|
||||
run: |
|
||||
ls ../dist
|
||||
cp ../../../dist/swagger-ui-es-bundle-core.js ../dist
|
||||
cp ../../../dist/swagger-ui-es-bundle-core.js.map ../dist
|
||||
cp ../../../dist/swagger-ui.css ../dist
|
||||
cp ../../../dist/swagger-ui.css.map ../dist
|
||||
|
||||
- name: Create a releasable package manifest
|
||||
run: node create-manifest.js > ../dist/package.json
|
||||
|
||||
- name: Transpile our top-level React Component
|
||||
run: |
|
||||
../../../node_modules/.bin/cross-env BABEL_ENV=commonjs ../../../node_modules/.bin/babel --config-file ../../../babel.config.js ../index.jsx > ../dist/commonjs.js
|
||||
../../../node_modules/.bin/cross-env BABEL_ENV=es ../../../node_modules/.bin/babel --config-file ../../../babel.config.js ../index.jsx > ../dist/index.js
|
||||
|
||||
- name: Copy our README into the dist folder for npm
|
||||
run: cp ../README.md ../dist
|
||||
|
||||
- name: Copy LICENSE & NOTICE into the dist folder for npm
|
||||
run: |
|
||||
cp ../../../LICENSE ../dist
|
||||
cp ../../../NOTICE ../dist
|
||||
|
||||
- name: Run the release from the dist folder
|
||||
run: |
|
||||
cd ../dist
|
||||
pwd
|
||||
npm publish . --tag alpha
|
||||
env:
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
73
public/static/js/swagger/swagger-ui-5.17.14/.github/workflows/release-swagger-ui.yml
vendored
Normal file
73
public/static/js/swagger/swagger-ui-5.17.14/.github/workflows/release-swagger-ui.yml
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
name: Release SwaggerUI@next
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
branches:
|
||||
- next
|
||||
|
||||
jobs:
|
||||
release-swagger-ui:
|
||||
name: Release SwaggerUI
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
ref: next
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- name: Determine the next release version
|
||||
uses: cycjimmy/semantic-release-action@v4
|
||||
with:
|
||||
dry_run: true
|
||||
extra_plugins: |
|
||||
@semantic-release/git
|
||||
@semantic-release/exec
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.SWAGGER_BOT_GITHUB_TOKEN }}
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
- name: Nothing to release
|
||||
if: ${{ env.NEXT_RELEASE_VERSION == '' }}
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
core.setFailed('Nothing to release')
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Prepare release
|
||||
run: |
|
||||
npm run build
|
||||
|
||||
- name: Semantic Release
|
||||
id: semantic
|
||||
uses: cycjimmy/semantic-release-action@v4
|
||||
with:
|
||||
dry_run: false
|
||||
extra_plugins: |
|
||||
@semantic-release/git
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.SWAGGER_BOT_GITHUB_TOKEN }}
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
- name: Release failed
|
||||
if: steps.semantic.outputs.new_release_published == 'false'
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
core.setFailed('Release failed')
|
||||
|
||||
- name: Release published
|
||||
run: |
|
||||
echo ${{ steps.semantic.outputs.new_release_version }}
|
||||
echo ${{ steps.semantic.outputs.new_release_major_version }}
|
||||
echo ${{ steps.semantic.outputs.new_release_minor_version }}
|
||||
echo ${{ steps.semantic.outputs.new_release_patch_version }}
|
29
public/static/js/swagger/swagger-ui-5.17.14/.gitignore
vendored
Normal file
29
public/static/js/swagger/swagger-ui-5.17.14/.gitignore
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
node_modules
|
||||
.idea
|
||||
.vscode
|
||||
.deps_check
|
||||
.DS_Store
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
.nyc_output
|
||||
npm-debug.log*
|
||||
.eslintcache
|
||||
*.iml
|
||||
selenium-debug.log
|
||||
chromedriver.log
|
||||
test/e2e/db.json
|
||||
docs/_book
|
||||
dev-helpers/examples
|
||||
|
||||
# dist
|
||||
flavors/**/dist/*
|
||||
/lib
|
||||
/es
|
||||
dist/log*
|
||||
/swagger-ui-*.tgz
|
||||
|
||||
# Cypress
|
||||
test/e2e-cypress/screenshots
|
||||
test/e2e-cypress/videos
|
1
public/static/js/swagger/swagger-ui-5.17.14/.husky/commit-msg
Executable file
1
public/static/js/swagger/swagger-ui-5.17.14/.husky/commit-msg
Executable file
@ -0,0 +1 @@
|
||||
npx commitlint -e
|
1
public/static/js/swagger/swagger-ui-5.17.14/.husky/pre-commit
Executable file
1
public/static/js/swagger/swagger-ui-5.17.14/.husky/pre-commit
Executable file
@ -0,0 +1 @@
|
||||
npx lint-staged
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"*.js": "eslint"
|
||||
}
|
15
public/static/js/swagger/swagger-ui-5.17.14/.npmignore
Normal file
15
public/static/js/swagger/swagger-ui-5.17.14/.npmignore
Normal file
@ -0,0 +1,15 @@
|
||||
*
|
||||
*/
|
||||
!README.md
|
||||
!NOTICE
|
||||
!package.json
|
||||
!dist/swagger-ui.js
|
||||
!dist/swagger-ui.js.map
|
||||
!dist/swagger-ui-bundle.js
|
||||
!dist/swagger-ui-standalone-preset.js
|
||||
!dist/swagger-ui-es-bundle.js
|
||||
!dist/swagger-ui-es-bundle-core.js
|
||||
!dist/swagger-ui-es-bundle-core.js.map
|
||||
!dist/swagger-ui.css
|
||||
!dist/swagger-ui.css.map
|
||||
!dist/oauth2-redirect.html
|
1
public/static/js/swagger/swagger-ui-5.17.14/.npmrc
Normal file
1
public/static/js/swagger/swagger-ui-5.17.14/.npmrc
Normal file
@ -0,0 +1 @@
|
||||
save-prefix="="
|
1
public/static/js/swagger/swagger-ui-5.17.14/.nvmrc
Normal file
1
public/static/js/swagger/swagger-ui-5.17.14/.nvmrc
Normal file
@ -0,0 +1 @@
|
||||
20.3.0
|
@ -0,0 +1,5 @@
|
||||
semi: false
|
||||
trailingComma: es5
|
||||
endOfLine: lf
|
||||
requirePragma: true
|
||||
insertPragma: true
|
35
public/static/js/swagger/swagger-ui-5.17.14/.releaserc
Normal file
35
public/static/js/swagger/swagger-ui-5.17.14/.releaserc
Normal file
@ -0,0 +1,35 @@
|
||||
{
|
||||
"branches": [
|
||||
{
|
||||
"name": "master"
|
||||
},
|
||||
{
|
||||
"name": "next",
|
||||
"channel": "alpha",
|
||||
"prerelease": "alpha"
|
||||
}
|
||||
],
|
||||
"tagFormat": "v${version}",
|
||||
"plugins": [
|
||||
"@semantic-release/commit-analyzer",
|
||||
[
|
||||
"@semantic-release/exec",
|
||||
{
|
||||
"verifyReleaseCmd": "echo \"NEXT_RELEASE_VERSION=${nextRelease.version}\" >> $GITHUB_ENV"
|
||||
}
|
||||
],
|
||||
"@semantic-release/release-notes-generator",
|
||||
"@semantic-release/npm",
|
||||
"@semantic-release/github",
|
||||
[
|
||||
"@semantic-release/git",
|
||||
{
|
||||
"assets": [
|
||||
"package.json",
|
||||
"package-lock.json"
|
||||
],
|
||||
"message": "chore(release): cut the ${nextRelease.version} release\n\n${nextRelease.notes}"
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
30
public/static/js/swagger/swagger-ui-5.17.14/Dockerfile
Normal file
30
public/static/js/swagger/swagger-ui-5.17.14/Dockerfile
Normal file
@ -0,0 +1,30 @@
|
||||
# Looking for information on environment variables?
|
||||
# We don't declare them here — take a look at our docs.
|
||||
# https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/configuration.md
|
||||
|
||||
FROM nginx:1.26.0-alpine
|
||||
|
||||
RUN apk update && apk add --no-cache "nodejs>=18.20.1-r0 "
|
||||
|
||||
LABEL maintainer="char0n"
|
||||
|
||||
ENV API_KEY="**None**" \
|
||||
SWAGGER_JSON="/app/swagger.json" \
|
||||
PORT="8080" \
|
||||
PORT_IPV6="" \
|
||||
BASE_URL="/" \
|
||||
SWAGGER_JSON_URL="" \
|
||||
CORS="true" \
|
||||
EMBEDDING="false"
|
||||
|
||||
COPY --chown=nginx:nginx --chmod=0666 ./docker/default.conf.template ./docker/cors.conf ./docker/embedding.conf /etc/nginx/templates/
|
||||
|
||||
COPY --chmod=0666 ./dist/* /usr/share/nginx/html/
|
||||
COPY --chmod=0555 ./docker/docker-entrypoint.d/ /docker-entrypoint.d/
|
||||
COPY --chmod=0666 ./docker/configurator /usr/share/nginx/configurator
|
||||
|
||||
# Simulates running NGINX as a non root; in future we want to use nginxinc/nginx-unprivileged.
|
||||
# In future we will have separate unpriviledged images tagged as v5.1.2-unprivileged.
|
||||
RUN chmod 777 /usr/share/nginx/html/ /etc/nginx/conf.d/ /etc/nginx/conf.d/default.conf /var/cache/nginx/ /var/run/
|
||||
|
||||
EXPOSE 8080
|
202
public/static/js/swagger/swagger-ui-5.17.14/LICENSE
Normal file
202
public/static/js/swagger/swagger-ui-5.17.14/LICENSE
Normal file
@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
2
public/static/js/swagger/swagger-ui-5.17.14/NOTICE
Normal file
2
public/static/js/swagger/swagger-ui-5.17.14/NOTICE
Normal file
@ -0,0 +1,2 @@
|
||||
swagger-ui
|
||||
Copyright 2020-2021 SmartBear Software Inc.
|
99
public/static/js/swagger/swagger-ui-5.17.14/README.md
Normal file
99
public/static/js/swagger/swagger-ui-5.17.14/README.md
Normal file
@ -0,0 +1,99 @@
|
||||
# <img src="https://raw.githubusercontent.com/swagger-api/swagger.io/wordpress/images/assets/SWU-logo-clr.png" width="300">
|
||||
|
||||
[](http://badge.fury.io/js/swagger-ui)
|
||||
[](https://jenkins.swagger.io/view/OSS%20-%20JavaScript/job/oss-swagger-ui-master/)
|
||||
[](https://jenkins.swagger.io/job/oss-swagger-ui-security-audit/lastBuild/console)
|
||||

|
||||
|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
## Introduction
|
||||
[Swagger UI](https://swagger.io/tools/swagger-ui/) allows anyone — be it your development team or your end consumers — to visualize and interact with the API’s resources without having any of the implementation logic in place. It’s automatically generated from your OpenAPI (formerly known as Swagger) Specification, with the visual documentation making it easy for back end implementation and client side consumption.
|
||||
|
||||
## General
|
||||
**👉🏼 Want to score an easy open-source contribution?** Check out our [Good first issue](https://github.com/swagger-api/swagger-ui/issues?q=is%3Aissue+is%3Aopen+label%3A%22Good+first+issue%22) label.
|
||||
|
||||
**🕰️ Looking for the older version of Swagger UI?** Refer to the [*2.x* branch](https://github.com/swagger-api/swagger-ui/tree/2.x).
|
||||
|
||||
|
||||
This repository publishes three different NPM modules:
|
||||
|
||||
* [swagger-ui](https://www.npmjs.com/package/swagger-ui) is a traditional npm module intended for use in single-page applications that are capable of resolving dependencies (via Webpack, Browserify, etc.).
|
||||
* [swagger-ui-dist](https://www.npmjs.com/package/swagger-ui-dist) is a dependency-free module that includes everything you need to serve Swagger UI in a server-side project, or a single-page application that can't resolve npm module dependencies.
|
||||
* [swagger-ui-react](https://www.npmjs.com/package/swagger-ui-react) is Swagger UI packaged as a React component for use in React applications.
|
||||
|
||||
We strongly suggest that you use `swagger-ui` instead of `swagger-ui-dist` if you're building a single-page application, since `swagger-ui-dist` is significantly larger.
|
||||
|
||||
If you are looking for plain ol' HTML/JS/CSS, [download the latest release](https://github.com/swagger-api/swagger-ui/releases/latest) and copy the contents of the `/dist` folder to your server.
|
||||
|
||||
|
||||
## Compatibility
|
||||
The OpenAPI Specification has undergone 5 revisions since initial creation in 2010. Compatibility between Swagger UI and the OpenAPI Specification is as follows:
|
||||
|
||||
| Swagger UI Version | Release Date | OpenAPI Spec compatibility | Notes |
|
||||
|--------------------|--------------|----------------------------------------|-----------------------------------------------------------------------|
|
||||
| 5.0.0 | 2023-06-12 | 2.0, 3.0.0, 3.0.1, 3.0.2, 3.0.3, 3.1.0 | [tag v5.0.0](https://github.com/swagger-api/swagger-ui/tree/v5.0.0) |
|
||||
| 4.0.0 | 2021-11-03 | 2.0, 3.0.0, 3.0.1, 3.0.2, 3.0.3 | [tag v4.0.0](https://github.com/swagger-api/swagger-ui/tree/v4.0.0) |
|
||||
| 3.18.3 | 2018-08-03 | 2.0, 3.0.0, 3.0.1, 3.0.2, 3.0.3 | [tag v3.18.3](https://github.com/swagger-api/swagger-ui/tree/v3.18.3) |
|
||||
| 3.0.21 | 2017-07-26 | 2.0 | [tag v3.0.21](https://github.com/swagger-api/swagger-ui/tree/v3.0.21) |
|
||||
| 2.2.10 | 2017-01-04 | 1.1, 1.2, 2.0 | [tag v2.2.10](https://github.com/swagger-api/swagger-ui/tree/v2.2.10) |
|
||||
| 2.1.5 | 2016-07-20 | 1.1, 1.2, 2.0 | [tag v2.1.5](https://github.com/swagger-api/swagger-ui/tree/v2.1.5) |
|
||||
| 2.0.24 | 2014-09-12 | 1.1, 1.2 | [tag v2.0.24](https://github.com/swagger-api/swagger-ui/tree/v2.0.24) |
|
||||
| 1.0.13 | 2013-03-08 | 1.1, 1.2 | [tag v1.0.13](https://github.com/swagger-api/swagger-ui/tree/v1.0.13) |
|
||||
| 1.0.1 | 2011-10-11 | 1.0, 1.1 | [tag v1.0.1](https://github.com/swagger-api/swagger-ui/tree/v1.0.1) |
|
||||
|
||||
## Documentation
|
||||
|
||||
#### Usage
|
||||
- [Installation](https://github.com/swagger-api/swagger-ui/blob/HEAD/docs/usage/installation.md)
|
||||
- [Configuration](https://github.com/swagger-api/swagger-ui/blob/HEAD/docs/usage/configuration.md)
|
||||
- [CORS](https://github.com/swagger-api/swagger-ui/blob/HEAD/docs/usage/cors.md)
|
||||
- [OAuth2](https://github.com/swagger-api/swagger-ui/blob/HEAD/docs/usage/oauth2.md)
|
||||
- [Deep Linking](https://github.com/swagger-api/swagger-ui/blob/HEAD/docs/usage/deep-linking.md)
|
||||
- [Limitations](https://github.com/swagger-api/swagger-ui/blob/HEAD/docs/usage/limitations.md)
|
||||
- [Version detection](https://github.com/swagger-api/swagger-ui/blob/HEAD/docs/usage/version-detection.md)
|
||||
|
||||
#### Customization
|
||||
- [Overview](https://github.com/swagger-api/swagger-ui/blob/HEAD/docs/customization/overview.md)
|
||||
- [Plugin API](https://github.com/swagger-api/swagger-ui/blob/HEAD/docs/customization/plugin-api.md)
|
||||
- [Custom layout](https://github.com/swagger-api/swagger-ui/blob/HEAD/docs/customization/custom-layout.md)
|
||||
|
||||
#### Development
|
||||
- [Setting up](https://github.com/swagger-api/swagger-ui/blob/HEAD/docs/development/setting-up.md)
|
||||
- [Scripts](https://github.com/swagger-api/swagger-ui/blob/HEAD/docs/development/scripts.md)
|
||||
|
||||
#### Contributing
|
||||
- [Contributing](https://github.com/swagger-api/.github/blob/HEAD/CONTRIBUTING.md)
|
||||
|
||||
##### Integration Tests
|
||||
|
||||
You will need JDK of version 7 or higher as instructed here
|
||||
https://nightwatchjs.org/guide/getting-started/installation.html#install-selenium-server
|
||||
|
||||
Integration tests can be run locally with `npm run e2e` - be sure you aren't running a dev server when testing!
|
||||
|
||||
### Browser support
|
||||
Swagger UI works in the latest versions of Chrome, Safari, Firefox, and Edge.
|
||||
|
||||
### Known Issues
|
||||
|
||||
To help with the migration, here are the currently known issues with 3.X. This list will update regularly, and will not include features that were not implemented in previous versions.
|
||||
|
||||
- Only part of the parameters previously supported are available.
|
||||
- The JSON Form Editor is not implemented.
|
||||
- Support for `collectionFormat` is partial.
|
||||
- l10n (translations) is not implemented.
|
||||
- Relative path support for external files is not implemented.
|
||||
|
||||
## Security contact
|
||||
|
||||
Please disclose any security-related issues or vulnerabilities by emailing [security@swagger.io](mailto:security@swagger.io), instead of using the public issue tracker.
|
||||
|
||||
## License
|
||||
|
||||
SwaggerUI is licensed under [Apache 2.0 license](https://github.com/swagger-api/swagger-ui/blob/master/LICENSE).
|
||||
SwaggerUI comes with an explicit [NOTICE](https://github.com/swagger-api/swagger-ui/blob/master/NOTICE) file
|
||||
containing additional legal notices and information.
|
23
public/static/js/swagger/swagger-ui-5.17.14/SECURITY.md
Normal file
23
public/static/js/swagger/swagger-ui-5.17.14/SECURITY.md
Normal file
@ -0,0 +1,23 @@
|
||||
# Security Policy
|
||||
|
||||
If you believe you've found an exploitable security issue in Swagger UI,
|
||||
**please don't create a public issue**.
|
||||
|
||||
|
||||
## Supported versions
|
||||
|
||||
This is the list of versions of `swagger-ui` which are
|
||||
currently being supported with security updates.
|
||||
|
||||
| Version | Supported | Notes |
|
||||
|---------|--------------------|---------------------------------|
|
||||
| 5.x | :white_check_mark: | Active LTS |
|
||||
| 4.x | :x: | End-of-life as of August 2023 |
|
||||
| 3.x | :x: | End-of-life as of November 2021 |
|
||||
| 2.x | :x: | End-of-life as of 2017 |
|
||||
|
||||
## Reporting a vulnerability
|
||||
|
||||
To report a vulnerability please send an email with the details to [security@swagger.io](mailto:security@swagger.io).
|
||||
|
||||
We'll acknowledge receipt of your report ASAP, and set expectations on how we plan to handle it.
|
140
public/static/js/swagger/swagger-ui-5.17.14/babel.config.js
Normal file
140
public/static/js/swagger/swagger-ui-5.17.14/babel.config.js
Normal file
@ -0,0 +1,140 @@
|
||||
const browser = {
|
||||
presets: [
|
||||
[
|
||||
"@babel/preset-env",
|
||||
{
|
||||
debug: false,
|
||||
modules: "auto",
|
||||
useBuiltIns: false,
|
||||
forceAllTransforms: false,
|
||||
ignoreBrowserslistConfig: false,
|
||||
}
|
||||
],
|
||||
"@babel/preset-react",
|
||||
],
|
||||
plugins: [
|
||||
[
|
||||
"@babel/plugin-transform-runtime",
|
||||
{
|
||||
corejs: { version: 3, proposals: false },
|
||||
absoluteRuntime: false,
|
||||
helpers: true,
|
||||
regenerator: false,
|
||||
version: "^7.22.11",
|
||||
}
|
||||
],
|
||||
[
|
||||
"transform-react-remove-prop-types",
|
||||
{
|
||||
additionalLibraries: [
|
||||
"react-immutable-proptypes"
|
||||
]
|
||||
}
|
||||
],
|
||||
[
|
||||
"babel-plugin-module-resolver",
|
||||
{
|
||||
alias: {
|
||||
root: ".",
|
||||
core: "./src/core",
|
||||
}
|
||||
}
|
||||
]
|
||||
],
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
env: {
|
||||
commonjs: {
|
||||
presets: [
|
||||
[
|
||||
"@babel/preset-env",
|
||||
{
|
||||
debug: false,
|
||||
modules: "commonjs",
|
||||
loose: true,
|
||||
useBuiltIns: false,
|
||||
forceAllTransforms: false,
|
||||
ignoreBrowserslistConfig: false,
|
||||
}
|
||||
],
|
||||
"@babel/preset-react",
|
||||
],
|
||||
plugins: [
|
||||
[
|
||||
"@babel/plugin-transform-runtime",
|
||||
{
|
||||
corejs: { version: 3, proposals: false },
|
||||
absoluteRuntime: false,
|
||||
helpers: true,
|
||||
regenerator: false,
|
||||
version: "^7.22.11",
|
||||
}
|
||||
],
|
||||
[
|
||||
"transform-react-remove-prop-types",
|
||||
{
|
||||
additionalLibraries: [
|
||||
"react-immutable-proptypes"
|
||||
]
|
||||
}
|
||||
],
|
||||
[
|
||||
"babel-plugin-module-resolver",
|
||||
{
|
||||
alias: {
|
||||
root: ".",
|
||||
core: "./src/core",
|
||||
}
|
||||
}
|
||||
]
|
||||
],
|
||||
},
|
||||
esm: {
|
||||
presets: [
|
||||
[
|
||||
"@babel/env",
|
||||
{
|
||||
debug: false,
|
||||
modules: false,
|
||||
ignoreBrowserslistConfig: false,
|
||||
useBuiltIns: false,
|
||||
}
|
||||
],
|
||||
"@babel/preset-react"
|
||||
],
|
||||
plugins: [
|
||||
[
|
||||
"@babel/plugin-transform-runtime",
|
||||
{
|
||||
corejs: { version: 3, proposals: false },
|
||||
absoluteRuntime: false,
|
||||
helpers: true,
|
||||
regenerator: false,
|
||||
version: "^7.22.11",
|
||||
}
|
||||
],
|
||||
[
|
||||
"transform-react-remove-prop-types",
|
||||
{
|
||||
additionalLibraries: [
|
||||
"react-immutable-proptypes"
|
||||
]
|
||||
}
|
||||
],
|
||||
[
|
||||
"babel-plugin-module-resolver",
|
||||
{
|
||||
alias: {
|
||||
root: ".",
|
||||
core: "./src/core",
|
||||
}
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
development: browser,
|
||||
production: browser,
|
||||
},
|
||||
}
|
||||
|
40
public/static/js/swagger/swagger-ui-5.17.14/composer.json
Normal file
40
public/static/js/swagger/swagger-ui-5.17.14/composer.json
Normal file
@ -0,0 +1,40 @@
|
||||
{
|
||||
"name": "swagger-api/swagger-ui",
|
||||
"description": " Swagger UI is a collection of HTML, Javascript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.",
|
||||
"keywords": [
|
||||
"Swagger",
|
||||
"OpenAPI",
|
||||
"specification",
|
||||
"documentation",
|
||||
"API",
|
||||
"UI"
|
||||
],
|
||||
"homepage": "http://swagger.io",
|
||||
"license": "Apache-2.0",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Anna Bodnia",
|
||||
"email": "anna.bodnia@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Buu Nguyen",
|
||||
"email": "buunguyen@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Josh Ponelat",
|
||||
"email": "jponelat@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Kyle Shockey",
|
||||
"email": "kyleshockey1@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Robert Barnwell",
|
||||
"email": "robert@robertismy.name"
|
||||
},
|
||||
{
|
||||
"name": "Sahar Jafari",
|
||||
"email": "shr.jafari@gmail.com"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
{
|
||||
"rules": {
|
||||
"import/no-unresolved": 0,
|
||||
"import/extensions": 0,
|
||||
"quotes": ["error", "single"],
|
||||
"semi": ["error", "always"]
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
const path = require('path');
|
||||
|
||||
module.exports = {
|
||||
rootDir: path.join(__dirname, '..', '..'),
|
||||
testEnvironment: 'jsdom',
|
||||
testMatch: ['**/test/build-artifacts/**/*.js'],
|
||||
setupFiles: ['<rootDir>/test/unit/jest-shim.js'],
|
||||
transformIgnorePatterns: ['/node_modules/(?!(swagger-client|react-syntax-highlighter)/)'],
|
||||
};
|
@ -0,0 +1,23 @@
|
||||
const path = require('path');
|
||||
|
||||
module.exports = {
|
||||
rootDir: path.join(__dirname, '..', '..'),
|
||||
testEnvironment: 'jest-environment-jsdom',
|
||||
testMatch: [
|
||||
'**/test/unit/*.js?(x)',
|
||||
'**/test/unit/**/*.js?(x)',
|
||||
],
|
||||
setupFiles: ['<rootDir>/test/unit/jest-shim.js'],
|
||||
setupFilesAfterEnv: ['<rootDir>/test/unit/setup.js'],
|
||||
testPathIgnorePatterns: [
|
||||
'<rootDir>/node_modules/',
|
||||
'<rootDir>/test/build-artifacts/',
|
||||
'<rootDir>/test/unit/jest-shim.js',
|
||||
'<rootDir>/test/unit/setup.js',
|
||||
],
|
||||
moduleNameMapper: {
|
||||
'^.+\\.svg$': 'jest-transform-stub'
|
||||
},
|
||||
transformIgnorePatterns: ['/node_modules/(?!(sinon|react-syntax-highlighter)/)'],
|
||||
silent: true, // set to `false` to allow console.* calls to be printed
|
||||
};
|
@ -0,0 +1,19 @@
|
||||
const { defineConfig } = require("cypress")
|
||||
|
||||
const startOAuthServer = require("./test/e2e-cypress/support/helpers/oauth2-server")
|
||||
|
||||
module.exports = defineConfig({
|
||||
fileServerFolder: "test/e2e-cypress/static",
|
||||
fixturesFolder: "test/e2e-cypress/fixtures",
|
||||
screenshotsFolder: "test/e2e-cypress/screenshots",
|
||||
videosFolder: "test/e2e-cypress/videos",
|
||||
video: false,
|
||||
e2e: {
|
||||
baseUrl: "http://localhost:3230/",
|
||||
supportFile: "test/e2e-cypress/support/e2e.js",
|
||||
specPattern: "test/e2e-cypress/e2e/**/*.cy.{js,jsx}",
|
||||
setupNodeEvents: () => {
|
||||
startOAuthServer()
|
||||
},
|
||||
},
|
||||
})
|
@ -0,0 +1,33 @@
|
||||
/* eslint-disable no-undef */
|
||||
window.onload = function() {
|
||||
window["SwaggerUIBundle"] = window["swagger-ui-bundle"]
|
||||
window["SwaggerUIStandalonePreset"] = window["swagger-ui-standalone-preset"]
|
||||
// Build a system
|
||||
const ui = SwaggerUIBundle({
|
||||
url: "https://petstore.swagger.io/v2/swagger.json",
|
||||
dom_id: "#swagger-ui",
|
||||
presets: [
|
||||
SwaggerUIBundle.presets.apis,
|
||||
SwaggerUIStandalonePreset
|
||||
],
|
||||
plugins: [
|
||||
SwaggerUIBundle.plugins.DownloadUrl
|
||||
],
|
||||
// requestSnippetsEnabled: true,
|
||||
layout: "StandaloneLayout"
|
||||
})
|
||||
|
||||
window.ui = ui
|
||||
|
||||
ui.initOAuth({
|
||||
clientId: "your-client-id",
|
||||
clientSecret: "your-client-secret-if-required",
|
||||
realm: "your-realms",
|
||||
appName: "your-app-name",
|
||||
scopeSeparator: " ",
|
||||
scopes: "openid profile email phone address",
|
||||
additionalQueryStringParams: {},
|
||||
useBasicAuthenticationWithAccessCodeGrant: false,
|
||||
usePkceWithAuthorizationCodeGrant: false
|
||||
})
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
<!-- HTML for dev server -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Swagger UI</title>
|
||||
<link rel="stylesheet" type="text/css" href="style.css">
|
||||
<style>
|
||||
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="swagger-ui"></div>
|
||||
|
||||
<script src="dev-helper-initializer.js"></script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
@ -0,0 +1,76 @@
|
||||
<!doctype html>
|
||||
<html lang="en-US">
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
<script>
|
||||
'use strict';
|
||||
function run () {
|
||||
var oauth2 = window.opener.swaggerUIRedirectOauth2;
|
||||
var sentState = oauth2.state;
|
||||
var redirectUrl = oauth2.redirectUrl;
|
||||
var isValid, qp, arr;
|
||||
|
||||
if (/code|token|error/.test(window.location.hash)) {
|
||||
qp = window.location.hash.substring(1).replace('?', '&');
|
||||
} else {
|
||||
qp = location.search.substring(1);
|
||||
}
|
||||
|
||||
arr = qp.split("&")
|
||||
arr.forEach(function (v,i,_arr) { _arr[i] = '"' + v.replace('=', '":"') + '"';})
|
||||
qp = qp ? JSON.parse('{' + arr.join() + '}',
|
||||
function (key, value) {
|
||||
return key === "" ? value : decodeURIComponent(value)
|
||||
}
|
||||
) : {}
|
||||
|
||||
isValid = qp.state === sentState
|
||||
|
||||
if ((
|
||||
oauth2.auth.schema.get("flow") === "accessCode" ||
|
||||
oauth2.auth.schema.get("flow") === "authorizationCode" ||
|
||||
oauth2.auth.schema.get("flow") === "authorization_code"
|
||||
) && !oauth2.auth.code) {
|
||||
if (!isValid) {
|
||||
oauth2.errCb({
|
||||
authId: oauth2.auth.name,
|
||||
source: "auth",
|
||||
level: "warning",
|
||||
message: "Authorization may be unsafe, passed state was changed in server Passed state wasn't returned from auth server"
|
||||
});
|
||||
}
|
||||
|
||||
if (qp.code) {
|
||||
delete oauth2.state;
|
||||
oauth2.auth.code = qp.code;
|
||||
oauth2.callback({auth: oauth2.auth, redirectUrl: redirectUrl});
|
||||
} else {
|
||||
let oauthErrorMsg
|
||||
if (qp.error) {
|
||||
oauthErrorMsg = "["+qp.error+"]: " +
|
||||
(qp.error_description ? qp.error_description+ ". " : "no accessCode received from the server. ") +
|
||||
(qp.error_uri ? "More info: "+qp.error_uri : "");
|
||||
}
|
||||
|
||||
oauth2.errCb({
|
||||
authId: oauth2.auth.name,
|
||||
source: "auth",
|
||||
level: "error",
|
||||
message: oauthErrorMsg || "[Authorization failed]: no accessCode received from the server"
|
||||
});
|
||||
}
|
||||
} else {
|
||||
oauth2.callback({auth: oauth2.auth, token: qp, isValid: isValid, redirectUrl: redirectUrl});
|
||||
}
|
||||
window.close();
|
||||
}
|
||||
|
||||
if( document.readyState !== 'loading' ) {
|
||||
run();
|
||||
} else {
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
run();
|
||||
});
|
||||
}
|
||||
</script>
|
@ -0,0 +1,19 @@
|
||||
html
|
||||
{
|
||||
box-sizing: border-box;
|
||||
overflow: -moz-scrollbars-vertical;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
||||
*,
|
||||
*:before,
|
||||
*:after
|
||||
{
|
||||
box-sizing: inherit;
|
||||
}
|
||||
|
||||
body
|
||||
{
|
||||
margin:0;
|
||||
background: #fafafa;
|
||||
}
|
BIN
public/static/js/swagger/swagger-ui-5.17.14/dist/favicon-16x16.png
vendored
Normal file
BIN
public/static/js/swagger/swagger-ui-5.17.14/dist/favicon-16x16.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 665 B |
BIN
public/static/js/swagger/swagger-ui-5.17.14/dist/favicon-32x32.png
vendored
Normal file
BIN
public/static/js/swagger/swagger-ui-5.17.14/dist/favicon-32x32.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 628 B |
16
public/static/js/swagger/swagger-ui-5.17.14/dist/index.css
vendored
Normal file
16
public/static/js/swagger/swagger-ui-5.17.14/dist/index.css
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
html {
|
||||
box-sizing: border-box;
|
||||
overflow: -moz-scrollbars-vertical;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
||||
*,
|
||||
*:before,
|
||||
*:after {
|
||||
box-sizing: inherit;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
background: #fafafa;
|
||||
}
|
19
public/static/js/swagger/swagger-ui-5.17.14/dist/index.html
vendored
Normal file
19
public/static/js/swagger/swagger-ui-5.17.14/dist/index.html
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
<!-- HTML for static distribution bundle build -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Swagger UI</title>
|
||||
<link rel="stylesheet" type="text/css" href="./swagger-ui.css" />
|
||||
<link rel="stylesheet" type="text/css" href="index.css" />
|
||||
<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
|
||||
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="swagger-ui"></div>
|
||||
<script src="./swagger-ui-bundle.js" charset="UTF-8"> </script>
|
||||
<script src="./swagger-ui-standalone-preset.js" charset="UTF-8"> </script>
|
||||
<script src="./swagger-initializer.js" charset="UTF-8"> </script>
|
||||
</body>
|
||||
</html>
|
79
public/static/js/swagger/swagger-ui-5.17.14/dist/oauth2-redirect.html
vendored
Normal file
79
public/static/js/swagger/swagger-ui-5.17.14/dist/oauth2-redirect.html
vendored
Normal file
@ -0,0 +1,79 @@
|
||||
<!doctype html>
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<title>Swagger UI: OAuth2 Redirect</title>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
'use strict';
|
||||
function run () {
|
||||
var oauth2 = window.opener.swaggerUIRedirectOauth2;
|
||||
var sentState = oauth2.state;
|
||||
var redirectUrl = oauth2.redirectUrl;
|
||||
var isValid, qp, arr;
|
||||
|
||||
if (/code|token|error/.test(window.location.hash)) {
|
||||
qp = window.location.hash.substring(1).replace('?', '&');
|
||||
} else {
|
||||
qp = location.search.substring(1);
|
||||
}
|
||||
|
||||
arr = qp.split("&");
|
||||
arr.forEach(function (v,i,_arr) { _arr[i] = '"' + v.replace('=', '":"') + '"';});
|
||||
qp = qp ? JSON.parse('{' + arr.join() + '}',
|
||||
function (key, value) {
|
||||
return key === "" ? value : decodeURIComponent(value);
|
||||
}
|
||||
) : {};
|
||||
|
||||
isValid = qp.state === sentState;
|
||||
|
||||
if ((
|
||||
oauth2.auth.schema.get("flow") === "accessCode" ||
|
||||
oauth2.auth.schema.get("flow") === "authorizationCode" ||
|
||||
oauth2.auth.schema.get("flow") === "authorization_code"
|
||||
) && !oauth2.auth.code) {
|
||||
if (!isValid) {
|
||||
oauth2.errCb({
|
||||
authId: oauth2.auth.name,
|
||||
source: "auth",
|
||||
level: "warning",
|
||||
message: "Authorization may be unsafe, passed state was changed in server. The passed state wasn't returned from auth server."
|
||||
});
|
||||
}
|
||||
|
||||
if (qp.code) {
|
||||
delete oauth2.state;
|
||||
oauth2.auth.code = qp.code;
|
||||
oauth2.callback({auth: oauth2.auth, redirectUrl: redirectUrl});
|
||||
} else {
|
||||
let oauthErrorMsg;
|
||||
if (qp.error) {
|
||||
oauthErrorMsg = "["+qp.error+"]: " +
|
||||
(qp.error_description ? qp.error_description+ ". " : "no accessCode received from the server. ") +
|
||||
(qp.error_uri ? "More info: "+qp.error_uri : "");
|
||||
}
|
||||
|
||||
oauth2.errCb({
|
||||
authId: oauth2.auth.name,
|
||||
source: "auth",
|
||||
level: "error",
|
||||
message: oauthErrorMsg || "[Authorization failed]: no accessCode received from the server."
|
||||
});
|
||||
}
|
||||
} else {
|
||||
oauth2.callback({auth: oauth2.auth, token: qp, isValid: isValid, redirectUrl: redirectUrl});
|
||||
}
|
||||
window.close();
|
||||
}
|
||||
|
||||
if (document.readyState !== 'loading') {
|
||||
run();
|
||||
} else {
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
run();
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
20
public/static/js/swagger/swagger-ui-5.17.14/dist/swagger-initializer.js
vendored
Normal file
20
public/static/js/swagger/swagger-ui-5.17.14/dist/swagger-initializer.js
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
window.onload = function() {
|
||||
//<editor-fold desc="Changeable Configuration Block">
|
||||
|
||||
// the following lines will be replaced by docker/configurator, when it runs in a docker-container
|
||||
window.ui = SwaggerUIBundle({
|
||||
url: "/api",
|
||||
dom_id: '#swagger-ui',
|
||||
deepLinking: true,
|
||||
presets: [
|
||||
SwaggerUIBundle.presets.apis,
|
||||
SwaggerUIStandalonePreset
|
||||
],
|
||||
plugins: [
|
||||
SwaggerUIBundle.plugins.DownloadUrl
|
||||
],
|
||||
layout: "StandaloneLayout"
|
||||
});
|
||||
|
||||
//</editor-fold>
|
||||
};
|
2
public/static/js/swagger/swagger-ui-5.17.14/dist/swagger-ui-bundle.js
vendored
Normal file
2
public/static/js/swagger/swagger-ui-5.17.14/dist/swagger-ui-bundle.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
public/static/js/swagger/swagger-ui-5.17.14/dist/swagger-ui-bundle.js.map
vendored
Normal file
1
public/static/js/swagger/swagger-ui-5.17.14/dist/swagger-ui-bundle.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
3
public/static/js/swagger/swagger-ui-5.17.14/dist/swagger-ui-es-bundle-core.js
vendored
Normal file
3
public/static/js/swagger/swagger-ui-5.17.14/dist/swagger-ui-es-bundle-core.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
public/static/js/swagger/swagger-ui-5.17.14/dist/swagger-ui-es-bundle-core.js.map
vendored
Normal file
1
public/static/js/swagger/swagger-ui-5.17.14/dist/swagger-ui-es-bundle-core.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
2
public/static/js/swagger/swagger-ui-5.17.14/dist/swagger-ui-es-bundle.js
vendored
Normal file
2
public/static/js/swagger/swagger-ui-5.17.14/dist/swagger-ui-es-bundle.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
public/static/js/swagger/swagger-ui-5.17.14/dist/swagger-ui-es-bundle.js.map
vendored
Normal file
1
public/static/js/swagger/swagger-ui-5.17.14/dist/swagger-ui-es-bundle.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
2
public/static/js/swagger/swagger-ui-5.17.14/dist/swagger-ui-standalone-preset.js
vendored
Normal file
2
public/static/js/swagger/swagger-ui-5.17.14/dist/swagger-ui-standalone-preset.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
public/static/js/swagger/swagger-ui-5.17.14/dist/swagger-ui-standalone-preset.js.map
vendored
Normal file
1
public/static/js/swagger/swagger-ui-5.17.14/dist/swagger-ui-standalone-preset.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
3
public/static/js/swagger/swagger-ui-5.17.14/dist/swagger-ui.css
vendored
Normal file
3
public/static/js/swagger/swagger-ui-5.17.14/dist/swagger-ui.css
vendored
Normal file
File diff suppressed because one or more lines are too long
1
public/static/js/swagger/swagger-ui-5.17.14/dist/swagger-ui.css.map
vendored
Normal file
1
public/static/js/swagger/swagger-ui-5.17.14/dist/swagger-ui.css.map
vendored
Normal file
File diff suppressed because one or more lines are too long
2
public/static/js/swagger/swagger-ui-5.17.14/dist/swagger-ui.js
vendored
Normal file
2
public/static/js/swagger/swagger-ui-5.17.14/dist/swagger-ui.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
public/static/js/swagger/swagger-ui-5.17.14/dist/swagger-ui.js.map
vendored
Normal file
1
public/static/js/swagger/swagger-ui-5.17.14/dist/swagger-ui.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -0,0 +1,13 @@
|
||||
module.exports.indent = function indent(str, len, fromLine = 0) {
|
||||
|
||||
return str
|
||||
.split("\n")
|
||||
.map((line, i) => {
|
||||
if (i + 1 >= fromLine) {
|
||||
return `${Array(len + 1).join(" ")}${line}`
|
||||
} else {
|
||||
return line
|
||||
}
|
||||
})
|
||||
.join("\n")
|
||||
}
|
52
public/static/js/swagger/swagger-ui-5.17.14/docker/configurator/index.js
Executable file
52
public/static/js/swagger/swagger-ui-5.17.14/docker/configurator/index.js
Executable file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Replace static code with configured data based on environment-variables.
|
||||
* This code should be called BEFORE the webserver serve the api-documentation.
|
||||
*/
|
||||
const fs = require("fs")
|
||||
const path = require("path")
|
||||
|
||||
const translator = require("./translator")
|
||||
const oauthBlockBuilder = require("./oauth")
|
||||
const indent = require("./helpers").indent
|
||||
|
||||
const START_MARKER = "//<editor-fold desc=\"Changeable Configuration Block\">"
|
||||
const END_MARKER = "//</editor-fold>"
|
||||
|
||||
const targetPath = path.normalize(process.cwd() + "/" + process.argv[2])
|
||||
|
||||
const originalHtmlContent = fs.readFileSync(targetPath, "utf8")
|
||||
|
||||
const startMarkerIndex = originalHtmlContent.indexOf(START_MARKER)
|
||||
const endMarkerIndex = originalHtmlContent.indexOf(END_MARKER)
|
||||
|
||||
const beforeStartMarkerContent = originalHtmlContent.slice(0, startMarkerIndex)
|
||||
const afterEndMarkerContent = originalHtmlContent.slice(
|
||||
endMarkerIndex + END_MARKER.length
|
||||
)
|
||||
|
||||
if (startMarkerIndex < 0 || endMarkerIndex < 0) {
|
||||
console.error("ERROR: Swagger UI was unable to inject Docker configuration data!")
|
||||
console.error("! This can happen when you provide custom HTML/JavaScript to Swagger UI.")
|
||||
console.error("! ")
|
||||
console.error(`! In order to solve this, add the "${START_MARKER}"`)
|
||||
console.error(`! and "${END_MARKER}" markers to your JavaScript.`)
|
||||
console.error("! See the repository for an example:")
|
||||
console.error("! https://github.com/swagger-api/swagger-ui/blob/8c946a02e73ef877d73b7635de27924418ba50f3/dist/swagger-initializer.js#L2-L19")
|
||||
console.error("! ")
|
||||
console.error("! If you're seeing this message and aren't using custom HTML,")
|
||||
console.error("! this message may be a bug. Please file an issue:")
|
||||
console.error("! https://github.com/swagger-api/swagger-ui/issues/new/choose")
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
fs.writeFileSync(
|
||||
targetPath,
|
||||
`${beforeStartMarkerContent}
|
||||
${START_MARKER}
|
||||
window.ui = SwaggerUIBundle({
|
||||
${indent(translator(process.env, {injectBaseConfig: true}), 8, 2)}
|
||||
})
|
||||
${indent(oauthBlockBuilder(process.env), 6, 2)}
|
||||
${END_MARKER}
|
||||
${afterEndMarkerContent}`
|
||||
)
|
@ -0,0 +1,55 @@
|
||||
const translator = require("./translator")
|
||||
const indent = require("./helpers").indent
|
||||
|
||||
const oauthBlockSchema = {
|
||||
OAUTH_CLIENT_ID: {
|
||||
type: "string",
|
||||
name: "clientId"
|
||||
},
|
||||
OAUTH_CLIENT_SECRET: {
|
||||
type: "string",
|
||||
name: "clientSecret",
|
||||
onFound: () => console.warn("Swagger UI warning: don't use `OAUTH_CLIENT_SECRET` in production!")
|
||||
},
|
||||
OAUTH_REALM: {
|
||||
type: "string",
|
||||
name: "realm"
|
||||
},
|
||||
OAUTH_APP_NAME: {
|
||||
type: "string",
|
||||
name: "appName"
|
||||
},
|
||||
OAUTH_SCOPE_SEPARATOR: {
|
||||
type: "string",
|
||||
name: "scopeSeparator"
|
||||
},
|
||||
OAUTH_SCOPES: {
|
||||
type: "string",
|
||||
name: "scopes"
|
||||
},
|
||||
OAUTH_ADDITIONAL_PARAMS: {
|
||||
type: "object",
|
||||
name: "additionalQueryStringParams"
|
||||
},
|
||||
OAUTH_USE_BASIC_AUTH: {
|
||||
type: "boolean",
|
||||
name: "useBasicAuthenticationWithAccessCodeGrant"
|
||||
},
|
||||
OAUTH_USE_PKCE: {
|
||||
type: "boolean",
|
||||
name: "usePkceWithAuthorizationCodeGrant"
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = function oauthBlockBuilder(env) {
|
||||
const translatorResult = translator(env, { schema: oauthBlockSchema })
|
||||
|
||||
if(translatorResult) {
|
||||
return (
|
||||
`ui.initOAuth({
|
||||
${indent(translatorResult, 2)}
|
||||
})`)
|
||||
}
|
||||
|
||||
return ``
|
||||
}
|
@ -0,0 +1,111 @@
|
||||
// Converts an object of environment variables into a Swagger UI config object
|
||||
const configSchema = require("./variables")
|
||||
|
||||
const defaultBaseConfig = {
|
||||
url: {
|
||||
value: "https://petstore.swagger.io/v2/swagger.json",
|
||||
schema: {
|
||||
type: "string",
|
||||
base: true
|
||||
}
|
||||
},
|
||||
dom_id: {
|
||||
value: "#swagger-ui",
|
||||
schema: {
|
||||
type: "string",
|
||||
base: true
|
||||
}
|
||||
},
|
||||
deepLinking: {
|
||||
value: "true",
|
||||
schema: {
|
||||
type: "boolean",
|
||||
base: true
|
||||
}
|
||||
},
|
||||
presets: {
|
||||
value: `[\n SwaggerUIBundle.presets.apis,\n SwaggerUIStandalonePreset\n]`,
|
||||
schema: {
|
||||
type: "array",
|
||||
base: true
|
||||
}
|
||||
},
|
||||
plugins: {
|
||||
value: `[\n SwaggerUIBundle.plugins.DownloadUrl\n]`,
|
||||
schema: {
|
||||
type: "array",
|
||||
base: true
|
||||
}
|
||||
},
|
||||
layout: {
|
||||
value: "StandaloneLayout",
|
||||
schema: {
|
||||
type: "string",
|
||||
base: true
|
||||
}
|
||||
},
|
||||
queryConfigEnabled: {
|
||||
value: "false",
|
||||
schema: {
|
||||
type: "boolean",
|
||||
base: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function objectToKeyValueString(env, { injectBaseConfig = false, schema = configSchema, baseConfig = defaultBaseConfig } = {}) {
|
||||
let valueStorage = injectBaseConfig ? Object.assign({}, baseConfig) : {}
|
||||
const keys = Object.keys(env)
|
||||
|
||||
// Compute an intermediate representation that holds candidate values and schemas.
|
||||
//
|
||||
// This is useful for deduping between multiple env keys that set the same
|
||||
// config variable.
|
||||
|
||||
keys.forEach(key => {
|
||||
const varSchema = schema[key]
|
||||
const value = env[key]
|
||||
|
||||
if(!varSchema) return
|
||||
|
||||
if(varSchema.onFound) {
|
||||
varSchema.onFound()
|
||||
}
|
||||
|
||||
const storageContents = valueStorage[varSchema.name]
|
||||
|
||||
if(storageContents) {
|
||||
if (varSchema.legacy === true && !storageContents.schema.base) {
|
||||
// If we're looking at a legacy var, it should lose out to any already-set value
|
||||
// except for base values
|
||||
return
|
||||
}
|
||||
delete valueStorage[varSchema.name]
|
||||
}
|
||||
|
||||
valueStorage[varSchema.name] = {
|
||||
value,
|
||||
schema: varSchema
|
||||
}
|
||||
})
|
||||
|
||||
// Compute a key:value string based on valueStorage's contents.
|
||||
|
||||
let result = ""
|
||||
|
||||
Object.keys(valueStorage).forEach(key => {
|
||||
const value = valueStorage[key]
|
||||
|
||||
const escapedName = /[^a-zA-Z0-9]/.test(key) ? `"${key}"` : key
|
||||
|
||||
if (value.schema.type === "string") {
|
||||
result += `${escapedName}: "${value.value}",\n`
|
||||
} else {
|
||||
result += `${escapedName}: ${value.value === "" ? `undefined` : value.value},\n`
|
||||
}
|
||||
})
|
||||
|
||||
return result.trim()
|
||||
}
|
||||
|
||||
module.exports = objectToKeyValueString
|
@ -0,0 +1,125 @@
|
||||
const standardVariables = {
|
||||
CONFIG_URL: {
|
||||
type: "string",
|
||||
name: "configUrl"
|
||||
},
|
||||
DOM_ID: {
|
||||
type: "string",
|
||||
name: "dom_id"
|
||||
},
|
||||
SPEC: {
|
||||
type: "object",
|
||||
name: "spec"
|
||||
},
|
||||
URL: {
|
||||
type: "string",
|
||||
name: "url"
|
||||
},
|
||||
URLS: {
|
||||
type: "array",
|
||||
name: "urls"
|
||||
},
|
||||
URLS_PRIMARY_NAME: {
|
||||
type: "string",
|
||||
name: "urls.primaryName"
|
||||
},
|
||||
QUERY_CONFIG_ENABLED: {
|
||||
type: "boolean",
|
||||
name: "queryConfigEnabled"
|
||||
},
|
||||
LAYOUT: {
|
||||
type: "string",
|
||||
name: "layout"
|
||||
},
|
||||
DEEP_LINKING: {
|
||||
type: "boolean",
|
||||
name: "deepLinking"
|
||||
},
|
||||
DISPLAY_OPERATION_ID: {
|
||||
type: "boolean",
|
||||
name: "displayOperationId"
|
||||
},
|
||||
DEFAULT_MODELS_EXPAND_DEPTH: {
|
||||
type: "number",
|
||||
name: "defaultModelsExpandDepth"
|
||||
},
|
||||
DEFAULT_MODEL_EXPAND_DEPTH: {
|
||||
type: "number",
|
||||
name: "defaultModelExpandDepth"
|
||||
},
|
||||
DEFAULT_MODEL_RENDERING: {
|
||||
type: "string",
|
||||
name: "defaultModelRendering"
|
||||
},
|
||||
DISPLAY_REQUEST_DURATION: {
|
||||
type: "boolean",
|
||||
name: "displayRequestDuration"
|
||||
},
|
||||
DOC_EXPANSION: {
|
||||
type: "string",
|
||||
name: "docExpansion"
|
||||
},
|
||||
FILTER: {
|
||||
type: "string",
|
||||
name: "filter"
|
||||
},
|
||||
MAX_DISPLAYED_TAGS: {
|
||||
type: "number",
|
||||
name: "maxDisplayedTags"
|
||||
},
|
||||
SHOW_EXTENSIONS: {
|
||||
type: "boolean",
|
||||
name: "showExtensions"
|
||||
},
|
||||
SHOW_COMMON_EXTENSIONS: {
|
||||
type: "boolean",
|
||||
name: "showCommonExtensions"
|
||||
},
|
||||
USE_UNSAFE_MARKDOWN: {
|
||||
type: "boolean",
|
||||
name: "useUnsafeMarkdown"
|
||||
},
|
||||
OAUTH2_REDIRECT_URL: {
|
||||
type: "string",
|
||||
name: "oauth2RedirectUrl"
|
||||
},
|
||||
PERSIST_AUTHORIZATION: {
|
||||
type: "boolean",
|
||||
name: "persistAuthorization"
|
||||
},
|
||||
SHOW_MUTATED_REQUEST: {
|
||||
type: "boolean",
|
||||
name: "showMutatedRequest"
|
||||
},
|
||||
SUPPORTED_SUBMIT_METHODS: {
|
||||
type: "array",
|
||||
name: "supportedSubmitMethods"
|
||||
},
|
||||
TRY_IT_OUT_ENABLED: {
|
||||
type: "boolean",
|
||||
name: "tryItOutEnabled"
|
||||
},
|
||||
VALIDATOR_URL: {
|
||||
type: "string",
|
||||
name: "validatorUrl"
|
||||
},
|
||||
WITH_CREDENTIALS: {
|
||||
type: "boolean",
|
||||
name: "withCredentials",
|
||||
}
|
||||
}
|
||||
|
||||
const legacyVariables = {
|
||||
API_URL: {
|
||||
type: "string",
|
||||
name: "url",
|
||||
legacy: true
|
||||
},
|
||||
API_URLS: {
|
||||
type: "array",
|
||||
name: "urls",
|
||||
legacy: true
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Object.assign({}, standardVariables, legacyVariables)
|
14
public/static/js/swagger/swagger-ui-5.17.14/docker/cors.conf
Normal file
14
public/static/js/swagger/swagger-ui-5.17.14/docker/cors.conf
Normal file
@ -0,0 +1,14 @@
|
||||
add_header 'Access-Control-Allow-Origin' '*' always;
|
||||
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
|
||||
#
|
||||
# Custom headers and headers various browsers *should* be OK with but aren't
|
||||
#
|
||||
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type' always;
|
||||
#
|
||||
# Tell client that this pre-flight info is valid for 20 days
|
||||
#
|
||||
add_header 'Access-Control-Max-Age' $access_control_max_age always;
|
||||
|
||||
if ($request_method = OPTIONS) {
|
||||
return 204;
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
types {
|
||||
text/plain yaml;
|
||||
text/plain yml;
|
||||
}
|
||||
|
||||
gzip on;
|
||||
gzip_static on;
|
||||
gzip_disable "msie6";
|
||||
|
||||
gzip_vary on;
|
||||
gzip_types text/plain text/css application/javascript;
|
||||
|
||||
map $request_method $access_control_max_age {
|
||||
OPTIONS 1728000; # 20 days
|
||||
}
|
||||
server_tokens off; # Hide Nginx version
|
||||
|
||||
server {
|
||||
listen $PORT;
|
||||
server_name localhost;
|
||||
index index.html index.htm;
|
||||
|
||||
location $BASE_URL {
|
||||
absolute_redirect off;
|
||||
alias /usr/share/nginx/html/;
|
||||
expires 1d;
|
||||
|
||||
location ~ swagger-initializer.js {
|
||||
expires -1;
|
||||
include templates/cors.conf;
|
||||
}
|
||||
|
||||
location ~* \.(?:json|yml|yaml)$ {
|
||||
#SWAGGER_ROOT
|
||||
expires -1;
|
||||
|
||||
include templates/cors.conf;
|
||||
}
|
||||
|
||||
include templates/cors.conf;
|
||||
include templates/embedding.conf;
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
#! /bin/sh
|
||||
|
||||
set -e
|
||||
NGINX_ROOT=/usr/share/nginx/html
|
||||
INITIALIZER_SCRIPT=$NGINX_ROOT/swagger-initializer.js
|
||||
NGINX_CONF=/etc/nginx/conf.d/default.conf
|
||||
|
||||
node /usr/share/nginx/configurator $INITIALIZER_SCRIPT
|
||||
|
||||
|
||||
if [ "$SWAGGER_JSON_URL" ]; then
|
||||
sed -i "s|https://petstore.swagger.io/v2/swagger.json|$SWAGGER_JSON_URL|g" $INITIALIZER_SCRIPT
|
||||
sed -i "s|http://example.com/api|$SWAGGER_JSON_URL|g" $INITIALIZER_SCRIPT
|
||||
fi
|
||||
|
||||
if [[ -f "$SWAGGER_JSON" ]]; then
|
||||
cp -s "$SWAGGER_JSON" "$NGINX_ROOT"
|
||||
REL_PATH="./$(basename $SWAGGER_JSON)"
|
||||
|
||||
if [[ -z "$SWAGGER_ROOT" ]]; then
|
||||
SWAGGER_ROOT="$(dirname $SWAGGER_JSON)"
|
||||
fi
|
||||
|
||||
if [[ "$BASE_URL" != "/" ]]
|
||||
then
|
||||
BASE_URL=$(echo $BASE_URL | sed 's/\/$//')
|
||||
sed -i \
|
||||
"s|#SWAGGER_ROOT|rewrite ^$BASE_URL(/.*)$ \$1 break;\n #SWAGGER_ROOT|" \
|
||||
$NGINX_CONF
|
||||
fi
|
||||
sed -i "s|#SWAGGER_ROOT|root $SWAGGER_ROOT/;|g" $NGINX_CONF
|
||||
|
||||
sed -i "s|https://petstore.swagger.io/v2/swagger.json|$REL_PATH|g" $INITIALIZER_SCRIPT
|
||||
sed -i "s|http://example.com/api|$REL_PATH|g" $INITIALIZER_SCRIPT
|
||||
fi
|
||||
|
||||
# enable/disable the address and port for IPv6 addresses that nginx listens on
|
||||
if [[ -n "${PORT_IPV6}" ]]; then
|
||||
sed -i "s|${PORT};|${PORT};\n listen [::]:${PORT_IPV6};|g" $NGINX_CONF
|
||||
fi
|
||||
|
||||
# enable/disable CORS
|
||||
if [ "$CORS" != "true" ]; then
|
||||
truncate -s 0 /etc/nginx/templates/cors.conf
|
||||
fi
|
||||
|
||||
# allow/disallow embedding the swagger-ui in frames/iframes from different origins
|
||||
if [ "$EMBEDDING" != "false" ]; then
|
||||
truncate -s 0 /etc/nginx/templates/embedding.conf
|
||||
fi
|
||||
|
||||
find $NGINX_ROOT -type f -regex ".*\.\(html\|js\|css\)" -exec sh -c "gzip < {} > {}.gz" \;
|
@ -0,0 +1,5 @@
|
||||
#
|
||||
# Prevent displaying inside an iframe
|
||||
#
|
||||
add_header 'X-Frame-Options' 'DENY' always;
|
||||
add_header 'Content-Security-Policy' "frame-ancestors 'none'" always;
|
26
public/static/js/swagger/swagger-ui-5.17.14/docs/README.md
Normal file
26
public/static/js/swagger/swagger-ui-5.17.14/docs/README.md
Normal file
@ -0,0 +1,26 @@
|
||||
# Swagger UI
|
||||
|
||||
Welcome to the Swagger UI documentation!
|
||||
|
||||
## Usage
|
||||
|
||||
- [Installation](usage/installation.md)
|
||||
- [Configuration](usage/configuration.md)
|
||||
- [CORS](usage/cors.md)
|
||||
- [OAuth2](usage/oauth2.md)
|
||||
- [Deep Linking](usage/deep-linking.md)
|
||||
- [Limitations](usage/limitations.md)
|
||||
- [Version detection](usage/version-detection.md)
|
||||
|
||||
## Customization
|
||||
|
||||
- [Overview](customization/overview.md)
|
||||
- [Plugin API](customization/plugin-api.md)
|
||||
- [Custom layout](customization/custom-layout.md)
|
||||
- [Adding plugin](customization/add-plugin.md)
|
||||
- [Plug-Points](customization/plug-points.md)
|
||||
|
||||
## Development
|
||||
|
||||
- [Setting up](development/setting-up.md)
|
||||
- [Scripts](development/scripts.md)
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"title": "Swagger UI"
|
||||
}
|
@ -0,0 +1,127 @@
|
||||
# Add a plugin
|
||||
|
||||
### Swagger-UI relies on plugins for all the good stuff.
|
||||
|
||||
Plugins allow you to add
|
||||
- `statePlugins`
|
||||
- `selectors` - query the state
|
||||
- `reducers` - modify the state
|
||||
- `actions` - fire and forget, that will eventually be handled by a reducer. You *can* rely on the result of async actions. But in general it's not recommended
|
||||
- `wrapActions` - replace an action with a wrapped action (useful for hooking into existing `actions`)
|
||||
- `components` - React components
|
||||
- `fn` - commons functions
|
||||
|
||||
To add a plugin we include it in the configs...
|
||||
|
||||
```js
|
||||
SwaggerUI({
|
||||
url: 'some url',
|
||||
plugins: [ ... ]
|
||||
})
|
||||
```
|
||||
|
||||
Or if you're updating the core plugins.. you'll add it to the base preset: [src/core/presets/base/index.js](https://github.com/swagger-api/swagger-ui/blob/master/src/core/presets/base/index.js)
|
||||
|
||||
Each Plugin is a function that returns an object. That object will get merged with the `system` and later bound to the state.
|
||||
Here is an example of each `type`
|
||||
|
||||
```js
|
||||
// A contrived, but quite full example....
|
||||
|
||||
export function SomePlugin(toolbox) {
|
||||
|
||||
const UPDATE_SOMETHING = "some_namespace_update_something" // strings just need to be uniuqe... see below
|
||||
|
||||
// Tools
|
||||
const fromJS = toolbox.Im.fromJS // needed below
|
||||
const createSelector = toolbox.createSelector // same, needed below
|
||||
|
||||
return {
|
||||
statePlugins: {
|
||||
|
||||
someNamespace: {
|
||||
actions: {
|
||||
actionName: (args)=> ({type: UPDATE_SOMETHING, payload: args}), // Synchronous action must return an object for the reducer to handle
|
||||
anotherAction: (a,b,c) => (system) => system.someNamespaceActions.actionName(a || b) // Asynchronous actions must return a function. The function gets the whole system, and can call other actions (based on state if needed)
|
||||
},
|
||||
wrapActions: {
|
||||
anotherAction: (oriAction, system) => (...args) => {
|
||||
oriAction(...args) // Usually we at least call the original action
|
||||
system.someNamespace.actionName(...args) // why not call this?
|
||||
console.log("args", args) // Log the args
|
||||
// anotherAction in the someNamespace has now been replaced with the this function
|
||||
}
|
||||
},
|
||||
reducers: {
|
||||
[UPDATE_SOMETHING]: (state, action) => { // Take a state (which is immutable) and an action (see synchronous actions) and return a new state
|
||||
return state.set("something", fromJS(action.payload)) // we're updating the Immutable state object... we need to convert vanilla objects into an immutable type (fromJS)
|
||||
// See immutable about how to modify the state
|
||||
// PS: you're only working with the state under the namespace, in this case "someNamespace". So you can do what you want, without worrying about /other/ namespaces
|
||||
}
|
||||
},
|
||||
selectors: {
|
||||
// creatSelector takes a list of fn's and passes all the results to the last fn.
|
||||
// eg: createSelector(a => a, a => a+1, (a,a2) => a + a2)(1) // = 3
|
||||
something: createSelector( // see [reselect#createSelector](https://github.com/reactjs/reselect#createselectorinputselectors--inputselectors-resultfunc)
|
||||
getState => getState(), // This is a requirement... because we `bind` selectors, we don't want to bind to any particular state (which is an immutable value) so we bind to a function, which returns the current state
|
||||
state => state.get("something") // return the whatever "something" points to
|
||||
),
|
||||
foo: getState => "bar" // In the end selectors are just functions that we pass getState to
|
||||
}
|
||||
}
|
||||
|
||||
... // you can include as many namespaces as you want. They just get merged into the 'system'
|
||||
|
||||
},
|
||||
|
||||
components: {
|
||||
foo: ()=> <h1> Hello </h1> // just a map of names to react components, naturally you'd want to import a fuller react component
|
||||
},
|
||||
|
||||
fn: {
|
||||
addOne: (a) => a + 1 // just any extra functions you want to include
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
>The plugin factory gets one argument, which I like to call `toolbox`.
|
||||
This argument is the entire plugin system (at the point the plugin factory is called). It also includes a reference to the `Immutable` lib, so that plugin authors don't need to include it.
|
||||
|
||||
|
||||
### The Plugin system
|
||||
|
||||
Each plugin you include will end up getting merged into the `system`, which is just an object.
|
||||
|
||||
Then we bind the `system` to our state. And flatten it, so that we don't need to reach into deep objects
|
||||
|
||||
> ie: spec.actions becomes specActions, spec.selectors becomes specSelectors
|
||||
|
||||
You can reach this bound system by calling `getSystem` on the store.
|
||||
|
||||
`getSystem` is the heart of this whole project. Each container component will receive a spread of props from `getSystem`
|
||||
|
||||
here is an example....
|
||||
```js
|
||||
class Bobby extends React.Component {
|
||||
|
||||
handleClick(e) {
|
||||
this.props.someNamespaceActions.actionName() // fires an action... which the reducer will *eventually* see
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
let { someNamespaceSelectors, someNamespaceActions } = this.props // this.props has the whole state spread
|
||||
let something = someNamespaceSelectors.something() // calls our selector, which returns some state (either an immutable object or value)
|
||||
|
||||
return (
|
||||
<h1 onClick={this.handleClick.bind(this)}> Hello {something} </h1> // render the contents
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
TODO: a lot more elaboration
|
||||
`
|
@ -0,0 +1,92 @@
|
||||
# Creating a custom layout
|
||||
|
||||
**Layouts** are a special type of component that Swagger UI uses as the root component for the entire application. You can define custom layouts in order to have high-level control over what ends up on the page.
|
||||
|
||||
By default, Swagger UI uses `BaseLayout`, which is built into the application. You can specify a different layout to be used by passing the layout's name as the `layout` parameter to Swagger UI. Be sure to provide your custom layout as a component to Swagger UI.
|
||||
|
||||
<br>
|
||||
|
||||
For example, if you wanted to create a custom layout that only displayed operations, you could define an `OperationsLayout`:
|
||||
|
||||
```js
|
||||
import React from "react"
|
||||
|
||||
// Create the layout component
|
||||
class OperationsLayout extends React.Component {
|
||||
render() {
|
||||
const {
|
||||
getComponent
|
||||
} = this.props
|
||||
|
||||
const Operations = getComponent("operations", true)
|
||||
|
||||
return (
|
||||
<div className="swagger-ui">
|
||||
<Operations />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// Create the plugin that provides our layout component
|
||||
const OperationsLayoutPlugin = () => {
|
||||
return {
|
||||
components: {
|
||||
OperationsLayout: OperationsLayout
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Provide the plugin to Swagger-UI, and select OperationsLayout
|
||||
// as the layout for Swagger-UI
|
||||
SwaggerUI({
|
||||
url: "https://petstore.swagger.io/v2/swagger.json",
|
||||
plugins: [ OperationsLayoutPlugin ],
|
||||
layout: "OperationsLayout"
|
||||
})
|
||||
```
|
||||
|
||||
### Augmenting the default layout
|
||||
|
||||
If you'd like to build around the `BaseLayout` instead of replacing it, you can pull the `BaseLayout` into your custom layout and use it:
|
||||
|
||||
```js
|
||||
import React from "react"
|
||||
|
||||
// Create the layout component
|
||||
class AugmentingLayout extends React.Component {
|
||||
render() {
|
||||
const {
|
||||
getComponent
|
||||
} = this.props
|
||||
|
||||
const BaseLayout = getComponent("BaseLayout", true)
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="myCustomHeader">
|
||||
<h1>I have a custom header above Swagger-UI!</h1>
|
||||
</div>
|
||||
<BaseLayout />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// Create the plugin that provides our layout component
|
||||
const AugmentingLayoutPlugin = () => {
|
||||
return {
|
||||
components: {
|
||||
AugmentingLayout: AugmentingLayout
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Provide the plugin to Swagger-UI, and select AugmentingLayout
|
||||
// as the layout for Swagger-UI
|
||||
SwaggerUI({
|
||||
url: "https://petstore.swagger.io/v2/swagger.json",
|
||||
plugins: [ AugmentingLayoutPlugin ],
|
||||
layout: "AugmentingLayout"
|
||||
})
|
||||
```
|
@ -0,0 +1,71 @@
|
||||
# Plugin system overview
|
||||
|
||||
### Prior art
|
||||
|
||||
Swagger UI leans heavily on concepts and patterns found in React and Redux.
|
||||
|
||||
If you aren't already familiar, here's some suggested reading:
|
||||
|
||||
- [React: Quick Start (reactjs.org)](https://reactjs.org/docs/hello-world.html)
|
||||
- [Redux README (redux.js.org)](https://redux.js.org/)
|
||||
|
||||
In the following documentation, we won't take the time to define the fundamentals covered in the resources above.
|
||||
|
||||
> **Note**: Some of the examples in this section contain JSX, which is a syntax extension to JavaScript that is useful for writing React components.
|
||||
>
|
||||
> If you don't want to set up a build pipeline capable of translating JSX to JavaScript, take a look at [React without JSX (reactjs.org)](https://reactjs.org/docs/react-without-jsx.html). You can use our `system.React` reference to leverage React without needing to pull a copy into your project.
|
||||
|
||||
### The System
|
||||
|
||||
The _system_ is the heart of the Swagger UI application. At runtime, it's a JavaScript object that holds many things:
|
||||
|
||||
- React components
|
||||
- Bound Redux actions and reducers
|
||||
- Bound Reselect state selectors
|
||||
- System-wide collection of available components
|
||||
- Built-in helpers like `getComponent`, `makeMappedContainer`, and `getStore`
|
||||
- References to the React and Immutable.js libraries (`system.React`, `system.Im`)
|
||||
- User-defined helper functions
|
||||
|
||||
The system is built up when Swagger UI is called by iterating through ("compiling") each plugin that Swagger UI has been given, through the `presets` and `plugins` configuration options.
|
||||
|
||||
### Presets
|
||||
|
||||
Presets are arrays of plugins, which are provided to Swagger UI through the `presets` configuration option. All plugins within presets are compiled before any plugins provided via the `plugins` configuration option. Consider the following example:
|
||||
|
||||
```javascript
|
||||
const MyPreset = [FirstPlugin, SecondPlugin, ThirdPlugin]
|
||||
|
||||
SwaggerUI({
|
||||
presets: [
|
||||
MyPreset
|
||||
]
|
||||
})
|
||||
```
|
||||
|
||||
By default, Swagger UI includes the internal `ApisPreset`, which contains a set of plugins that provide baseline functionality for Swagger UI. If you specify your own `presets` option, you need to add the ApisPreset manually, like so:
|
||||
|
||||
```javascript
|
||||
SwaggerUI({
|
||||
presets: [
|
||||
SwaggerUI.presets.apis,
|
||||
MyAmazingCustomPreset
|
||||
]
|
||||
})
|
||||
```
|
||||
|
||||
The need to provide the `apis` preset when adding other presets is an artifact of Swagger UI's original design, and will likely be removed in the next major version.
|
||||
|
||||
### getComponent
|
||||
|
||||
`getComponent` is a helper function injected into every container component, which is used to get references to components provided by the plugin system.
|
||||
|
||||
All components should be loaded through `getComponent`, since it allows other plugins to modify the component. It is preferred over a conventional `import` statement.
|
||||
|
||||
Container components in Swagger UI can be loaded by passing `true` as the second argument to `getComponent`, like so:
|
||||
|
||||
```javascript
|
||||
getComponent("ContainerComponentName", true)
|
||||
```
|
||||
|
||||
This will map the current system as props to the component.
|
@ -0,0 +1,415 @@
|
||||
# Plug points
|
||||
|
||||
Swagger UI exposes most of its internal logic through the plugin system.
|
||||
|
||||
Often, it is beneficial to override the core internals to achieve custom behavior.
|
||||
|
||||
### Note: Semantic Versioning
|
||||
|
||||
Swagger UI's internal APIs are _not_ part of our public contract, which means that they can change without the major version change.
|
||||
|
||||
If your custom plugins wrap, extend, override, or consume any internal core APIs, we recommend specifying a specific minor version of Swagger UI to use in your application, because they will _not_ change between patch versions.
|
||||
|
||||
If you're installing Swagger UI via NPM, for example, you can do this by using a tilde:
|
||||
|
||||
```js
|
||||
{
|
||||
"dependencies": {
|
||||
"swagger-ui": "~3.11.0"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### `fn.opsFilter`
|
||||
|
||||
When using the `filter` option, tag names will be filtered by the user-provided value. If you'd like to customize this behavior, you can override the default `opsFilter` function.
|
||||
|
||||
For example, you can implement a multiple-phrase filter:
|
||||
|
||||
```js
|
||||
const MultiplePhraseFilterPlugin = function() {
|
||||
return {
|
||||
fn: {
|
||||
opsFilter: (taggedOps, phrase) => {
|
||||
const phrases = phrase.split(", ")
|
||||
|
||||
return taggedOps.filter((val, key) => {
|
||||
return phrases.some(item => key.indexOf(item) > -1)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
### Logo component
|
||||
While using the Standalone Preset the SwaggerUI logo is rendered in the Top Bar.
|
||||
The logo can be exchanged by replacing the `Logo` component via the plugin api:
|
||||
|
||||
```jsx
|
||||
import React from "react";
|
||||
const MyLogoPlugin = {
|
||||
components: {
|
||||
Logo: () => (
|
||||
<img alt="My Logo" height="40" src="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTM3IiBoZWlnaHQ9IjEzNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KCiA8Zz4KICA8dGl0bGU+TGF5ZXIgMTwvdGl0bGU+CiAgPHRleHQgdHJhbnNmb3JtPSJtYXRyaXgoMy40Nzc2OSAwIDAgMy4yNjA2NyAtNjczLjEyOCAtNjkxLjk5MykiIHN0cm9rZT0iIzAwMCIgZm9udC1zdHlsZT0ibm9ybWFsIiBmb250LXdlaWdodD0ibm9ybWFsIiB4bWw6c3BhY2U9InByZXNlcnZlIiB0ZXh0LWFuY2hvcj0ic3RhcnQiIGZvbnQtZmFtaWx5PSInT3BlbiBTYW5zIEV4dHJhQm9sZCciIGZvbnQtc2l6ZT0iMjQiIGlkPSJzdmdfMSIgeT0iMjQxLjIyMTkyIiB4PSIxOTYuOTY5MjEiIHN0cm9rZS13aWR0aD0iMCIgZmlsbD0iIzYyYTAzZiI+TXkgTG9nbzwvdGV4dD4KICA8cGF0aCBpZD0ic3ZnXzIiIGQ9Im0zOTUuNjAyNSw1MS4xODM1OWw1My44Nzc3MSwwbDE2LjY0ODYzLC01MS4xODM1OGwxNi42NDg2NCw1MS4xODM1OGw1My44Nzc3LDBsLTQzLjU4NzksMzEuNjMyODNsMTYuNjQ5NDksNTEuMTgzNThsLTQzLjU4NzkyLC0zMS42MzM2OWwtNDMuNTg3OTEsMzEuNjMzNjlsMTYuNjQ5NDksLTUxLjE4MzU4bC00My41ODc5MiwtMzEuNjMyODN6IiBzdHJva2Utd2lkdGg9IjAiIHN0cm9rZT0iIzAwMCIgZmlsbD0iIzYyYTAzZiIvPgogPC9nPgo8L3N2Zz4="/>
|
||||
)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### JSON Schema components
|
||||
In swagger there are so called JSON Schema components. These are used to render inputs for parameters and components of request bodies with `application/x-www-form-urlencoded` or `multipart/*` media-type.
|
||||
|
||||
Internally swagger uses following mapping to find the JSON Schema component from OpenAPI Specification schema information:
|
||||
|
||||
For each schema’s type(eg. `string`, `array`, …) and if defined schema’s format (eg. ‘date’, ‘uuid’, …) there is a corresponding component mapping:
|
||||
|
||||
**If format defined:**
|
||||
```js
|
||||
`JsonSchema_${type}_${format}`
|
||||
```
|
||||
|
||||
**Fallback if `JsonSchema_${type}_${format}` component does not exist or format not defined:**
|
||||
```js
|
||||
`JsonSchema_${type}`
|
||||
```
|
||||
|
||||
**Default:**
|
||||
```js
|
||||
`JsonSchema_string`
|
||||
```
|
||||
|
||||
With this, one can define custom input components or override existing.
|
||||
|
||||
#### Example Date-Picker plugin
|
||||
|
||||
If one would like to input date values you could provide a custom plugin to integrate [react-datepicker](https://www.npmjs.com/package/react-datepicker) into swagger-ui.
|
||||
All you need to do is to create a component to wrap [react-datepicker](https://www.npmjs.com/package/react-datepicker) accordingly to the format.
|
||||
|
||||
**There are two cases:**
|
||||
- ```yaml
|
||||
type: string
|
||||
format: date
|
||||
```
|
||||
The resulting name for mapping to succeed: `JsonSchema_string_date`
|
||||
- ```yaml
|
||||
type: string
|
||||
format: date-time
|
||||
```
|
||||
The resulting name for mapping to succeed: `JsonSchema_string_date-time`
|
||||
|
||||
This creates the need for two components and simple logic to strip any time input in case the format is date:
|
||||
```js
|
||||
import React from "react";
|
||||
import DatePicker from "react-datepicker";
|
||||
import "react-datepicker/dist/react-datepicker.css";
|
||||
|
||||
const JsonSchema_string_date = (props) => {
|
||||
const dateNumber = Date.parse(props.value);
|
||||
const date = dateNumber
|
||||
? new Date(dateNumber)
|
||||
: new Date();
|
||||
|
||||
return (
|
||||
<DatePicker
|
||||
selected={date}
|
||||
onChange={d => props.onChange(d.toISOString().substring(0, 10))}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
const JsonSchema_string_date_time = (props) => {
|
||||
const dateNumber = Date.parse(props.value);
|
||||
const date = dateNumber
|
||||
? new Date(dateNumber)
|
||||
: new Date();
|
||||
|
||||
return (
|
||||
<DatePicker
|
||||
selected={date}
|
||||
onChange={d => props.onChange(d.toISOString())}
|
||||
showTimeSelect
|
||||
timeFormat="p"
|
||||
dateFormat="Pp"
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
export const DateTimeSwaggerPlugin = {
|
||||
components: {
|
||||
JsonSchema_string_date: JsonSchema_string_date,
|
||||
"JsonSchema_string_date-time": JsonSchema_string_date_time
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
### Request Snippets
|
||||
|
||||
SwaggerUI can be configured with the `requestSnippetsEnabled: true` option to activate Request Snippets.
|
||||
Instead of the generic curl that is generated upon doing a request. It gives you more granular options:
|
||||
- curl for bash
|
||||
- curl for cmd
|
||||
- curl for powershell
|
||||
|
||||
There might be the case where you want to provide your own snipped generator. This can be done by using the plugin api.
|
||||
A Request Snipped generator consists of the configuration and a `fn`,
|
||||
which takes the internal request object and transforms it to the desired snippet.
|
||||
|
||||
```js
|
||||
// Add config to Request Snippets Configuration with an unique key like "node_native"
|
||||
const snippetConfig = {
|
||||
requestSnippetsEnabled: true,
|
||||
requestSnippets: {
|
||||
generators: {
|
||||
"node_native": {
|
||||
title: "NodeJs Native",
|
||||
syntax: "javascript"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const SnippedGeneratorNodeJsPlugin = {
|
||||
fn: {
|
||||
// use `requestSnippetGenerator_` + key from config (node_native) for generator fn
|
||||
requestSnippetGenerator_node_native: (request) => {
|
||||
const url = new Url(request.get("url"))
|
||||
let isMultipartFormDataRequest = false
|
||||
const headers = request.get("headers")
|
||||
if(headers && headers.size) {
|
||||
request.get("headers").map((val, key) => {
|
||||
isMultipartFormDataRequest = isMultipartFormDataRequest || /^content-type$/i.test(key) && /^multipart\/form-data$/i.test(val)
|
||||
})
|
||||
}
|
||||
const packageStr = url.protocol === "https:" ? "https" : "http"
|
||||
let reqBody = request.get("body")
|
||||
if (request.get("body")) {
|
||||
if (isMultipartFormDataRequest && ["POST", "PUT", "PATCH"].includes(request.get("method"))) {
|
||||
return "throw new Error(\"Currently unsupported content-type: /^multipart\\/form-data$/i\");"
|
||||
} else {
|
||||
if (!Map.isMap(reqBody)) {
|
||||
if (typeof reqBody !== "string") {
|
||||
reqBody = JSON.stringify(reqBody)
|
||||
}
|
||||
} else {
|
||||
reqBody = getStringBodyOfMap(request)
|
||||
}
|
||||
}
|
||||
} else if (!request.get("body") && request.get("method") === "POST") {
|
||||
reqBody = ""
|
||||
}
|
||||
|
||||
const stringBody = "`" + (reqBody || "")
|
||||
.replace(/\\n/g, "\n")
|
||||
.replace(/`/g, "\\`")
|
||||
+ "`"
|
||||
|
||||
return `const http = require("${packageStr}");
|
||||
const options = {
|
||||
"method": "${request.get("method")}",
|
||||
"hostname": "${url.host}",
|
||||
"port": ${url.port || "null"},
|
||||
"path": "${url.pathname}"${headers && headers.size ? `,
|
||||
"headers": {
|
||||
${request.get("headers").map((val, key) => `"${key}": "${val}"`).valueSeq().join(",\n ")}
|
||||
}` : ""}
|
||||
};
|
||||
const req = http.request(options, function (res) {
|
||||
const chunks = [];
|
||||
res.on("data", function (chunk) {
|
||||
chunks.push(chunk);
|
||||
});
|
||||
res.on("end", function () {
|
||||
const body = Buffer.concat(chunks);
|
||||
console.log(body.toString());
|
||||
});
|
||||
});
|
||||
${reqBody ? `\nreq.write(${stringBody});` : ""}
|
||||
req.end();`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const ui = SwaggerUIBundle({
|
||||
"dom_id": "#swagger-ui",
|
||||
deepLinking: true,
|
||||
presets: [
|
||||
SwaggerUIBundle.presets.apis,
|
||||
SwaggerUIStandalonePreset
|
||||
],
|
||||
plugins: [
|
||||
SwaggerUIBundle.plugins.DownloadUrl,
|
||||
SnippedGeneratorNodeJsPlugin
|
||||
],
|
||||
layout: "StandaloneLayout",
|
||||
validatorUrl: "https://validator.swagger.io/validator",
|
||||
url: "https://petstore.swagger.io/v2/swagger.json",
|
||||
...snippetConfig,
|
||||
})
|
||||
```
|
||||
|
||||
### Error handling
|
||||
|
||||
SwaggerUI comes with a `safe-render` plugin that handles error handling allows plugging into error handling system and modify it.
|
||||
|
||||
The plugin accepts a list of component names that should be protected by error boundaries.
|
||||
|
||||
Its public API looks like this:
|
||||
|
||||
```js
|
||||
{
|
||||
fn: {
|
||||
componentDidCatch,
|
||||
withErrorBoundary: withErrorBoundary(getSystem),
|
||||
},
|
||||
components: {
|
||||
ErrorBoundary,
|
||||
Fallback,
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
safe-render plugin is automatically utilized by [base](https://github.com/swagger-api/swagger-ui/blob/78f62c300a6d137e65fd027d850981b010009970/src/core/presets/base.js) and [standalone](https://github.com/swagger-api/swagger-ui/tree/78f62c300a6d137e65fd027d850981b010009970/src/standalone) SwaggerUI presets and
|
||||
should always be used as the last plugin, after all the components are already known to the SwaggerUI.
|
||||
The plugin defines a default list of components that should be protected by error boundaries:
|
||||
|
||||
```js
|
||||
[
|
||||
"App",
|
||||
"BaseLayout",
|
||||
"VersionPragmaFilter",
|
||||
"InfoContainer",
|
||||
"ServersContainer",
|
||||
"SchemesContainer",
|
||||
"AuthorizeBtnContainer",
|
||||
"FilterContainer",
|
||||
"Operations",
|
||||
"OperationContainer",
|
||||
"parameters",
|
||||
"responses",
|
||||
"OperationServers",
|
||||
"Models",
|
||||
"ModelWrapper",
|
||||
"Topbar",
|
||||
"StandaloneLayout",
|
||||
"onlineValidatorBadge"
|
||||
]
|
||||
```
|
||||
|
||||
As demonstrated below, additional components can be protected by utilizing the safe-render plugin
|
||||
with configuration options. This gets really handy if you are a SwaggerUI integrator and you maintain a number of
|
||||
plugins with additional custom components.
|
||||
|
||||
```js
|
||||
const swaggerUI = SwaggerUI({
|
||||
url: "https://petstore.swagger.io/v2/swagger.json",
|
||||
dom_id: '#swagger-ui',
|
||||
plugins: [
|
||||
() => ({
|
||||
components: {
|
||||
MyCustomComponent1: () => 'my custom component',
|
||||
},
|
||||
}),
|
||||
SwaggerUI.plugins.SafeRender({
|
||||
fullOverride: true, // only the component list defined here will apply (not the default list)
|
||||
componentList: [
|
||||
"MyCustomComponent1",
|
||||
],
|
||||
}),
|
||||
],
|
||||
});
|
||||
```
|
||||
|
||||
##### componentDidCatch
|
||||
|
||||
This static function is invoked after a component has thrown an error.
|
||||
It receives two parameters:
|
||||
|
||||
1. `error` - The error that was thrown.
|
||||
2. `info` - An object with a componentStack key containing [information about which component threw the error](https://reactjs.org/docs/error-boundaries.html#component-stack-traces).
|
||||
|
||||
It has precisely the same signature as error boundaries [componentDidCatch lifecycle method](https://reactjs.org/docs/react-component.html#componentdidcatch),
|
||||
except it's a static function and not a class method.
|
||||
|
||||
Default implement of componentDidCatch uses `console.error` to display the received error:
|
||||
|
||||
```js
|
||||
export const componentDidCatch = console.error;
|
||||
```
|
||||
|
||||
To utilize your own error handling logic (e.g. [bugsnag](https://www.bugsnag.com/)), create new SwaggerUI plugin that overrides componentDidCatch:
|
||||
|
||||
{% highlight js linenos %}
|
||||
const BugsnagErrorHandlerPlugin = () => {
|
||||
// init bugsnag
|
||||
|
||||
return {
|
||||
fn: {
|
||||
componentDidCatch = (error, info) => {
|
||||
Bugsnag.notify(error);
|
||||
Bugsnag.notify(info);
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
{% endhighlight %}
|
||||
|
||||
##### withErrorBoundary
|
||||
|
||||
This function is HOC (Higher Order Component). It wraps a particular component into the `ErrorBoundary` component.
|
||||
It can be overridden via a plugin system to control how components are wrapped by the ErrorBoundary component.
|
||||
In 99.9% of situations, you won't need to override this function, but if you do, please read the source code of this function first.
|
||||
|
||||
##### Fallback
|
||||
|
||||
The component is displayed when the error boundary catches an error. It can be overridden via a plugin system.
|
||||
Its default implementation is trivial:
|
||||
|
||||
```js
|
||||
import React from "react"
|
||||
import PropTypes from "prop-types"
|
||||
|
||||
const Fallback = ({ name }) => (
|
||||
<div className="fallback">
|
||||
😱 <i>Could not render { name === "t" ? "this component" : name }, see the console.</i>
|
||||
</div>
|
||||
)
|
||||
Fallback.propTypes = {
|
||||
name: PropTypes.string.isRequired,
|
||||
}
|
||||
export default Fallback
|
||||
```
|
||||
|
||||
Feel free to override it to match your look & feel:
|
||||
|
||||
```js
|
||||
const CustomFallbackPlugin = () => ({
|
||||
components: {
|
||||
Fallback: ({ name } ) => `This is my custom fallback. ${name} failed to render`,
|
||||
},
|
||||
});
|
||||
|
||||
const swaggerUI = SwaggerUI({
|
||||
url: "https://petstore.swagger.io/v2/swagger.json",
|
||||
dom_id: '#swagger-ui',
|
||||
plugins: [
|
||||
CustomFallbackPlugin,
|
||||
]
|
||||
});
|
||||
```
|
||||
|
||||
##### ErrorBoundary
|
||||
|
||||
This is the component that implements React error boundaries. Uses `componentDidCatch` and `Fallback`
|
||||
under the hood. In 99.9% of situations, you won't need to override this component, but if you do,
|
||||
please read the source code of this component first.
|
||||
|
||||
|
||||
##### Change in behavior
|
||||
|
||||
In prior releases of SwaggerUI (before v4.3.0), almost all components have been protected, and when thrown error,
|
||||
`Fallback` component was displayed. This changes with SwaggerUI v4.3.0. Only components defined
|
||||
by the `safe-render` plugin are now protected and display fallback. If a small component somewhere within
|
||||
SwaggerUI React component tree fails to render and throws an error. The error bubbles up to the closest
|
||||
error boundary, and that error boundary displays the `Fallback` component and invokes `componentDidCatch`.
|
@ -0,0 +1,455 @@
|
||||
# Plugins
|
||||
|
||||
A plugin is a function that returns an object - more specifically, the object may contain functions and components that augment and modify Swagger UI's functionality.
|
||||
|
||||
### Note: Semantic Versioning
|
||||
|
||||
Swagger UI's internal APIs are _not_ part of our public contract, which means that they can change without the major version change.
|
||||
|
||||
If your custom plugins wrap, extend, override, or consume any internal core APIs, we recommend specifying a specific minor version of Swagger UI to use in your application, because they will _not_ change between patch versions.
|
||||
|
||||
If you're installing Swagger UI via NPM, for example, you can do this by using a tilde:
|
||||
|
||||
```js
|
||||
{
|
||||
"dependencies": {
|
||||
"swagger-ui": "~3.11.0"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Format
|
||||
|
||||
A plugin return value may contain any of these keys, where `stateKey` is a name for a piece of state:
|
||||
|
||||
```javascript
|
||||
{
|
||||
statePlugins: {
|
||||
[stateKey]: {
|
||||
actions,
|
||||
reducers,
|
||||
selectors,
|
||||
wrapActions,
|
||||
wrapSelectors
|
||||
}
|
||||
},
|
||||
components: {},
|
||||
wrapComponents: {},
|
||||
rootInjects: {},
|
||||
afterLoad: (system) => {},
|
||||
fn: {},
|
||||
}
|
||||
```
|
||||
|
||||
### System is provided to plugins
|
||||
|
||||
Let's assume we have a plugin, `NormalPlugin`, that exposes a `doStuff` action under the `normal` state namespace.
|
||||
|
||||
```javascript
|
||||
const ExtendingPlugin = function(system) {
|
||||
return {
|
||||
statePlugins: {
|
||||
extending: {
|
||||
actions: {
|
||||
doExtendedThings: function(...args) {
|
||||
// you can do other things in here if you want
|
||||
return system.normalActions.doStuff(...args)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
As you can see, each plugin is passed a reference to the `system` being built up. As long as `NormalPlugin` is compiled before `ExtendingPlugin`, this will work without any issues.
|
||||
|
||||
There is no dependency management built into the plugin system, so if you create a plugin that relies on another, it is your responsibility to make sure that the dependent plugin is loaded _after_ the plugin being depended on.
|
||||
|
||||
### Interfaces
|
||||
|
||||
#### Actions
|
||||
|
||||
```javascript
|
||||
const MyActionPlugin = () => {
|
||||
return {
|
||||
statePlugins: {
|
||||
example: {
|
||||
actions: {
|
||||
updateFavoriteColor: (str) => {
|
||||
return {
|
||||
type: "EXAMPLE_SET_FAV_COLOR",
|
||||
payload: str
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Once an action has been defined, you can use it anywhere that you can get a system reference:
|
||||
|
||||
```javascript
|
||||
// elsewhere
|
||||
system.exampleActions.updateFavoriteColor("blue")
|
||||
```
|
||||
|
||||
The Action interface enables the creation of new Redux action creators within a piece of state in the Swagger UI system.
|
||||
|
||||
This action creator function will be exposed to container components as `exampleActions.updateFavoriteColor`. When this action creator is called, the return value (which should be a [Flux Standard Action](https://github.com/acdlite/flux-standard-action)) will be passed to the `example` reducer, which we'll define in the next section.
|
||||
|
||||
For more information about the concept of actions in Redux, see the [Redux Actions documentation](https://redux.js.org/tutorials/fundamentals/part-2-concepts-data-flow#actions).
|
||||
|
||||
#### Reducers
|
||||
|
||||
Reducers take a state (which is an [Immutable.js map](https://facebook.github.io/immutable-js/docs/#/Map)) and an action, then returns a new state.
|
||||
|
||||
Reducers must be provided to the system under the name of the action type that they handle, in this case, `EXAMPLE_SET_FAV_COLOR`.
|
||||
|
||||
```javascript
|
||||
const MyReducerPlugin = function(system) {
|
||||
return {
|
||||
statePlugins: {
|
||||
example: {
|
||||
reducers: {
|
||||
"EXAMPLE_SET_FAV_COLOR": (state, action) => {
|
||||
// you're only working with the state under the namespace, in this case "example".
|
||||
// So you can do what you want, without worrying about /other/ namespaces
|
||||
return state.set("favColor", action.payload)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Selectors
|
||||
|
||||
Selectors reach into their namespace's state to retrieve or derive data from the state.
|
||||
|
||||
They're an easy way to keep logic in one place, and are preferred over passing state data directly into components.
|
||||
|
||||
|
||||
```javascript
|
||||
const MySelectorPlugin = function(system) {
|
||||
return {
|
||||
statePlugins: {
|
||||
example: {
|
||||
selectors: {
|
||||
myFavoriteColor: (state) => state.get("favColor")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
You can also use the Reselect library to memoize your selectors, which is recommended for any selectors that will see heavy use, since Reselect automatically memoizes selector calls for you:
|
||||
|
||||
```javascript
|
||||
import { createSelector } from "reselect"
|
||||
|
||||
const MySelectorPlugin = function(system) {
|
||||
return {
|
||||
statePlugins: {
|
||||
example: {
|
||||
selectors: {
|
||||
// this selector will be memoized after it is run once for a
|
||||
// value of `state`
|
||||
myFavoriteColor: createSelector((state) => state.get("favColor"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Once a selector has been defined, you can use it anywhere that you can get a system reference:
|
||||
```javascript
|
||||
system.exampleSelectors.myFavoriteColor() // gets `favColor` in state for you
|
||||
```
|
||||
|
||||
#### Components
|
||||
|
||||
You can provide a map of components to be integrated into the system.
|
||||
|
||||
Be mindful of the key names for the components you provide, as you'll need to use those names to refer to the components elsewhere.
|
||||
|
||||
```javascript
|
||||
class HelloWorldClass extends React.Component {
|
||||
render() {
|
||||
return <h1>Hello World!</h1>
|
||||
}
|
||||
}
|
||||
|
||||
const MyComponentPlugin = function(system) {
|
||||
return {
|
||||
components: {
|
||||
HelloWorldClass: HelloWorldClass
|
||||
// components can just be functions, these are called "stateless components"
|
||||
HelloWorldStateless: () => <h1>Hello World!</h1>,
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
```javascript
|
||||
// elsewhere
|
||||
const HelloWorldStateless = system.getComponent("HelloWorldStateless")
|
||||
const HelloWorldClass = system.getComponent("HelloWorldClass")
|
||||
```
|
||||
|
||||
You can also "cancel out" any components that you don't want by creating a stateless component that always returns `null`:
|
||||
|
||||
```javascript
|
||||
const NeverShowInfoPlugin = function(system) {
|
||||
return {
|
||||
components: {
|
||||
info: () => null
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
You can use `config.failSilently` if you don't want a warning when a component doesn't exist in the system.
|
||||
|
||||
Be mindful of `getComponent` arguments order. In the example below, the boolean `false` refers to presence of a container, and the 3rd argument is the config object used to suppress the missing component warning.
|
||||
```javascript
|
||||
const thisVariableWillBeNull = getComponent("not_real", false, { failSilently: true })
|
||||
```
|
||||
|
||||
#### Wrap-Actions
|
||||
|
||||
Wrap Actions allow you to override the behavior of an action in the system.
|
||||
|
||||
They are function factories with the signature `(oriAction, system) => (...args) => result`.
|
||||
|
||||
A Wrap Action's first argument is `oriAction`, which is the action being wrapped. It is your responsibility to call the `oriAction` - if you don't, the original action will not fire!
|
||||
|
||||
This mechanism is useful for conditionally overriding built-in behaviors, or listening to actions.
|
||||
|
||||
```javascript
|
||||
// FYI: in an actual Swagger UI, `updateSpec` is already defined in the core code
|
||||
// it's just here for clarity on what's behind the scenes
|
||||
const MySpecPlugin = function(system) {
|
||||
return {
|
||||
statePlugins: {
|
||||
spec: {
|
||||
actions: {
|
||||
updateSpec: (str) => {
|
||||
return {
|
||||
type: "SPEC_UPDATE_SPEC",
|
||||
payload: str
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// this plugin allows you to watch changes to the spec that is in memory
|
||||
const MyWrapActionPlugin = function(system) {
|
||||
return {
|
||||
statePlugins: {
|
||||
spec: {
|
||||
wrapActions: {
|
||||
updateSpec: (oriAction, system) => (str) => {
|
||||
// here, you can hand the value to some function that exists outside of Swagger UI
|
||||
console.log("Here is my API definition", str)
|
||||
return oriAction(str) // don't forget! otherwise, Swagger UI won't update
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Wrap-Selectors
|
||||
|
||||
Wrap Selectors allow you to override the behavior of a selector in the system.
|
||||
|
||||
They are function factories with the signature `(oriSelector, system) => (state, ...args) => result`.
|
||||
|
||||
This interface is useful for controlling what data flows into components. We use this in the core code to disable selectors based on the API definition's version.
|
||||
|
||||
```javascript
|
||||
import { createSelector } from 'reselect'
|
||||
|
||||
// FYI: in an actual Swagger UI, the `url` spec selector is already defined
|
||||
// it's just here for clarity on what's behind the scenes
|
||||
const MySpecPlugin = function(system) {
|
||||
return {
|
||||
statePlugins: {
|
||||
spec: {
|
||||
selectors: {
|
||||
url: createSelector(
|
||||
state => state.get("url")
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const MyWrapSelectorsPlugin = function(system) {
|
||||
return {
|
||||
statePlugins: {
|
||||
spec: {
|
||||
wrapSelectors: {
|
||||
url: (oriSelector, system) => (state, ...args) => {
|
||||
console.log('someone asked for the spec url!!! it is', state.get('url'))
|
||||
// you can return other values here...
|
||||
// but let's just enable the default behavior
|
||||
return oriSelector(state, ...args)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Wrap-Components
|
||||
|
||||
Wrap Components allow you to override a component registered within the system.
|
||||
|
||||
Wrap Components are function factories with the signature `(OriginalComponent, system) => props => ReactElement`. If you'd prefer to provide a React component class, `(OriginalComponent, system) => ReactClass` works as well.
|
||||
|
||||
```javascript
|
||||
const MyWrapBuiltinComponentPlugin = function(system) {
|
||||
return {
|
||||
wrapComponents: {
|
||||
info: (Original, system) => (props) => {
|
||||
return <div>
|
||||
<h3>Hello world! I am above the Info component.</h3>
|
||||
<Original {...props} />
|
||||
</div>
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Here's another example that includes a code sample of a component that will be wrapped:
|
||||
|
||||
```javascript
|
||||
///// Overriding a component from a plugin
|
||||
|
||||
// Here's our normal, unmodified component.
|
||||
const MyNumberDisplayPlugin = function(system) {
|
||||
return {
|
||||
components: {
|
||||
NumberDisplay: ({ number }) => <span>{number}</span>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Here's a component wrapper defined as a function.
|
||||
const MyWrapComponentPlugin = function(system) {
|
||||
return {
|
||||
wrapComponents: {
|
||||
NumberDisplay: (Original, system) => (props) => {
|
||||
if(props.number > 10) {
|
||||
return <div>
|
||||
<h3>Warning! Big number ahead.</h3>
|
||||
<Original {...props} />
|
||||
</div>
|
||||
} else {
|
||||
return <Original {...props} />
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Alternatively, here's the same component wrapper defined as a class.
|
||||
const MyWrapComponentPlugin = function(system) {
|
||||
return {
|
||||
wrapComponents: {
|
||||
NumberDisplay: (Original, system) => class WrappedNumberDisplay extends React.component {
|
||||
render() {
|
||||
if(props.number > 10) {
|
||||
return <div>
|
||||
<h3>Warning! Big number ahead.</h3>
|
||||
<Original {...props} />
|
||||
</div>
|
||||
} else {
|
||||
return <Original {...props} />
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### `rootInjects`
|
||||
|
||||
The `rootInjects` interface allows you to inject values at the top level of the system.
|
||||
|
||||
This interface takes an object, which will be merged in with the top-level system object at runtime.
|
||||
|
||||
```js
|
||||
const MyRootInjectsPlugin = function(system) {
|
||||
return {
|
||||
rootInjects: {
|
||||
myConstant: 123,
|
||||
myMethod: (...params) => console.log(...params)
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### `afterLoad`
|
||||
|
||||
The `afterLoad` plugin method allows you to get a reference to the system after your plugin has been registered.
|
||||
|
||||
This interface is used in the core code to attach methods that are driven by bound selectors or actions. You can also use it to execute logic that requires your plugin to already be ready, for example fetching initial data from a remote endpoint and passing it to an action your plugin creates.
|
||||
|
||||
The plugin context, which is bound to `this`, is undocumented, but below is an example of how to attach a bound action as a top-level method:
|
||||
|
||||
```javascript
|
||||
const MyMethodProvidingPlugin = function() {
|
||||
return {
|
||||
afterLoad(system) {
|
||||
// at this point in time, your actions have been bound into the system
|
||||
// so you can do things with them
|
||||
this.rootInjects = this.rootInjects || {}
|
||||
this.rootInjects.myMethod = system.exampleActions.updateFavoriteColor
|
||||
},
|
||||
statePlugins: {
|
||||
example: {
|
||||
actions: {
|
||||
updateFavoriteColor: (str) => {
|
||||
return {
|
||||
type: "EXAMPLE_SET_FAV_COLOR",
|
||||
payload: str
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### fn
|
||||
|
||||
The fn interface allows you to add helper functions to the system for use elsewhere.
|
||||
|
||||
```javascript
|
||||
import leftPad from "left-pad"
|
||||
|
||||
const MyFnPlugin = function(system) {
|
||||
return {
|
||||
fn: {
|
||||
leftPad: leftPad
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
@ -0,0 +1,38 @@
|
||||
# Helpful scripts
|
||||
|
||||
Any of the scripts below can be run by typing `npm run <script name>` in the project's root directory.
|
||||
|
||||
### Developing
|
||||
Script name | Description
|
||||
--- | ---
|
||||
`dev` | Spawn a hot-reloading dev server on port 3200.
|
||||
`deps-check` | Generate a size and licensing report on Swagger UI's dependencies.
|
||||
`lint` | Report ESLint style errors and warnings.
|
||||
`lint-errors` | Report ESLint style errors, without warnings.
|
||||
`lint-fix` | Attempt to fix style errors automatically.
|
||||
`watch` | Rebuild the core files in `/dist` when the source code changes. Useful for `npm link` with Swagger Editor.
|
||||
|
||||
### Building
|
||||
Script name | Description
|
||||
--- | ---
|
||||
`build` | Build a new set of JS and CSS assets, and output them to `/dist`.
|
||||
`build-bundle` | Build `swagger-ui-bundle.js` only (commonJS).
|
||||
`build-core` | Build `swagger-ui.(js\|css)` only (commonJS).
|
||||
`build-standalone` | Build `swagger-ui-standalone-preset.js` only (commonJS).
|
||||
`build-stylesheets` | Build `swagger-ui.css` only.
|
||||
`build:es:bundle` | Build `swagger-ui-es-bundle.js` only (es2015).
|
||||
`build:es:bundle:core` | Build `swagger-ui-es-bundle-core.js` only (es2015).
|
||||
|
||||
### Testing
|
||||
Script name | Description
|
||||
--- | ---
|
||||
`test` | Run unit tests in Node, run Cypress end-to-end tests, and run ESLint in errors-only mode.
|
||||
`test:unit` | Run Jest unit tests in Node.
|
||||
`e2e` | Run end-to-end tests (requires JDK and Selenium).
|
||||
`e2e-cypress` | Run end-to-end browser tests with Cypress.
|
||||
`dev-e2e-cypress` | Dev mode, open Cypress runner and manually select tests to run.
|
||||
`lint` | Run ESLint test
|
||||
`test:artifact` | Run list of bundle artifact tests in Jest
|
||||
`test:artifact:umd:bundle` | Run unit test that confirms `swagger-ui-bundle` exports as a Function
|
||||
`test:artifact:es:bundle` | Run unit test that confirms `swagger-ui-es-bundle` exports as a Function
|
||||
`test:artifact:es:bundle:core` | Run unit test that confirms `swagger-ui-es-bundle-core` exports as a Function
|
@ -0,0 +1,38 @@
|
||||
# Setting up a dev environment
|
||||
|
||||
Swagger UI includes a development server that provides hot module reloading and unminified stack traces, for easier development.
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- git, any version
|
||||
- **Node.js >=20.3.0** and **npm >=9.6.7** are the minimum required versions that this repo runs on, but we always recommend using the latest version of Node.js.
|
||||
|
||||
### Steps
|
||||
|
||||
1. `git clone https://github.com/swagger-api/swagger-ui.git`
|
||||
2. `cd swagger-ui`
|
||||
3. `npm install`
|
||||
4. `npm run dev`
|
||||
5. Wait a bit
|
||||
6. Open http://localhost:3200/
|
||||
|
||||
### Using your own local api definition with local dev build
|
||||
|
||||
You can specify a local file in `dev-helpers/dev-helper-initializer.js` by changing the `url` parameter. This local file MUST be located in the `dev-helpers` directory or a subdirectory. As a convenience and best practice, we recommend that you create a subdirectory, `dev-helpers/examples`, which is already specified in `.gitignore`.
|
||||
|
||||
replace
|
||||
```
|
||||
url: "https://petstore.swagger.io/v2/swagger.json",
|
||||
```
|
||||
|
||||
with
|
||||
```
|
||||
url: "./examples/your-local-api-definition.yaml",
|
||||
```
|
||||
|
||||
Files in `dev-helpers` should NOT be committed to git. The exception is if you are fixing something in `index.html`, `oauth2-redirect.html`, `dev-helper-initializer.js`, or introducing a new support file.
|
||||
|
||||
## Bonus points
|
||||
|
||||
- Swagger UI includes an ESLint rule definition. If you use a graphical editor, consider installing an ESLint plugin, which will point out syntax and style errors for you as you code.
|
||||
- The linter runs as part of the PR test sequence, so don't think you can get away with not paying attention to it!
|
Binary file not shown.
After Width: | Height: | Size: 97 KiB |
Binary file not shown.
After Width: | Height: | Size: 78 KiB |
@ -0,0 +1,14 @@
|
||||
|
||||
### Demo of Swagger UI with Webpack.
|
||||
|
||||
This `webpack-getting-started` sample is for reference only.
|
||||
|
||||
It includes CSS and OAuth configuration.
|
||||
|
||||
`_sample_package.json` is a placeholder sample. You should rename this file, per `Usage` section below, and you should also verify and update this sample's `@latest` compared to the `swagger-ui@latest`
|
||||
|
||||
|
||||
#### Usage
|
||||
rename `_sample_package.json` to `package.json`
|
||||
npm install
|
||||
npm start
|
@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "swagger-ui-webpack-getting-started",
|
||||
"version": "0.0.1",
|
||||
"description": "A simple setup of Swagger UI with Webpack",
|
||||
"scripts": {
|
||||
"build": "webpack",
|
||||
"start": "webpack-dev-server --open"
|
||||
},
|
||||
"author": "Shaun Luttin",
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {
|
||||
"clean-webpack-plugin": "^4.0.0",
|
||||
"copy-webpack-plugin": "^11.0.0",
|
||||
"html-webpack-plugin": "^5.5.0",
|
||||
"webpack": "^5.74.0",
|
||||
"webpack-cli": "^4.10.0",
|
||||
"webpack-dev-server": "^4.11.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"css-loader": "^6.7.1",
|
||||
"json-loader": "^0.5.7",
|
||||
"style-loader": "^3.3.1",
|
||||
"swagger-ui": "^4.14.0",
|
||||
"yaml-loader": "^0.8.0"
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Getting Started</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="swagger"></div>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,15 @@
|
||||
import SwaggerUI from 'swagger-ui'
|
||||
import 'swagger-ui/dist/swagger-ui.css';
|
||||
|
||||
const spec = require('./swagger-config.yaml');
|
||||
|
||||
const ui = SwaggerUI({
|
||||
spec,
|
||||
dom_id: '#swagger',
|
||||
});
|
||||
|
||||
ui.initOAuth({
|
||||
appName: "Swagger UI Webpack Demo",
|
||||
// See https://demo.identityserver.io/ for configuration details.
|
||||
clientId: 'implicit'
|
||||
});
|
@ -0,0 +1,30 @@
|
||||
openapi: "3.0.0"
|
||||
info:
|
||||
version: "0.0.1"
|
||||
title: "Swagger UI Webpack Setup"
|
||||
description: "Demonstrates Swagger UI with Webpack including CSS and OAuth"
|
||||
servers:
|
||||
- url: "https://demo.identityserver.io/api"
|
||||
description: "Identity Server test API"
|
||||
components:
|
||||
securitySchemes:
|
||||
# See https://demo.identityserver.io/ for configuration details.
|
||||
identity_server_auth:
|
||||
type: oauth2
|
||||
flows:
|
||||
implicit:
|
||||
authorizationUrl: "https://demo.identityserver.io/connect/authorize"
|
||||
scopes:
|
||||
api: "api"
|
||||
security:
|
||||
- identity_server_auth:
|
||||
- api
|
||||
paths:
|
||||
/test:
|
||||
get:
|
||||
summary: "Runs a test request against the Identity Server demo API"
|
||||
responses:
|
||||
401:
|
||||
description: "Unauthorized"
|
||||
200:
|
||||
description: "OK"
|
@ -0,0 +1,52 @@
|
||||
const path = require('path');
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
||||
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
||||
|
||||
const outputPath = path.resolve(__dirname, 'dist');
|
||||
|
||||
module.exports = {
|
||||
mode: 'development',
|
||||
entry: {
|
||||
app: require.resolve('./src/index'),
|
||||
},
|
||||
resolve: {
|
||||
extensions: ['.ts', '.js'],
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.yaml$/,
|
||||
use: [
|
||||
{ loader: 'json-loader' },
|
||||
{ loader: 'yaml-loader', options:{ asJSON: true } }
|
||||
]
|
||||
},
|
||||
{
|
||||
test: /\.css$/,
|
||||
use: [
|
||||
{ loader: 'style-loader' },
|
||||
{ loader: 'css-loader' },
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
new CleanWebpackPlugin(),
|
||||
new CopyWebpackPlugin({patterns:[
|
||||
{
|
||||
// Copy the Swagger OAuth2 redirect file to the project root;
|
||||
// that file handles the OAuth2 redirect after authenticating the end-user.
|
||||
from: require.resolve('swagger-ui/dist/oauth2-redirect.html'),
|
||||
to: './'
|
||||
}
|
||||
]}),
|
||||
new HtmlWebpackPlugin({
|
||||
template: 'index.html'
|
||||
})
|
||||
],
|
||||
output: {
|
||||
filename: '[name].bundle.js',
|
||||
path: outputPath,
|
||||
}
|
||||
};
|
@ -0,0 +1,383 @@
|
||||
# Configuration
|
||||
|
||||
### How to configure
|
||||
|
||||
Swagger UI accepts configuration parameters in three locations.
|
||||
|
||||
From lowest to highest precedence:
|
||||
- configuration object passed as an argument to Swagger UI (`SwaggerUI({ ... })`)
|
||||
- configuration document fetched from a specified `configUrl`
|
||||
- configuration items passed as key/value pairs in the URL query string
|
||||
|
||||
### Parameters
|
||||
|
||||
Parameters with dots in their names are single strings used to organize subordinate parameters, and are not indicative of a nested structure.
|
||||
|
||||
For readability, parameters are grouped by category and sorted alphabetically.
|
||||
|
||||
Type notations are formatted like so:
|
||||
- `String=""` means a String type with a default value of `""`.
|
||||
- `String=["a"*, "b", "c", "d"]` means a String type that can be `a`, `b`, `c`, or `d`, with the `*` indicating that `a` is the default value.
|
||||
|
||||
##### Core
|
||||
|
||||
Parameter name | Docker variable | Description
|
||||
--- | --- | -----
|
||||
<a name="configUrl"></a>`configUrl` | `CONFIG_URL` | `String`. URL to fetch external configuration document from.
|
||||
<a name="dom_id"></a>`dom_id` | `DOM_ID` |`String`, **REQUIRED** if `domNode` is not provided. The ID of a DOM element inside which `SwaggerUI` will put its user interface.
|
||||
<a name="domNode"></a>`domNode` | _Unavailable_ | `Element`, **REQUIRED** if `dom_id` is not provided. The HTML DOM element inside which `SwaggerUI` will put its user interface. Overrides `dom_id`.
|
||||
<a name="spec"></a>`spec` | `SPEC` | `Object={}`. A JavaScript object describing the OpenAPI definition. When used, the `url` parameter will not be parsed. This is useful for testing manually-generated definitions without hosting them.
|
||||
<a name="url"></a>`url` | `URL` | `String`. The URL pointing to API definition (normally `swagger.json` or `swagger.yaml`). Will be ignored if `urls` or `spec` is used.
|
||||
<a name="urls"></a>`urls` | `URLS` | `Array`. An array of API definition objects (`[{url: "<url1>", name: "<name1>"},{url: "<url2>", name: "<name2>"}]`) used by Topbar plugin. When used and Topbar plugin is enabled, the `url` parameter will not be parsed. Names and URLs must be unique among all items in this array, since they're used as identifiers.
|
||||
<a name="urls.primaryName"></a>`urls.primaryName` | `URLS_PRIMARY_NAME` | `String`. When using `urls`, you can use this subparameter. If the value matches the name of a spec provided in `urls`, that spec will be displayed when Swagger UI loads, instead of defaulting to the first spec in `urls`.
|
||||
<a name="queryConfigEnabled"></a>`queryConfigEnabled` | `QUERY_CONFIG_ENABLED` | `Boolean=false`. Enables overriding configuration parameters via URL search params.
|
||||
|
||||
##### Plugin system
|
||||
|
||||
Read more about the plugin system in the [Customization documentation](/docs/customization/overview.md).
|
||||
|
||||
Parameter name | Docker variable | Description
|
||||
--- | --- | -----
|
||||
<a name="layout"></a>`layout` | _Unavailable_ | `String="BaseLayout"`. The name of a component available via the plugin system to use as the top-level layout for Swagger UI.
|
||||
<a name="plugins"></a>`plugins` | _Unavailable_ | `Array=[]`. An array of plugin functions to use in Swagger UI.
|
||||
<a name="presets"></a>`presets` | _Unavailable_ | `Array=[SwaggerUI.presets.ApisPreset]`. An array of presets to use in Swagger UI. Usually, you'll want to include `ApisPreset` if you use this option.
|
||||
|
||||
##### Display
|
||||
|
||||
<table role="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Parameter name</th>
|
||||
<th>Docker variable</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><a name="user-content-deeplinking"></a><code>deepLinking</code></td>
|
||||
<td><code>DEEP_LINKING</code></td>
|
||||
<td><code>Boolean=false</code>. If set to <code>true</code>, enables
|
||||
deep linking for tags and operations. See the <a
|
||||
href="/docs/usage/deep-linking.md">Deep Linking
|
||||
documentation</a> for more information.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a name="user-content-displayoperationid"></a><code>displayOperationId</code>
|
||||
</td>
|
||||
<td><code>DISPLAY_OPERATION_ID</code></td>
|
||||
<td><code>Boolean=false</code>. Controls the display of operationId in
|
||||
operations list. The default is <code>false</code>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a name="user-content-defaultmodelsexpanddepth"></a><code>defaultModelsExpandDepth</code>
|
||||
</td>
|
||||
<td><code>DEFAULT_MODELS_EXPAND_DEPTH</code></td>
|
||||
<td><code>Number=1</code>. The default expansion depth for models (set
|
||||
to -1 completely hide the models).
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a name="user-content-defaultmodelexpanddepth"></a><code>defaultModelExpandDepth</code>
|
||||
</td>
|
||||
<td><code>DEFAULT_MODEL_EXPAND_DEPTH</code></td>
|
||||
<td><code>Number=1</code>. The default expansion depth for the model on
|
||||
the model-example section.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a name="user-content-defaultmodelrendering"></a><code>defaultModelRendering</code>
|
||||
</td>
|
||||
<td><code>DEFAULT_MODEL_RENDERING</code></td>
|
||||
<td><code>String=["example"*, "model"]</code>. Controls how the model is
|
||||
shown when the API is first rendered. (The user can always switch
|
||||
the rendering for a given model by clicking the 'Model' and 'Example
|
||||
Value' links.)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a name="user-content-displayrequestduration"></a><code>displayRequestDuration</code>
|
||||
</td>
|
||||
<td><code>DISPLAY_REQUEST_DURATION</code></td>
|
||||
<td><code>Boolean=false</code>. Controls the display of the request
|
||||
duration (in milliseconds) for "Try it out" requests.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a name="user-content-docexpansion"></a><code>docExpansion</code>
|
||||
</td>
|
||||
<td><code>DOC_EXPANSION</code></td>
|
||||
<td><code>String=["list"*, "full", "none"]</code>. Controls the default
|
||||
expansion setting for the operations and tags. It can be 'list'
|
||||
(expands only the tags), 'full' (expands the tags and operations) or
|
||||
'none' (expands nothing).
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a name="user-content-filter"></a><code>filter</code></td>
|
||||
<td><code>FILTER</code></td>
|
||||
<td><code>Boolean=false OR String</code>. If set, enables filtering. The
|
||||
top bar will show an edit box that you can use to filter the tagged
|
||||
operations that are shown. Can be Boolean to enable or disable, or a
|
||||
string, in which case filtering will be enabled using that string as
|
||||
the filter expression. Filtering is case sensitive matching the
|
||||
filter expression anywhere inside the tag.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a name="user-content-maxdisplayedtags"></a><code>maxDisplayedTags</code>
|
||||
</td>
|
||||
<td><code>MAX_DISPLAYED_TAGS</code></td>
|
||||
<td><code>Number</code>. If set, limits the number of tagged operations
|
||||
displayed to at most this many. The default is to show all
|
||||
operations.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a name="user-content-operationssorter"></a><code>operationsSorter</code>
|
||||
</td>
|
||||
<td><em>Unavailable</em></td>
|
||||
<td><code>Function=(a => a)</code>. Apply a sort to the operation
|
||||
list of each API. It can be 'alpha' (sort by paths
|
||||
alphanumerically), 'method' (sort by HTTP method) or a function (see
|
||||
Array.prototype.sort() to know how sort function works). Default is
|
||||
the order returned by the server unchanged.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a name="user-content-showextensions"></a><code>showExtensions</code>
|
||||
</td>
|
||||
<td><code>SHOW_EXTENSIONS</code></td>
|
||||
<td><code>Boolean=false</code>. Controls the display of vendor extension
|
||||
(<code>x-</code>) fields and values for Operations, Parameters,
|
||||
Responses, and Schema.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a name="user-content-showcommonextensions"></a><code>showCommonExtensions</code>
|
||||
</td>
|
||||
<td><code>SHOW_COMMON_EXTENSIONS</code></td>
|
||||
<td><code>Boolean=false</code>. Controls the display of extensions
|
||||
(<code>pattern</code>, <code>maxLength</code>,
|
||||
<code>minLength</code>, <code>maximum</code>, <code>minimum</code>)
|
||||
fields and values for Parameters.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a name="user-content-tagsorter"></a><code>tagsSorter</code></td>
|
||||
<td><em>Unavailable</em></td>
|
||||
<td><code>Function=(a => a)</code>. Apply a sort to the tag list of
|
||||
each API. It can be 'alpha' (sort by paths alphanumerically) or a
|
||||
function (see <a
|
||||
href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort"
|
||||
rel="nofollow">Array.prototype.sort()</a> to learn how to
|
||||
write a sort function). Two tag name strings are passed to the
|
||||
sorter for each pass. Default is the order determined by Swagger UI.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a name="user-content-useunsafemarkdown"></a><code>useUnsafeMarkdown</code>
|
||||
</td>
|
||||
<td><code>USE_UNSAFE_MARKDOWN</code></td>
|
||||
<td><code>Boolean=false</code>. When enabled, sanitizer will leave
|
||||
<code>style</code>, <code>class</code> and <code>data-*</code>
|
||||
attributes untouched on all HTML Elements declared inside markdown
|
||||
strings. This parameter is <strong>Deprecated</strong> and will be
|
||||
removed in <code>4.0.0</code>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a name="user-content-oncomplete"></a><code>onComplete</code></td>
|
||||
<td><em>Unavailable</em></td>
|
||||
<td><code>Function=NOOP</code>. Provides a mechanism to be notified when
|
||||
Swagger UI has finished rendering a newly provided definition.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a name="user-content-syntaxhighlight"></a><code>syntaxHighlight</code>
|
||||
</td>
|
||||
<td><em>Unavailable</em></td>
|
||||
<td>Set to <code>false</code> to deactivate syntax highlighting of
|
||||
payloads and cURL command, can be otherwise an object with the
|
||||
<code>activated</code> and <code>theme</code> properties.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a name="user-content-syntaxhighlight.activated"></a><code>syntaxHighlight.activated</code>
|
||||
</td>
|
||||
<td><em>Unavailable</em></td>
|
||||
<td><code>Boolean=true</code>. Whether syntax highlighting should be
|
||||
activated or not.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a name="user-content-syntaxhighlight.theme"></a><code>syntaxHighlight.theme</code>
|
||||
</td>
|
||||
<td><em>Unavailable</em></td>
|
||||
<td><code>String=["agate"*, "arta", "monokai", "nord", "obsidian",
|
||||
"tomorrow-night", "idea"]</code>. <a
|
||||
href="https://highlightjs.org/static/demo/" rel="nofollow">Highlight.js</a>
|
||||
syntax coloring theme to use. (Only these 7 styles are available.)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a name="user-content-tryitoutenabled"></a><code>tryItOutEnabled</code>
|
||||
</td>
|
||||
<td><code>TRY_IT_OUT_ENABLED</code></td>
|
||||
<td><code>Boolean=false</code>. Controls whether the "Try it out"
|
||||
section should be enabled by default.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a name="user-content-requestsnippetsenabled"></a><code>requestSnippetsEnabled</code>
|
||||
</td>
|
||||
<td><em>Unavailable</em></td>
|
||||
<td><code>Boolean=false</code>. Enables the request snippet section.
|
||||
When disabled, the legacy curl snippet will be used.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a name="user-content-requestsnippets"></a><code>requestSnippets</code>
|
||||
</td>
|
||||
<td><em>Unavailable</em></td>
|
||||
<td>
|
||||
<pre lang="javascript">
|
||||
<code>Object={
|
||||
generators: {
|
||||
curl_bash: {
|
||||
title: "cURL (bash)",
|
||||
syntax: "bash"
|
||||
},
|
||||
curl_powershell: {
|
||||
title: "cURL (PowerShell)",
|
||||
syntax: "powershell"
|
||||
},
|
||||
curl_cmd: {
|
||||
title: "cURL (CMD)",
|
||||
syntax: "bash"
|
||||
},
|
||||
},
|
||||
defaultExpanded: true,
|
||||
languages: null,
|
||||
// e.g. only show curl bash = ["curl_bash"]
|
||||
}
|
||||
</code>
|
||||
</pre>
|
||||
This is the default configuration section for the
|
||||
requestSnippets plugin.
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
##### Network
|
||||
|
||||
Parameter name | Docker variable | Description
|
||||
--- | --- | -----
|
||||
<a name="oauth2RedirectUrl"></a>`oauth2RedirectUrl` | `OAUTH2_REDIRECT_URL` | `String`. OAuth redirect URL.
|
||||
<a name="requestInterceptor"></a>`requestInterceptor` | _Unavailable_ | `Function=(a => a)`. MUST be a function. Function to intercept remote definition, "Try it out", and OAuth 2.0 requests. Accepts one argument requestInterceptor(request) and must return the modified request, or a Promise that resolves to the modified request.
|
||||
<a name="request.curlOptions"></a>`request.curlOptions` | _Unavailable_ | `Array`. If set, MUST be an array of command line options available to the `curl` command. This can be set on the mutated request in the `requestInterceptor` function. For example `request.curlOptions = ["-g", "--limit-rate 20k"]`
|
||||
<a name="responseInterceptor"></a>`responseInterceptor` | _Unavailable_ | `Function=(a => a)`. MUST be a function. Function to intercept remote definition, "Try it out", and OAuth 2.0 responses. Accepts one argument responseInterceptor(response) and must return the modified response, or a Promise that resolves to the modified response.
|
||||
<a name="showMutatedRequest"></a>`showMutatedRequest` | `SHOW_MUTATED_REQUEST` | `Boolean=true`. If set to `true`, uses the mutated request returned from a requestInterceptor to produce the curl command in the UI, otherwise the request before the requestInterceptor was applied is used.
|
||||
<a name="supportedSubmitMethods"></a>`supportedSubmitMethods` | `SUPPORTED_SUBMIT_METHODS` | `Array=["get", "put", "post", "delete", "options", "head", "patch", "trace"]`. List of HTTP methods that have the "Try it out" feature enabled. An empty array disables "Try it out" for all operations. This does not filter the operations from the display.
|
||||
<a name="validatorUrl"></a>`validatorUrl` | `VALIDATOR_URL` | `String="https://validator.swagger.io/validator" OR null`. By default, Swagger UI attempts to validate specs against swagger.io's online validator. You can use this parameter to set a different validator URL, for example for locally deployed validators ([Validator Badge](https://github.com/swagger-api/validator-badge)). Setting it to either `none`, `127.0.0.1` or `localhost` will disable validation.
|
||||
<a name="withCredentials"></a>`withCredentials` | `WITH_CREDENTIALS` | `Boolean=false` If set to `true`, enables passing credentials, [as defined in the Fetch standard](https://fetch.spec.whatwg.org/#credentials), in CORS requests that are sent by the browser. Note that Swagger UI cannot currently set cookies cross-domain (see [swagger-js#1163](https://github.com/swagger-api/swagger-js/issues/1163)) - as a result, you will have to rely on browser-supplied cookies (which this setting enables sending) that Swagger UI cannot control.
|
||||
|
||||
##### Macros
|
||||
|
||||
Parameter name | Docker variable | Description
|
||||
--- | --- | -----
|
||||
<a name="modelPropertyMacro"></a>`modelPropertyMacro` | _Unavailable_ | `Function`. Function to set default values to each property in model. Accepts one argument modelPropertyMacro(property), property is immutable
|
||||
<a name="parameterMacro"></a>`parameterMacro` | _Unavailable_ | `Function`. Function to set default value to parameters. Accepts two arguments parameterMacro(operation, parameter). Operation and parameter are objects passed for context, both remain immutable
|
||||
|
||||
##### Authorization
|
||||
|
||||
Parameter name | Docker variable | Description
|
||||
--- | --- | -----
|
||||
<a name="persistAuthorization"></a>`persistAuthorization` | `PERSIST_AUTHORIZATION` | `Boolean=false`. If set to `true`, it persists authorization data and it would not be lost on browser close/refresh
|
||||
|
||||
### Instance methods
|
||||
|
||||
**💡 Take note! These are methods, not parameters**.
|
||||
|
||||
Method name | Docker variable | Description
|
||||
--- | --- | -----
|
||||
<a name="initOAuth"></a>`initOAuth` | [_See `oauth2.md`_](./oauth2.md) | `(configObj) => void`. Provide Swagger UI with information about your OAuth server - see the [OAuth 2.0 documentation](./oauth2.md) for more information.
|
||||
<a name="preauthorizeBasic"></a>`preauthorizeBasic` | _Unavailable_ | `(authDefinitionKey, username, password) => action`. Programmatically set values for a Basic authorization scheme.
|
||||
<a name="preauthorizeApiKey"></a>`preauthorizeApiKey` | _Unavailable_ | `(authDefinitionKey, apiKeyValue) => action`. Programmatically set values for an API key or Bearer authorization scheme. In case of OpenAPI 3.0 Bearer scheme, `apiKeyValue` must contain just the token itself without the `Bearer` prefix.
|
||||
|
||||
### Docker
|
||||
|
||||
If you're using the Docker image, you can also control most of these options with environment variables. Each parameter has its environment variable name noted, if available.
|
||||
|
||||
Below are the general guidelines for using the environment variable interface.
|
||||
|
||||
##### String variables
|
||||
|
||||
Set the value to whatever string you'd like, taking care to escape characters where necessary
|
||||
|
||||
Example:
|
||||
|
||||
```sh
|
||||
FILTER="myFilterValue"
|
||||
LAYOUT="BaseLayout"
|
||||
```
|
||||
|
||||
##### Boolean variables
|
||||
|
||||
Set the value to `true` or `false`.
|
||||
|
||||
Example:
|
||||
|
||||
```sh
|
||||
DISPLAY_OPERATION_ID="true"
|
||||
DEEP_LINKING="false"
|
||||
```
|
||||
|
||||
##### Number variables
|
||||
|
||||
Set the value to _`n`_, where _n_ is the number you'd like to provide.
|
||||
|
||||
Example:
|
||||
|
||||
```sh
|
||||
DEFAULT_MODELS_EXPAND_DEPTH="5"
|
||||
DEFAULT_MODEL_EXPAND_DEPTH="7"
|
||||
```
|
||||
|
||||
##### Array variables
|
||||
|
||||
Set the value to the literal array value you'd like, taking care to escape characters where necessary.
|
||||
|
||||
Example:
|
||||
|
||||
```sh
|
||||
SUPPORTED_SUBMIT_METHODS="[\"get\", \"post\"]"
|
||||
URLS="[ { url: \"https://petstore.swagger.io/v2/swagger.json\", name: \"Petstore\" } ]"
|
||||
```
|
||||
|
||||
##### Object variables
|
||||
|
||||
Set the value to the literal object value you'd like, taking care to escape characters where necessary.
|
||||
|
||||
Example:
|
||||
|
||||
```sh
|
||||
SPEC="{ \"openapi\": \"3.0.0\" }"
|
||||
```
|
||||
|
||||
### Docker-Compose
|
||||
|
||||
#### .env file example encoding
|
||||
```sh
|
||||
SUPPORTED_SUBMIT_METHODS=['get', 'post']
|
||||
URLS=[ { url: 'https://petstore.swagger.io/v2/swagger.json', name: 'Petstore' } ]
|
||||
```
|
@ -0,0 +1,60 @@
|
||||
# CORS
|
||||
|
||||
CORS is a technique to prevent websites from doing bad things with your personal data. Most browsers + JavaScript toolkits not only support CORS but enforce it, which has implications for your API server which supports Swagger.
|
||||
|
||||
You can read about CORS here: http://www.w3.org/TR/cors.
|
||||
|
||||
There are two cases where no action is needed for CORS support:
|
||||
|
||||
1. Swagger UI is hosted on the same server as the application itself (same host *and* port).
|
||||
2. The application is located behind a proxy that enables the required CORS headers. This may already be covered within your organization.
|
||||
|
||||
Otherwise, CORS support needs to be enabled for:
|
||||
|
||||
1. Your Swagger docs. For Swagger 2.0 it's the `swagger.json`/`swagger.yaml` and any externally `$ref`ed docs.
|
||||
2. For the `Try it now` button to work, CORS needs to be enabled on your API endpoints as well.
|
||||
|
||||
### Testing CORS Support
|
||||
|
||||
You can verify CORS support with one of three techniques:
|
||||
|
||||
- Curl your API and inspect the headers. For instance:
|
||||
|
||||
```bash
|
||||
$ curl -I "https://petstore.swagger.io/v2/swagger.json"
|
||||
HTTP/1.1 200 OK
|
||||
Date: Sat, 31 Jan 2015 23:05:44 GMT
|
||||
Access-Control-Allow-Origin: *
|
||||
Access-Control-Allow-Methods: GET, POST, DELETE, PUT, PATCH, OPTIONS
|
||||
Access-Control-Allow-Headers: Content-Type, api_key, Authorization
|
||||
Content-Type: application/json
|
||||
Content-Length: 0
|
||||
```
|
||||
|
||||
This tells us that the petstore resource listing supports OPTIONS, and the following headers: `Content-Type`, `api_key`, `Authorization`.
|
||||
|
||||
- Try Swagger UI from your file system and look at the debug console. If CORS is not enabled, you'll see something like this:
|
||||
|
||||
```
|
||||
XMLHttpRequest cannot load http://sad.server.com/v2/api-docs. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
|
||||
```
|
||||
|
||||
Swagger UI cannot easily show this error state.
|
||||
|
||||
- Use the https://www.test-cors.org website to verify CORS support. Keep in mind this will show a successful result even if `Access-Control-Allow-Headers` is not available, which is still required for Swagger UI to function properly.
|
||||
|
||||
### Enabling CORS
|
||||
|
||||
The method of enabling CORS depends on the server and/or framework you use to host your application. https://enable-cors.org provides information on how to enable CORS in some common web servers.
|
||||
|
||||
Other servers/frameworks may provide you information on how to enable it specifically in their use case.
|
||||
|
||||
### CORS and Header Parameters
|
||||
|
||||
Swagger UI lets you easily send headers as parameters to requests. The name of these headers *MUST* be supported in your CORS configuration as well. From our example above:
|
||||
|
||||
```
|
||||
Access-Control-Allow-Headers: Content-Type, api_key, Authorization
|
||||
```
|
||||
|
||||
Only headers with these names will be allowed to be sent by Swagger UI.
|
@ -0,0 +1,36 @@
|
||||
# `deepLinking` parameter
|
||||
|
||||
Swagger UI allows you to deeply link into tags and operations within a spec. When Swagger UI is provided a URL fragment at runtime, it will automatically expand and scroll to a specified tag or operation.
|
||||
|
||||
## Usage
|
||||
|
||||
👉🏼 Add `deepLinking: true` to your Swagger UI configuration to enable this functionality. This is demonstrated in [`dist/index.html`](https://github.com/swagger-api/swagger-ui/blob/master/dist/index.html).
|
||||
|
||||
When you expand a tag or operation, Swagger UI will automatically update its URL fragment with a deep link to the item.
|
||||
Conversely, when you collapse a tag or operation, Swagger UI will clear the URL fragment.
|
||||
|
||||
You can also right-click a tag name or operation path to copy a link to that tag or operation.
|
||||
|
||||
#### Fragment format
|
||||
|
||||
The fragment is formatted in one of two ways:
|
||||
|
||||
- `#/{tagName}`, to trigger the focus of a specific tag
|
||||
- `#/{tagName}/{operationId}`, to trigger the focus of a specific operation within a tag
|
||||
|
||||
`operationId` is the explicit operationId provided in the spec, if one exists.
|
||||
Otherwise, Swagger UI generates an implicit operationId by combining the operation's path and method, while escaping non-alphanumeric characters.
|
||||
|
||||
## FAQ
|
||||
|
||||
> I'm using Swagger UI in an application that needs control of the URL fragment. How do I disable deep-linking?
|
||||
|
||||
This functionality is disabled by default, but you can pass `deepLinking: false` into Swagger UI as a configuration item to be sure.
|
||||
|
||||
> Can I link to multiple tags or operations?
|
||||
|
||||
No, this is not supported.
|
||||
|
||||
> Can I collapse everything except the operation or tag I'm linking to?
|
||||
|
||||
Sure - use `docExpansion: none` to collapse all tags and operations. Your deep link will take precedence over the setting, so only the tag or operation you've specified will be expanded.
|
@ -0,0 +1,190 @@
|
||||
# Installation
|
||||
|
||||
## Distribution channels
|
||||
|
||||
### NPM Registry
|
||||
|
||||
We publish three modules to npm: **`swagger-ui`**, **`swagger-ui-dist`** and **`swagger-ui-react`**.
|
||||
|
||||
**`swagger-ui`** is meant for consumption by JavaScript web projects that include module bundlers,
|
||||
such as Webpack, Browserify, and Rollup. Its main file exports Swagger UI's main function,
|
||||
and the module also includes a namespaced stylesheet at `swagger-ui/dist/swagger-ui.css`. Here's an example:
|
||||
|
||||
```javascript
|
||||
import SwaggerUI from 'swagger-ui'
|
||||
// or use require if you prefer
|
||||
const SwaggerUI = require('swagger-ui')
|
||||
|
||||
SwaggerUI({
|
||||
dom_id: '#myDomId'
|
||||
})
|
||||
```
|
||||
|
||||
See the [Webpack Getting Started](../samples/webpack-getting-started) sample for details.
|
||||
|
||||
In contrast, **`swagger-ui-dist`** is meant for server-side projects that need assets to serve to clients. The module, when imported, includes an `absolutePath` helper function that returns the absolute filesystem path to where the `swagger-ui-dist` module is installed.
|
||||
|
||||
_Note: we suggest using `swagger-ui` when your tooling makes it possible, as `swagger-ui-dist`
|
||||
will result in more code going across the wire._
|
||||
|
||||
The module's contents mirror the `dist` folder you see in the Git repository. The most useful file is `swagger-ui-bundle.js`, which is a build of Swagger UI that includes all the code it needs to run in one file. The folder also has an `index.html` asset, to make it easy to serve Swagger UI like so:
|
||||
|
||||
```javascript
|
||||
const express = require('express')
|
||||
const pathToSwaggerUi = require('swagger-ui-dist').absolutePath()
|
||||
|
||||
const app = express()
|
||||
|
||||
app.use(express.static(pathToSwaggerUi))
|
||||
|
||||
app.listen(3000)
|
||||
```
|
||||
|
||||
The module also exports `SwaggerUIBundle` and `SwaggerUIStandalonePreset`, so
|
||||
if you're in a JavaScript project that can't handle a traditional npm module,
|
||||
you could do something like this:
|
||||
|
||||
```js
|
||||
var SwaggerUIBundle = require('swagger-ui-dist').SwaggerUIBundle
|
||||
|
||||
const ui = SwaggerUIBundle({
|
||||
url: "https://petstore.swagger.io/v2/swagger.json",
|
||||
dom_id: '#swagger-ui',
|
||||
presets: [
|
||||
SwaggerUIBundle.presets.apis,
|
||||
SwaggerUIBundle.SwaggerUIStandalonePreset
|
||||
],
|
||||
layout: "StandaloneLayout"
|
||||
})
|
||||
```
|
||||
|
||||
`SwaggerUIBundle` is equivalent to `SwaggerUI`.
|
||||
|
||||
### Docker
|
||||
|
||||
You can pull a pre-built docker image of the swagger-ui directly from Docker Hub:
|
||||
|
||||
```sh
|
||||
docker pull swaggerapi/swagger-ui
|
||||
docker run -p 80:8080 swaggerapi/swagger-ui
|
||||
```
|
||||
|
||||
Will start nginx with Swagger UI on port 80.
|
||||
|
||||
Or you can provide your own swagger.json on your host
|
||||
|
||||
```sh
|
||||
docker run -p 80:8080 -e SWAGGER_JSON=/foo/swagger.json -v /bar:/foo swaggerapi/swagger-ui
|
||||
```
|
||||
|
||||
You can also provide a URL to a swagger.json on an external host:
|
||||
|
||||
```sh
|
||||
docker run -p 80:8080 -e SWAGGER_JSON_URL=https://petstore3.swagger.io/api/v3/openapi.json swaggerapi/swagger-ui
|
||||
```
|
||||
|
||||
The base URL of the web application can be changed by specifying the `BASE_URL` environment variable:
|
||||
|
||||
```sh
|
||||
docker run -p 80:8080 -e BASE_URL=/swagger -e SWAGGER_JSON=/foo/swagger.json -v /bar:/foo swaggerapi/swagger-ui
|
||||
```
|
||||
|
||||
This will serve Swagger UI at `/swagger` instead of `/`.
|
||||
|
||||
You can specify a different port via `PORT` variable for accessing the application, default is `8080`.
|
||||
|
||||
```sh
|
||||
docker run -p 80:80 -e PORT=80 swaggerapi/swagger-ui
|
||||
```
|
||||
|
||||
You can specify an IPv6 port via `PORT_IPV6` variable. By default, IPv6 port is not set.
|
||||
|
||||
```sh
|
||||
docker run -p 80:80 -e PORT_IPV6=8080 swaggerapi/swagger-ui
|
||||
```
|
||||
|
||||
You can allow/disallow [embedding](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options) via `EMBEDDING` variable. By default, embedding is disabled.
|
||||
|
||||
```sh
|
||||
docker run -p 80:80 -e EMBEDDING=true swaggerapi/swagger-ui
|
||||
```
|
||||
|
||||
For more information on controlling Swagger UI through the Docker image, see the Docker section of the [Configuration documentation](configuration.md#docker).
|
||||
|
||||
### unpkg
|
||||
|
||||
You can embed Swagger UI's code directly in your HTML by using [unpkg's](https://unpkg.com/) interface:
|
||||
|
||||
```html
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="description" content="SwaggerUI" />
|
||||
<title>SwaggerUI</title>
|
||||
<link rel="stylesheet" href="https://unpkg.com/swagger-ui-dist@5.11.0/swagger-ui.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="swagger-ui"></div>
|
||||
<script src="https://unpkg.com/swagger-ui-dist@5.11.0/swagger-ui-bundle.js" crossorigin></script>
|
||||
<script>
|
||||
window.onload = () => {
|
||||
window.ui = SwaggerUIBundle({
|
||||
url: 'https://petstore3.swagger.io/api/v3/openapi.json',
|
||||
dom_id: '#swagger-ui',
|
||||
});
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
Using `StandalonePreset` will render `TopBar` and `ValidatorBadge` as well.
|
||||
|
||||
```html
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="description" content="SwaggerUI" />
|
||||
<title>SwaggerUI</title>
|
||||
<link rel="stylesheet" href="https://unpkg.com/swagger-ui-dist@5.11.0/swagger-ui.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="swagger-ui"></div>
|
||||
<script src="https://unpkg.com/swagger-ui-dist@5.11.0/swagger-ui-bundle.js" crossorigin></script>
|
||||
<script src="https://unpkg.com/swagger-ui-dist@5.11.0/swagger-ui-standalone-preset.js" crossorigin></script>
|
||||
<script>
|
||||
window.onload = () => {
|
||||
window.ui = SwaggerUIBundle({
|
||||
url: 'https://petstore3.swagger.io/api/v3/openapi.json',
|
||||
dom_id: '#swagger-ui',
|
||||
presets: [
|
||||
SwaggerUIBundle.presets.apis,
|
||||
SwaggerUIStandalonePreset
|
||||
],
|
||||
layout: "StandaloneLayout",
|
||||
});
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
See [unpkg's main page](https://unpkg.com/) for more information on how to use unpkg.
|
||||
|
||||
### Static files without HTTP or HTML
|
||||
|
||||
Once swagger-ui has successfully generated the `/dist` directory, you can copy this to your own file system and host from there.
|
||||
|
||||
## Plain old HTML/CSS/JS (Standalone)
|
||||
|
||||
The folder `/dist` includes all the HTML, CSS and JS files needed to run SwaggerUI on a static website or CMS, without requiring NPM.
|
||||
|
||||
1. Download the [latest release](https://github.com/swagger-api/swagger-ui/releases/latest).
|
||||
1. Copy the contents of the `/dist` folder to your server.
|
||||
1. Open `swagger-initializer.js` in your text editor and replace "https://petstore.swagger.io/v2/swagger.json" with the URL for your OpenAPI 3.0 spec.
|
||||
|
||||
|
@ -0,0 +1,38 @@
|
||||
# Limitations
|
||||
|
||||
### Forbidden header names
|
||||
|
||||
Some header names cannot be controlled by web applications, due to security
|
||||
features built into web browsers.
|
||||
|
||||
Forbidden headers include:
|
||||
|
||||
> - Accept-Charset
|
||||
> - Accept-Encoding
|
||||
> - Access-Control-Request-Headers
|
||||
> - Access-Control-Request-Method
|
||||
> - Connection
|
||||
> - Content-Length
|
||||
> - Cookie
|
||||
> - Cookie2
|
||||
> - Date
|
||||
> - DNT
|
||||
> - Expect
|
||||
> - Host
|
||||
> - Keep-Alive
|
||||
> - Origin
|
||||
> - Proxy-*
|
||||
> - Sec-*
|
||||
> - Referer
|
||||
> - TE
|
||||
> - Trailer
|
||||
> - Transfer-Encoding
|
||||
> - Upgrade
|
||||
> - Via
|
||||
>
|
||||
> _[Forbidden header names (developer.mozilla.org)](https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name)_
|
||||
|
||||
The biggest impact of this is that OpenAPI 3.0 Cookie parameters cannot be
|
||||
controlled when running Swagger UI in a browser.
|
||||
|
||||
For more context, see [#3956](https://github.com/swagger-api/swagger-ui/issues/3956).
|
@ -0,0 +1,31 @@
|
||||
# OAuth 2.0 configuration
|
||||
You can configure OAuth 2.0 authorization by calling the `initOAuth` method.
|
||||
|
||||
Property name | Docker variable | Description
|
||||
--- | --- | ------
|
||||
clientId | `OAUTH_CLIENT_ID` | Default clientId. MUST be a string
|
||||
clientSecret | `OAUTH_CLIENT_SECRET` | **🚨 Never use this parameter in your production environment. It exposes crucial security information. This feature is intended for dev/test environments only. 🚨** <br>Default clientSecret. MUST be a string
|
||||
realm | `OAUTH_REALM` |realm query parameter (for oauth1) added to `authorizationUrl` and `tokenUrl`. MUST be a string
|
||||
appName | `OAUTH_APP_NAME` |application name, displayed in authorization popup. MUST be a string
|
||||
scopeSeparator | `OAUTH_SCOPE_SEPARATOR` |scope separator for passing scopes, encoded before calling, default value is a space (encoded value `%20`). MUST be a string
|
||||
scopes | `OAUTH_SCOPES` |string array or scope separator (i.e. space) separated string of initially selected oauth scopes, default is empty array
|
||||
additionalQueryStringParams | `OAUTH_ADDITIONAL_PARAMS` |Additional query parameters added to `authorizationUrl` and `tokenUrl`. MUST be an object
|
||||
useBasicAuthenticationWithAccessCodeGrant | `OAUTH_USE_BASIC_AUTH` |Only activated for the `accessCode` flow. During the `authorization_code` request to the `tokenUrl`, pass the [Client Password](https://tools.ietf.org/html/rfc6749#section-2.3.1) using the HTTP Basic Authentication scheme (`Authorization` header with `Basic base64encode(client_id + client_secret)`). The default is `false`
|
||||
usePkceWithAuthorizationCodeGrant | `OAUTH_USE_PKCE` | Only applies to `Authorization Code` flows. [Proof Key for Code Exchange](https://tools.ietf.org/html/rfc7636) brings enhanced security for OAuth public clients. The default is `false` <br/><br/>_Note:_ This option does not hide the client secret input because [neither PKCE nor client secrets are replacements for each other](https://oauth.net/2/pkce/).
|
||||
|
||||
```javascript
|
||||
const ui = SwaggerUI({...})
|
||||
|
||||
// Method can be called in any place after calling constructor SwaggerUIBundle
|
||||
ui.initOAuth({
|
||||
clientId: "your-client-id",
|
||||
clientSecret: "your-client-secret-if-required",
|
||||
realm: "your-realms",
|
||||
appName: "your-app-name",
|
||||
scopeSeparator: " ",
|
||||
scopes: "openid profile",
|
||||
additionalQueryStringParams: {test: "hello"},
|
||||
useBasicAuthenticationWithAccessCodeGrant: true,
|
||||
usePkceWithAuthorizationCodeGrant: true
|
||||
})
|
||||
```
|
@ -0,0 +1,54 @@
|
||||
# Detecting your Swagger UI version
|
||||
|
||||
At times, you're going to need to know which version of Swagger UI you use.
|
||||
|
||||
The first step would be to detect which major version you currently use, as the method of detecting the version has changed. If your Swagger UI has been heavily modified and you cannot detect from the look and feel which major version you use, you'd have to try both methods to get the exact version.
|
||||
|
||||
To help you visually detect which version you're using, we've included supporting images.
|
||||
|
||||
|
||||
# Swagger UI 3.x
|
||||
|
||||

|
||||
|
||||
Some distinct identifiers to Swagger UI 3.x:
|
||||
- The API version appears as a badge next to its title.
|
||||
- If there are schemes or authorizations, they'd appear in a bar above the operations.
|
||||
- Try it out functionality is not enabled by default.
|
||||
- All the response codes in the operations appear at after the parameters.
|
||||
- There's a models section after the operations.
|
||||
|
||||
If you've determined this is the version you have, to find the exact version:
|
||||
- Open your browser's web console (changes between browsers)
|
||||
- Type `JSON.stringify(versions)` in the console and execute the call.
|
||||
- The result should look similar to `swaggerUi : Object { version: "3.1.6", gitRevision: "g786cd47", gitDirty: true, … }`.
|
||||
- The version taken from that example would be `3.1.6`.
|
||||
|
||||
Note: This functionality was added in 3.0.8. If you're unable to execute it, you're likely to use an older version, and in that case the first step would be to upgrade.
|
||||
|
||||
|
||||
# Swagger UI 2.x and under
|
||||
|
||||

|
||||
|
||||
Some distinct identifiers to Swagger UI 2.x:
|
||||
- The API version appears at the bottom of the page.
|
||||
- Schemes are not rendered.
|
||||
- Authorization, if rendered, will appear next to the navigation bar.
|
||||
- Try it out functionality is enabled by default.
|
||||
- The successful response code would appear above the parameters, the rest below them.
|
||||
- There's no models section after the operations.
|
||||
|
||||
If you've determined this is the version you have, to find the exact version:
|
||||
- Navigate to the sources of the UI. Either on your disk or via the view page source functionality in your browser.
|
||||
- Find an open the `swagger-ui.js`
|
||||
- At the top of the page, there would be a comment containing the exact version of Swagger UI. This example shows version `2.2.9`:
|
||||
|
||||
```
|
||||
/**
|
||||
* swagger-ui - Swagger UI is a dependency-free collection of HTML, JavaScript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API
|
||||
* @version v2.2.9
|
||||
* @link https://swagger.io
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
```
|
@ -0,0 +1,195 @@
|
||||
# `swagger-ui-react`
|
||||
|
||||
[](http://badge.fury.io/js/swagger-ui-react)
|
||||
|
||||
`swagger-ui-react` is a flavor of Swagger UI suitable for use in React applications.
|
||||
|
||||
It has a few differences from the main version of Swagger UI:
|
||||
* Declares `react` and `react-dom` as peerDependencies instead of production dependencies
|
||||
* Exports a component instead of a constructor function
|
||||
|
||||
Versions of this module mirror the version of Swagger UI included in the distribution.
|
||||
|
||||
## Quick start
|
||||
|
||||
Install `swagger-ui-react`:
|
||||
|
||||
```
|
||||
$ npm i --save swagger-ui-react
|
||||
```
|
||||
|
||||
Use it in your React application:
|
||||
|
||||
```js
|
||||
import SwaggerUI from "swagger-ui-react"
|
||||
import "swagger-ui-react/swagger-ui.css"
|
||||
|
||||
export default App = () => <SwaggerUI url="https://petstore.swagger.io/v2/swagger.json" />
|
||||
```
|
||||
|
||||
## Props
|
||||
|
||||
These props map to [Swagger UI configuration options](https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/configuration.md) of the same name.
|
||||
|
||||
#### `spec`: PropTypes.object
|
||||
|
||||
An OpenAPI document represented as a JavaScript object, JSON string, or YAML string for Swagger UI to display.
|
||||
|
||||
⚠️ Don't use this in conjunction with `url` - unpredictable behavior may occur.
|
||||
|
||||
#### `url`: PropTypes.string
|
||||
|
||||
Remote URL to an OpenAPI document that Swagger UI will fetch, parse, and display.
|
||||
|
||||
⚠️ Don't use this in conjunction with `spec` - unpredictable behavior may occur.
|
||||
|
||||
#### `layout`: PropTypes.string
|
||||
|
||||
The name of a component available via the plugin system to use as the top-level layout for Swagger UI. The default value is `BaseLayout`.
|
||||
|
||||
⚠️ This prop is currently only applied once, on mount. Changes to this prop's value will not be propagated to the underlying Swagger UI instance. A future version of this module will remove this limitation, and the change will not be considered a breaking change.
|
||||
|
||||
#### `onComplete`: PropTypes.func
|
||||
|
||||
> `(system) => void`
|
||||
|
||||
A callback function that is triggered when Swagger-UI finishes rendering an OpenAPI document.
|
||||
|
||||
Swagger UI's `system` object is passed as an argument.
|
||||
|
||||
#### `requestInterceptor`: PropTypes.func
|
||||
|
||||
> `req => req` or `req => Promise<req>`.
|
||||
|
||||
A function that accepts a request object, and returns either a request object
|
||||
or a Promise that resolves to a request object.
|
||||
|
||||
#### `responseInterceptor`: PropTypes.func
|
||||
|
||||
> `res => res` or `res => Promise<res>`.
|
||||
|
||||
A function that accepts a response object, and returns either a response object
|
||||
or a Promise that resolves to a response object.
|
||||
|
||||
#### `docExpansion`: PropTypes.oneOf(['list', 'full', 'none'])
|
||||
|
||||
Controls the default expansion setting for the operations and tags. It can be 'list' (expands only the tags), 'full' (expands the tags and operations) or 'none' (expands nothing). The default value is 'list'.
|
||||
|
||||
⚠️ This prop is currently only applied once, on mount. Changes to this prop's value will not be propagated to the underlying Swagger UI instance. A future version of this module will remove this limitation, and the change will not be considered a breaking change.
|
||||
|
||||
#### `defaultModelExpandDepth`: PropTypes.number
|
||||
|
||||
The default expansion depth for models (set to -1 completely hide the models).
|
||||
|
||||
⚠️ This prop is currently only applied once, on mount. Changes to this prop's value will not be propagated to the underlying Swagger UI instance. A future version of this module will remove this limitation, and the change will not be considered a breaking change.
|
||||
|
||||
#### `defaultModelRendering`: PropTypes.oneOf(["example", "model"])
|
||||
|
||||
Controls how the model is shown when the API is first rendered. (The user can always switch the rendering for a given model by clicking the 'Model' and 'Example Value' links.) The default value is 'example'.
|
||||
|
||||
⚠️ This prop is currently only applied once, on mount. Changes to this prop's value will not be propagated to the underlying Swagger UI instance. A future version of this module will remove this limitation, and the change will not be considered a breaking change.
|
||||
|
||||
|
||||
#### `displayOperationId`: PropTypes.bool
|
||||
|
||||
Controls the display of operationId in operations list. The default is false.
|
||||
|
||||
⚠️ This prop is currently only applied once, on mount. Changes to this prop's value will not be propagated to the underlying Swagger UI instance. A future version of this module will remove this limitation, and the change will not be considered a breaking change.
|
||||
|
||||
#### `plugins`: PropTypes.arrayOf(PropTypes.object),
|
||||
|
||||
An array of objects that augment and modify Swagger UI's functionality. See Swagger UI's [Plugin API](https://github.com/swagger-api/swagger-ui/blob/master/docs/customization/plugin-api.md) for more details.
|
||||
|
||||
⚠️ This prop is currently only applied once, on mount. Changes to this prop's value will not be propagated to the underlying Swagger UI instance. A future version of this module will remove this limitation, and the change will not be considered a breaking change.
|
||||
|
||||
#### `supportedSubmitMethods`: PropTypes.arrayOf(PropTypes.oneOf(['get', 'put', 'post', 'delete', 'options', 'head', 'patch', 'trace']))
|
||||
|
||||
HTTP methods that have the Try it out feature enabled. An empty array disables Try it out for all operations. This does not filter the operations from the display.
|
||||
|
||||
⚠️ This prop is currently only applied once, on mount. Changes to this prop's value will not be propagated to the underlying Swagger UI instance. A future version of this module will remove this limitation, and the change will not be considered a breaking change.
|
||||
|
||||
#### `showExtensions`: PropTypes.bool
|
||||
|
||||
Controls the display of vendor extension (`x-`) fields and values for Operations, Parameters, Responses, and Schema.
|
||||
|
||||
⚠️ This prop is currently only applied once, on mount. Changes to this prop's value will not be propagated to the underlying Swagger UI instance. A future version of this module will remove this limitation, and the change will not be considered a breaking change.
|
||||
|
||||
#### `showCommonExtensions`: PropTypes.bool
|
||||
|
||||
Controls the display of extensions (pattern, maxLength, minLength, maximum, minimum) fields and values for Parameters.
|
||||
|
||||
⚠️ This prop is currently only applied once, on mount. Changes to this prop's value will not be propagated to the underlying Swagger UI instance. A future version of this module will remove this limitation, and the change will not be considered a breaking change.
|
||||
|
||||
#### `showMutatedRequest`: PropTypes.bool
|
||||
|
||||
If set to `true`, uses the mutated request returned from a requestInterceptor to produce the curl command in the UI, otherwise the request before the requestInterceptor was applied is used.
|
||||
|
||||
⚠️ This prop is currently only applied once, on mount. Changes to this prop's value will not be propagated to the underlying Swagger UI instance. A future version of this module will remove this limitation, and the change will not be considered a breaking change.
|
||||
|
||||
#### `presets`: PropTypes.arrayOf(PropTypes.func),
|
||||
|
||||
An array of functions that augment and modify Swagger UI's functionality. See Swagger UI's [Plugin API](https://github.com/swagger-api/swagger-ui/blob/master/docs/customization/plugin-api.md) for more details.
|
||||
|
||||
⚠️ This prop is currently only applied once, on mount. Changes to this prop's value will not be propagated to the underlying Swagger UI instance. A future version of this module will remove this limitation, and the change will not be considered a breaking change.
|
||||
|
||||
#### `tryItOutEnabled`: PropTypes.bool
|
||||
|
||||
Controls whether the "Try it out" section should start enabled. The default is false.
|
||||
|
||||
⚠️ This prop is currently only applied once, on mount. Changes to this prop's value will not be propagated to the underlying Swagger UI instance. A future version of this module will remove this limitation, and the change will not be considered a breaking change.
|
||||
|
||||
#### `displayRequestDuration`: PropTypes.bool
|
||||
|
||||
Controls the display of the request duration (in milliseconds) for "Try it out" requests. The default is false.
|
||||
|
||||
#### `filter`: PropTypes.oneOfType([PropTypes.string, PropTypes.bool])
|
||||
|
||||
If set, enables filtering. The top bar will show an edit box that you can use to filter the tagged operations that are shown. Can be Boolean to enable or disable, or a string, in which case filtering will be enabled using that string as the filter expression. Filtering is case sensitive matching the filter expression anywhere inside the tag. See Swagger UI's [Plug Points](https://github.com/swagger-api/swagger-ui/blob/master/docs/customization/plug-points.md#fnopsfilter) to customize the filtering behavior.
|
||||
|
||||
#### `requestSnippetsEnabled`: PropTypes.bool,
|
||||
|
||||
Enables the request snippet section. When disabled, the legacy curl snippet will be used. The default is false.
|
||||
|
||||
⚠️ This prop is currently only applied once, on mount. Changes to this prop's value will not be propagated to the underlying Swagger UI instance. A future version of this module will remove this limitation, and the change will not be considered a breaking change.
|
||||
|
||||
#### `requestSnippets`: PropTypes.object,
|
||||
|
||||
Configures the request snippet core plugin. See Swagger UI's [Display Configuration](https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/configuration.md#display) for more details.
|
||||
|
||||
⚠️ This prop is currently only applied once, on mount. Changes to this prop's value will not be propagated to the underlying Swagger UI instance. A future version of this module will remove this limitation, and the change will not be considered a breaking change.
|
||||
|
||||
#### `persistAuthorization`: PropTypes.bool
|
||||
|
||||
If set, it persists authorization data and it would not be lost on browser close/refresh. The default is false.
|
||||
|
||||
⚠️ This prop is currently only applied once, on mount. Changes to this prop's value will not be propagated to the underlying Swagger UI instance. A future version of this module will remove this limitation, and the change will not be considered a breaking change.
|
||||
|
||||
#### `withCredentials`: PropTypes.bool
|
||||
|
||||
If set to `true`, enables passing credentials, [as defined in the Fetch standard](https://fetch.spec.whatwg.org/#credentials), in CORS requests that are sent by the browser. Note that Swagger UI cannot currently set cookies cross-domain (see [swagger-js#1163](https://github.com/swagger-api/swagger-js/issues/1163)) - as a result, you will have to rely on browser-supplied cookies (which this setting enables sending) that Swagger UI cannot control.
|
||||
|
||||
⚠️ This prop is currently only applied once, on mount. Changes to this prop's value will not be propagated to the underlying Swagger UI instance. A future version of this module will remove this limitation, and the change will not be considered a breaking change.
|
||||
|
||||
#### `oauth2RedirectUrl`: PropTypes.string
|
||||
|
||||
Redirect url given as parameter to the oauth2 provider. Default the url refers to oauth2-redirect.html at the same path as the Swagger UI is available.
|
||||
|
||||
⚠️ This prop is currently only applied once, on mount. Changes to this prop's value will not be propagated to the underlying Swagger UI instance. A future version of this module will remove this limitation, and the change will not be considered a breaking change.
|
||||
|
||||
|
||||
## Limitations
|
||||
|
||||
* Not all configuration bindings are available.
|
||||
* Some props are only applied on mount, and cannot be updated reliably.
|
||||
* OAuth redirection handling is not supported.
|
||||
* Topbar/Standalone mode is not supported.
|
||||
|
||||
We intend to address these limitations based on user demand, so please open an issue or pull request if you have a specific request.
|
||||
|
||||
## Notes
|
||||
|
||||
* The `package.json` in the same folder as this README is _not_ the manifest that should be used for releases - another manifest is generated at build-time and can be found in `./dist/`.
|
||||
|
||||
---
|
||||
|
||||
For anything else, check the [Swagger-UI](https://github.com/swagger-api/swagger-ui) repository.
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user