|
1 | 1 | --- |
2 | 2 | title: Stainless |
3 | | -description: Automate your SDK example snippets in the API playground |
| 3 | +description: Automate SDK example snippets in your API playground |
4 | 4 | --- |
5 | 5 |
|
6 | | -If you use Mintlify's OpenAPI support for your API reference documentation, add the following to your Stainless config: |
7 | | - |
8 | | -```yaml openapi.stainless.yml |
9 | | -openapi: |
10 | | - code_samples: mintlify |
11 | | -``` |
12 | | -
|
13 | | -Configure the [OpenAPI setup](/api-playground/openapi/setup#in-the-repo) in your Mintlify docs. To integrate Stainless, modify the GitHub Action that uploads your OpenAPI spec to Stainless so that it pushes the Stainless-enhanced OpenAPI spec into your docs repo like so: |
14 | | -
|
15 | | -
|
16 | | -```yaml |
17 | | -name: Upload OpenAPI spec to Stainless and (Mintlify) docs repo |
18 | | - |
19 | | -on: |
20 | | - push: |
21 | | - branches: [main] |
22 | | - workflow_dispatch: |
23 | | - |
24 | | -jobs: |
25 | | - stainless: |
26 | | - runs-on: ubuntu-latest |
27 | | - steps: |
28 | | - - uses: actions/checkout@v4 |
29 | | - - name: Push spec and config to Stainless and outputs documented spec |
30 | | - uses: stainless-api/upload-openapi-spec-action@main |
31 | | - with: |
32 | | - input_path: 'path/to/my-company-openapi.json' |
33 | | - config_path: 'path/to/my-company.stainless.yaml' |
34 | | - output_path: 'path/to/my-company-openapi.documented.json' |
35 | | - project_name: 'my-stainless-project' |
36 | | - - name: Push documented spec to docs repo |
37 | | - uses: dmnemec/copy_file_to_another_repo_action@main |
38 | | - env: |
39 | | - API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }} |
40 | | - with: |
41 | | - source_file: 'config/my-company-openapi.documented.json' |
42 | | - destination_repo: '{DOCS_REPO_NAME}' |
43 | | - destination_folder: 'openapi-specs' # (optional) the folder in the destination repository to place the file in, if not the root directory |
44 | | - user_email: '{EMAIL}' # the email associated with the GH token |
45 | | - user_name: '{USERNAME}' # the username associated with the GH token |
46 | | - commit_message: 'Auto-updates from Stainless' |
47 | | -``` |
48 | | -
|
49 | | -This assumes the following secrets have been [uploaded to your GitHub Actions Secrets](https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions): |
50 | | -
|
51 | | -- `secrets.STAINLESS_API_KEY`: Your Stainless API key. |
52 | | -- `secrets.API_TOKEN_GITHUB`: A GitHub [Personal Access Token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) with permissions to push to your docs repo. |
| 6 | +## Prerequisites |
| 7 | + |
| 8 | +* Have a valid OpenAPI specification in your `docs.json`. See [OpenAPI Setup](/api-playground/openapi/setup) for more details. |
| 9 | +* Have a [Stainless](https://app.stainless.com) account. |
| 10 | + |
| 11 | +## Integrate with Stainless |
| 12 | + |
| 13 | +<Steps> |
| 14 | + <Step title="Setup OpenAPI decoration in Stainless."> |
| 15 | + In your `stainless.yml` config file, add `openapi.code_samples: 'mintlify'`. See the [Stainless documentation](https://app.stainless.com/docs/guides/integrate-docs) for more information. |
| 16 | + </Step> |
| 17 | + <Step title="Get the URL to your OpenAPI spec."> |
| 18 | + In your Stainless project: |
| 19 | + |
| 20 | + 1. Select the **Release** tab. |
| 21 | + 2. Select **Setup OpenAPI publishing**. |
| 22 | + 3. Copy the URL to your publicly accessible OpenAPI spec. |
| 23 | + |
| 24 | + <img |
| 25 | + src="/images/stainless-public-OpenAPI-spec.png" |
| 26 | + alt="Stainless release page with the OpenAPI spec URL highlighted with a green box." |
| 27 | + /> |
| 28 | + </Step> |
| 29 | + <Step title="Add your OpenAPI spec URL to your `docs.json`."> |
| 30 | + In your `docs.json` file, add the URL from Stainless to the `openapi` field. See the [OpenAPI Setup](/api-playground/openapi/setup) for more information. |
| 31 | + </Step> |
| 32 | +</Steps> |
0 commit comments