Automate OpenAPI updates
Automating updates
Stainless aims to make every part of shipping SDKs as painless as possible for developers. Here's how code flows from your repository to your end users.
SDK previews
SDK previews let you see how changes to your OpenAPI spec and Stainless config will affect your SDKs. You can use SDK previews if:
-
You store your OpenAPI spec in a GitHub repository.
-
All updates to your OpenAPI spec are made via pull requests.
After setting up SDK previews, pull requests to your GitHub repository that update the OpenAPI spec will build your SDKs, and make a comment on the pull request with the results.
The comment shows what commit message will be used when your change is merged; you can edit this comment to change the commit message. If your change adds new diagnostics, causes a merge conflict, or causes a fatal error, the comment will also say this. For certain languages, it will also have instructions for installing your SDK so you can try it out locally.
For setup instructions and more details, see the Build Stainless SDKs GitHub action.
Push updates
While we recommend setting up SDK previews when possible, you can also use push updates to directly commit changes to the main branch of your Stainless project. They are simpler and more flexible, but less powerful.
Option 1: Use GitHub action or GitLab CI in a push-based Workflow
If you store your OpenAPI spec in a GitHub or GitLab repository, you can use our CI component to build your SDK when a commit is pushed.
After setting up the action, pushes to your repository that update the OpenAPI spec will build your SDKs.
For setup instructions and more details, see the Build Stainless SDKs GitHub action.
Option 2: Set up URL polling for your project
If you have a stable URL to your OpenAPI spec, you can set up polling in the Stainless dashboard.
- In the Stainless dashboard, navigate to your project.
- Navigate to Release > Setup OpenAPI spec sync > Fetch URL.
- Add the URL to your OpenAPI spec.
- Click Fetch Spec.
We will check for changes to this link every hour, and it can be manually triggered on the UI.