Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/legion2/swagger-ui-action
Generate Swagger UI in a GitHub Actions workflow
https://github.com/legion2/swagger-ui-action
actions documentation-tool github-page openapi swagger-ui workflow
Last synced: about 14 hours ago
JSON representation
Generate Swagger UI in a GitHub Actions workflow
- Host: GitHub
- URL: https://github.com/legion2/swagger-ui-action
- Owner: Legion2
- License: mit
- Created: 2020-08-21T22:34:29.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-10-01T20:17:06.000Z (about 1 month ago)
- Last Synced: 2024-11-04T13:38:55.604Z (10 days ago)
- Topics: actions, documentation-tool, github-page, openapi, swagger-ui, workflow
- Language: TypeScript
- Homepage:
- Size: 2.69 MB
- Stars: 50
- Watchers: 2
- Forks: 6
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Swagger UI Action [![build-test](https://github.com/Legion2/swagger-ui-action/workflows/build-test/badge.svg)](https://github.com/Legion2/swagger-ui-action/actions?query=workflow%3Abuild-test+branch%3Amain)
Generate Swagger UI static html files and configuration to be deployed to GitHub Pages.> This action only works on linux runners.
## How to Use
This Action supports four different configuration modes:
* `spec-file`: File path to local OpenAPI or Swagger specification document
* `spec-url`: URL of an OpenAPI or Swagger specification document
* `swagger-config-file`: File path to local swagger configuration file
* `swagger-config-url`: URL of a swagger configuration fileUse `spec-file` or `spec-url` when you have an OpenAPI or Swagger specification document and want a basic Swagger UI generated for it.
If you want to customize the created Swagger UI, you should use the `swagger-config-file` or the `swagger-config-url` configuration modes.
For information about the advanced swagger-config see the [Swagger UI Configuration documentation](https://swagger.io/docs/open-source-tools/swagger-ui/usage/configuration/).Note that, if `swagger-config-file` or `swagger-config-url` are used, no files specified in the `swagger-config.yaml` are copied by this action.
In this case, it is your responsibility to copy required files such as the OpenAPI document where you need them (output directory).The output directory of the generated Swagger UI must be set with the `output` argument of the Action.
Optionally the Swagger UI version can be set with the `version` input, it accepts semver ranges.The `GITHUB_TOKEN` secret must be provided to the action. It is used to query the Github api and download the release files of Swagger UI.
### Example
This Action only generates the Swagger UI.
For example, to deploy it to GitHub Pages another Action is required.Example steps from a workflow to generate and deploy Swagger UI to GitHub Pages:
```yaml
- name: Generate Swagger UI
uses: Legion2/swagger-ui-action@v1
with:
output: swagger-ui
spec-file: openapi.json
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: swagger-ui
```For a full example have a look at [this workflow file](https://github.com/Legion2/open-cue-service/blob/master/.github/workflows/pages.yml).
## Development
The Action runs from GitHub this repo, so the packed dist folder must be added to git.
Release a new version:
```bash
$ npm run package
$ git commit -a -m "distribution"
$ npm version major/minor/patch
$ git push
$ git tag -fa v1 -m "Update v1 tag"
$ git push origin v1 --force
```Then create a release on GitHub.
[versioning documentation](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md)