Before using this GitHub Action, you must create a free account with Hey API and generate a project API key.
Create a new GitHub workflow or add an upload step to an existing workflow inside your API codebase.
name: Upload OpenAPI Specification
on:
push:
branches:
- main
pull_request:
jobs:
upload-openapi-spec:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Upload OpenAPI spec
uses: hey-api/upload-openapi-spec@v1.3.0
with:
path-to-file: path/to/openapi.json
tags: optional,custom,tags
env:
API_KEY: ${{ secrets.HEY_API_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
The example above will upload your OpenAPI specification to Hey API on every
pull request and push to the main
branch.
To successfully upload an OpenAPI specification, you need to provide the
following inputs (see with
in the example above)
A relative path to your OpenAPI file within the repository. Note that you might need an additional step in your GitHub workflow to generate this file (see FastAPI example).
A comma-separated string value representing any custom tags you wish to add to your OpenAPI specification.
In addition to the required path-to-file
input, you must provide the following
environment variables.
This is the project API key you obtained from Hey API.
Note: Personal API keys can't be used to upload specifications.
This variable will be available inside your workflow by default. It's used to fetch information about your repository, i.e. default branch.
Please follow the integrations guide on our website for the next steps.