Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
book-open

GitHub Action

Stainless — Upload OpenAPI specification

v0.2.1

Stainless — Upload OpenAPI specification

book-open

Stainless — Upload OpenAPI specification

Upload your OpenAPI spec to update your Stainless SDKs (and, if configured, add example snippets to your API docs)

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Stainless — Upload OpenAPI specification

uses: stainless-api/[email protected]

Learn more about this action in stainless-api/upload-openapi-spec-action

Choose a version

GitHub Action: upload your OpenAPI spec to Stainless

stainless-api/upload-openapi-spec

lint build

A GitHub action for pushing your OpenAPI spec to Stainless to trigger regeneration of your SDKs.

Note that there is currently a manual step in between this action and automatic creation of your PR's, and more manual steps before they are merged and released.

If your account is configured to do so, this action can also output a copy of your OpenAPI spec decorated with sample code snippets, so that your API reference documentation can show examples of making each request with the user's chosen SDK (e.g., show client.items.list() instead of curl https://api.my-company.com/items).

Example usage

First, obtain an API Key from Stainless, and add it to your GitHub actions secrets as STAINLESS_API_KEY:

gh secret set STAINLESS_API_KEY

Then, add a new workflow file, or add the action to an existing workflow:

name: Upload OpenAPI spec to Stainless

on:
  push:
    branches: [main]

jobs:
  stainless:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: stainless-api/upload-openapi-spec@main
        with:
          stainless_api_key: ${{ secrets.STAINLESS_API_KEY }}
          input_path: "path/to/my-company-openapi.json"

Usage with ReadMe for docs with example snippets

If you use ReadMe's OpenAPI support for your API reference documentation, ask your contact at Stainless to configure sample code decoration for ReadMe, and then:

name: Upload OpenAPI spec to Stainless and ReadMe

on:
  push:
    branches: [main]

jobs:
  stainless:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: stainless-api/upload-openapi-spec@main
        with:
          stainless_api_key: ${{ secrets.STAINLESS_API_KEY }}
          input_path: "path/to/my-company-openapi.json"
          output_path: "path/to/my-company-openapi.documented.json"
      - uses: readmeio/rdme
        with:
          rdme: openapi "path/to/my-company-openapi.documented.json" --key=${{ secrets.README_TOKEN }} --id=${{ secrets.README_DEFINITION_ID }}

This assumes the following secrets have been uploaded to your Github Actions Secrets:

  • secrets.STAINLESS_API_KEY: Your Stainless API key.
  • secrets.README_TOKEN: Your API token for readme.com. Only sent to ReadMe's servers.
  • secrets.README_DEFINITION_ID: According to ReadMe's documentation, this can be obtained by "clicking edit on the API definition on your project API definitions page". Only sent to ReadMe's servers.