-
Notifications
You must be signed in to change notification settings - Fork 16
docs: Add guide for using CLI to populate code samples without GitHub Actions #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
walker-tx
merged 16 commits into
main
from
devin/1747256876-cli-code-samples-without-github-actions
May 29, 2025
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
56cc869
Add guide for using CLI to populate code samples without GitHub Actions
devin-ai-integration[bot] 4b5269d
Merge branch 'main' into devin/1747256876-cli-code-samples-without-gi…
chailandau b08df2a
Merge branch 'main' into devin/1747256876-cli-code-samples-without-gi…
simplesagar b02eaac
Merge branch 'main' into devin/1747256876-cli-code-samples-without-gi…
chailandau 478412c
Merge branch 'main' into devin/1747256876-cli-code-samples-without-gi…
simplesagar 0b38c34
Clarify importance of main tag by drawing parallel to GitHub
devin-ai-integration[bot] 24e0c85
Add specific instruction to click Integrate with Docs Provider to fin…
devin-ai-integration[bot] 5732e53
Add references to integration guides for docs providers
devin-ai-integration[bot] d3813af
Add explanation of why to use CLI tagging instead of GitHub Actions
devin-ai-integration[bot] b474dd3
Remove redundant Important notes section
devin-ai-integration[bot] 6cbc955
Remove reference to integration guides documentation
devin-ai-integration[bot] 5dd3136
Update links to documentation providers with correct paths
devin-ai-integration[bot] ffc41bb
Update docs/guides/code-samples-without-github-actions.md
walker-tx 358bb73
Clean up extra blank line between sections
devin-ai-integration[bot] d333bd1
Update docs/guides/code-samples-without-github-actions.md
walker-tx 9878be2
Merge branch 'main' into devin/1747256876-cli-code-samples-without-gi…
walker-tx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| # Using the CLI to populate code samples without GitHub Actions | ||
|
|
||
| This guide explains how to use the Speakeasy CLI to generate and publish code samples for your API documentation when you're not using GitHub Actions. | ||
|
|
||
| ## Overview | ||
|
|
||
| Speakeasy can automatically generate code samples for your OpenAPI specification and make them available via a public URL that can be integrated with documentation platforms like Scalar. While this process is typically automated with GitHub Actions, you can achieve the same result using just the CLI in your own custom workflows. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - Speakeasy CLI installed | ||
| - An OpenAPI specification | ||
| - A Speakeasy account and API key | ||
|
|
||
| ## Step-by-step process | ||
|
|
||
| ### 1. Configure your workflow | ||
|
|
||
| First, set up your workflow configuration file: | ||
|
|
||
| ```bash | ||
| speakeasy configure | ||
| ``` | ||
|
|
||
| This creates a `.speakeasy/workflow.yaml` file that defines your SDK generation targets and code samples configuration. | ||
|
|
||
| ### 2. Generate SDKs and code samples | ||
|
|
||
| Run the Speakeasy CLI to generate your SDKs and code samples: | ||
|
|
||
| ```bash | ||
| speakeasy run | ||
| ``` | ||
|
|
||
| This command: | ||
| - Downloads or loads your OpenAPI document | ||
| - Validates the OpenAPI document | ||
| - Generates SDKs for your configured languages | ||
| - Creates code samples for each operation in your API | ||
|
|
||
| ### 3. Promote code samples to main | ||
|
|
||
| The critical step for enabling automated code samples is to tag your generated code samples with the `main` tag: | ||
|
|
||
| ```bash | ||
| speakeasy tag promote -c my-target-name -t main | ||
| ``` | ||
|
|
||
| This command marks your code samples as "official" so they can be incorporated into the public URL. Similar to how the `main` branch in GitHub represents the production-ready version of your code, the `main` tag in Speakeasy indicates these are the production-ready code samples that should be publicly available. Replace `my-target-name` with the name of your target as defined in your workflow configuration. | ||
|
|
||
| ### 4. Access the public URL | ||
|
|
||
| Once you've tagged your code samples with `main`, Speakeasy will automatically start building a combined spec in the background. The combined spec will be available at a public URL that you can use with documentation platforms like Scalar. | ||
|
|
||
| To find this URL, you'll need to visit the Speakeasy dashboard and navigate to the **Docs** tab. Click on **Integrate with Docs Provider** to see the URL to the OpenAPI with code samples combined. Currently, there's no CLI command to retrieve this URL programmatically. | ||
|
|
||
| ### 5. Integrate with docs providers | ||
|
|
||
| Once you have the public URL, you can integrate it with various documentation providers. Speakeasy offers detailed integration guides for several popular docs platforms: | ||
|
|
||
| - [Scalar](/docs/integrations/scalar) - A modern API documentation platform | ||
| - [ReadMe](/docs/integrations/readme) - Interactive API explorer and documentation | ||
| - [Mintlify](/docs/integrations/mintlify) - Developer documentation with an interactive playground | ||
| - [Bump.sh](/docs/integrations/bump) - Hosted API documentation and catalogs | ||
|
|
||
| ## Automating the process | ||
|
|
||
| For a fully automated workflow without GitHub Actions: | ||
|
|
||
| 1. Create a script or CI pipeline that runs `speakeasy run` to generate SDKs and code samples | ||
| 2. Add `speakeasy tag promote -c my-target-name -t main` to tag the generated code samples | ||
| 3. The public URL will automatically update with the latest code samples | ||
|
|
||
| ### Why use CLI tagging instead of GitHub Actions? | ||
|
|
||
| While GitHub Actions provides a convenient way to automate code sample generation and tagging, the CLI approach offers several advantages for teams: | ||
|
|
||
| - **Platform independence**: Use any CI/CD system (Jenkins, GitLab CI, CircleCI, Azure DevOps) instead of being limited to GitHub Actions | ||
| - **Custom workflows**: Integrate code sample generation into existing build processes or deployment pipelines | ||
| - **Local development**: Generate and test code samples locally before pushing changes | ||
| - **Private repositories**: Work with code that isn't hosted on GitHub or is in private repositories with restricted access | ||
| - **Enterprise environments**: Support for organizations with specific security or compliance requirements that prevent using GitHub Actions | ||
|
|
||
| ## Example workflow script | ||
|
|
||
| Here's a simple bash script example that could be used in a custom CI pipeline: | ||
|
|
||
| ```bash | ||
| #!/bin/bash | ||
| # Install Speakeasy CLI if needed | ||
| # curl -fsSL https://raw.githubusercontent.com/speakeasy-api/speakeasy/main/install.sh | sh | ||
|
|
||
| # Generate SDKs and code samples | ||
| speakeasy run | ||
|
|
||
| # Tag code samples as main | ||
| speakeasy tag promote -c my-python-target -t main | ||
| speakeasy tag promote -c my-typescript-target -t main | ||
|
|
||
| echo "Code samples have been generated and tagged. They will be available at the public URL in the Speakeasy dashboard." | ||
| ``` | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.