Skip to main content

API Versioning & Changelog Tools

Developer guide to API version management and automated changelog generation

This guide covers how to use Staqr's API versioning tools during development, testing, and release processes.


Overview

Staqr provides automated tooling for:

  1. Changelog Generation: Compare API versions and generate release notes
  2. Breaking Change Detection: Prevent accidental API breaking changes in PRs
  3. AI-Enhanced Changelogs: Transform technical diffs into readable release notes

These tools integrate with your development workflow and CI/CD pipelines.


Tool 1: Changelog Generation Script

Purpose

Compare OpenAPI specifications between two git tags and generate a markdown changelog.

Location

scripts/generate-changelog.sh

Usage

./scripts/generate-changelog.sh <previous-version> <current-version>

Example

# Compare v1.0.0 to v1.1.0
./scripts/generate-changelog.sh v1.0.0 v1.1.0

# Output: docs-new/changelogs/CHANGELOG-v1.1.0.md

What It Does

  1. Checks out previous version (e.g., v1.0.0)
  2. Generates OpenAPI spec from that version's code
  3. Checks out current version (e.g., v1.1.0)
  4. Generates OpenAPI spec from current code
  5. Compares specs using oasdiff
  6. Generates markdown changelog with:
    • Docusaurus frontmatter (title, description)
    • New endpoints
    • Modified endpoints
    • Removed endpoints
    • Breaking changes section (if any detected)
  7. Saves to docs-new/changelogs/CHANGELOG-v1.1.0.md

Output Format

---
title: 'API Changelog v1.1.0'
description: 'API changes from v1.0.0 to v1.1.0'
sidebar_position: 1
---

# API Changelog: v1.1.0

**Release Date:** 2026-01-19
**Previous Version:** v1.0.0

---

## New Endpoints: 5

### POST /api/v1/flows/{flowId}/execute
- endpoint added
- request body: application/json (FlowExecutionRequest)
- response: 200 (FlowExecutionResponse)

### GET /api/v1/connections/{connectionId}/health
- endpoint added
...

## Breaking Changes

⚠️ Parameter `customerId` removed from POST /api/v1/orders
⚠️ Response format changed for GET /api/v1/billing/invoices

Prerequisites

  • Git tags exist for the versions you want to compare
  • OpenAPI spec can be generated for both versions
  • oasdiff installed (automatic via go install)

Troubleshooting

Error: "Tag v1.0.0 not found"

# Check available tags
git tag --list | grep "^v"

# Create tags if needed
git tag v1.0.0

Error: "Could not generate OpenAPI spec"

# Ensure the version can build
git checkout v1.0.0
cd packages/server/api
pnpm install
pnpm run build
pnpm run generate:openapi

Tool 2: AI-Enhanced Changelog Script

Purpose

Transform technical oasdiff output into human-friendly release notes using Claude AI.

Location

scripts/generate-ai-changelog.py

Usage

python3 scripts/generate-ai-changelog.py \
<previous-spec.json> \
<current-spec.json> \
<version> \
<output-file>

Example

# Generate AI-enhanced changelog for v1.1.0
python3 scripts/generate-ai-changelog.py \
/tmp/openapi-v1.0.0.json \
/tmp/openapi-v1.1.0.json \
v1.1.0 \
docs-new/changelogs/CHANGELOG-v1.1.0-ai.md

Prerequisites

  1. Python 3.x installed
  2. Anthropic package:
    pip install -r requirements-changelog.txt
    # or
    pip install anthropic
  3. Anthropic API key:
    export ANTHROPIC_API_KEY=sk-ant-api03-...

What Makes It Different

Standard ChangelogAI-Enhanced Changelog
Technical endpoint diffsPlain English explanations
Raw schema changesGrouped by use case/domain
No contextImpact analysis and migration examples
For API developersFor all developers

Example Output

## Flow Management

### ✨ New: Execute Flows Programmatically

You can now trigger flows via the API, enabling scheduled jobs and external automation.

**Use Case:** Run a flow when an external event occurs

**Example:**
```typescript
import { StaqrClient } from '@staqr/api-client';

const client = new StaqrClient({ apiKey: process.env.STAQR_API_KEY });

const result = await client.flows.execute(flowId, {
payload: { customerId: 'cust_123' }
});

console.log(result.executionId); // flow-run-abc123

Migration: No changes required for existing code (new feature only)


---

## Tool 3: Breaking Change Detection (PR Workflow)

### Purpose

Automatically detect API breaking changes when you create a pull request.

### Location

`.github/workflows/api-breaking-changes.yml`

### How It Works

```mermaid
graph TD
A[Create PR] --> B{Modifies API code?}
B -->|Yes| C[Generate Base Branch Spec]
B -->|No| D[Workflow Skipped]
C --> E[Generate PR Branch Spec]
E --> F[Run oasdiff breaking]
F --> G{Breaking Changes?}
G -->|Yes| H[Comment on PR with Warning]
G -->|No| I[Comment with Summary]

Triggers

The workflow runs when a PR modifies:

  • packages/server/api/src/**
  • packages/shared/src/**

PR Comments

If breaking changes detected:

## ⚠️ Breaking API Changes Detected

**This PR introduces breaking changes to the Staqr Platform API.**

<details>
<summary>Breaking Changes</summary>

- Parameter `customerId` removed from POST /api/v1/orders
- Response type changed for GET /api/v1/billing/invoices
- Endpoint DELETE /api/v1/legacy-endpoint removed

</details>

**Action Required:**
- If intentional: Bump major version (e.g., v1.x.x → v2.0.0)
- If unintentional: Revise changes to maintain backward compatibility

If no breaking changes:

## ✅ API Changes Detected (No Breaking Changes)

This PR modifies the API but does not introduce breaking changes.

<details>
<summary>API Changes</summary>

- New endpoint: POST /api/v1/flows/{flowId}/execute
- New parameter: GET /api/v1/connections?status=active

</details>

Testing Before PR

Check for breaking changes locally before creating a PR:

# 1. Generate current branch spec
cd packages/server/api
pnpm run generate:openapi
cp dist/openapi.json /tmp/pr-spec.json

# 2. Generate main branch spec
git stash
git checkout main
pnpm run build
pnpm run generate:openapi
cp dist/openapi.json /tmp/main-spec.json
git checkout -

# 3. Check for breaking changes
oasdiff breaking /tmp/main-spec.json /tmp/pr-spec.json

Tool 4: Automatic Release Changelogs

Purpose

Automatically generate and publish changelogs when you release a new version.

Location

.github/workflows/changelog-generation.yml

How It Works

Trigger: Push a version tag

git tag v1.2.0
git push origin v1.2.0

What Happens:

  1. GitHub Actions detects the new tag
  2. Finds the previous version tag automatically
  3. Runs scripts/generate-changelog.sh
  4. Commits changelog to docs-new/changelogs/
  5. Pushes to nightly branch
  6. (Optional) Runs AI enhancement if ANTHROPIC_API_KEY secret configured
  7. Uploads changelog as GitHub artifact

Result: Changelog appears in Docusaurus automatically

Manual Trigger

You can also run the workflow manually for any two versions:

  1. Go to Actions tab in GitHub
  2. Select Generate API Changelog workflow
  3. Click Run workflow
  4. Enter previous version (e.g., v1.0.0)
  5. Enter current version (e.g., v1.1.0)
  6. Click Run

Development Workflow

During Development

While building new features:

# Preview what will be in the changelog
cd packages/server/api
pnpm run generate:openapi

# Compare against last release
oasdiff diff \
/path/to/v1.0.0/openapi.json \
dist/openapi.json \
--format text

Before Creating PR

Check for unintentional breaking changes:

# Generate specs for both branches (see "Testing Before PR" above)
oasdiff breaking /tmp/main-spec.json /tmp/pr-spec.json

If breaking changes found:

  • Intentional? Plan to bump major version
  • Unintentional? Revise your changes to maintain compatibility

During Code Review

When reviewing a PR:

  1. Check the automated comment from API Breaking Change Detection
  2. Review the diff summary
  3. If breaking changes present, verify they're intentional
  4. Confirm major version will be bumped if merging

At Release Time

# 1. Decide on version number
# - Breaking changes? → Bump major (v2.0.0)
# - New features? → Bump minor (v1.1.0)
# - Bug fixes only? → Bump patch (v1.0.1)

# 2. Create and push tag
git tag v1.1.0
git push origin v1.1.0

# 3. Changelog auto-generates
# - Check GitHub Actions for progress
# - Changelog appears in docs within minutes

Configuration

GitHub Secrets (Optional AI Enhancement)

To enable AI-enhanced changelogs in GitHub Actions:

  1. Go to repository Settings
  2. Navigate to Secrets and variables → Actions
  3. Click New repository secret
  4. Name: ANTHROPIC_API_KEY
  5. Value: Your Claude API key from Anthropic Console
  6. Click Add secret

Without this secret: Standard technical changelogs still work (oasdiff only)

Local Setup

Install oasdiff:

go install github.com/oasdiff/oasdiff@latest

Install Python dependencies (for AI enhancement):

pip install -r requirements-changelog.txt

Set API key (for AI enhancement):

export ANTHROPIC_API_KEY=sk-ant-...
# Or add to ~/.bashrc or ~/.zshrc for persistence

Best Practices

1. Always Check for Breaking Changes

Before merging to main:

oasdiff breaking /tmp/main-spec.json /tmp/pr-spec.json

2. Document Breaking Changes

If introducing a breaking change intentionally:

  • Update the PR description with migration instructions
  • Add deprecation notices before removal
  • Coordinate with API consumers

3. Use Semantic Versioning

Change TypeVersion BumpExample
Add endpointMinorv1.0.0 → v1.1.0
Add optional parameterMinorv1.0.0 → v1.1.0
Remove endpointMajorv1.0.0 → v2.0.0
Change response typeMajorv1.0.0 → v2.0.0
Bug fixPatchv1.0.0 → v1.0.1

4. Keep OpenAPI Specs Updated

Ensure your OpenAPI spec stays in sync with code:

# After API changes, regenerate spec
cd packages/server/api
pnpm run generate:openapi

# Verify spec is accurate
cat dist/openapi.json | jq '.paths | keys' | head -20

5. Test Changelog Generation Locally

Before pushing a version tag, test the changelog:

# Create test tags
git tag v0.99.0-test
git tag v1.0.0-test

# Generate changelog
./scripts/generate-changelog.sh v0.99.0-test v1.0.0-test

# Review output
cat docs-new/changelogs/CHANGELOG-v1.0.0-test.md

# Cleanup test tags
git tag -d v0.99.0-test v1.0.0-test
rm docs-new/changelogs/CHANGELOG-v1.0.0-test.md

Troubleshooting

"oasdiff: command not found"

# Install oasdiff
go install github.com/oasdiff/oasdiff@latest

# Add to PATH (if needed)
export PATH="$PATH:$HOME/go/bin"

# Verify
oasdiff --version

"Could not generate OpenAPI spec for v1.0.0"

The version must have a buildable API package:

# Check out the version
git checkout v1.0.0

# Try building
cd packages/server/api
pnpm install
pnpm run build

# Check if generate:openapi script exists
grep "generate:openapi" package.json

# If missing, spec may not exist for that version
# Use a later version or add the script

"Breaking changes in non-major version"

The script warns if breaking changes detected in minor/patch versions:

⚠️ Breaking changes detected:
❌ Breaking changes in non-major version!
Consider bumping to v2.0.0

Action:

  • If intentional: Bump to major version
  • If unintentional: Revise changes to maintain compatibility

"ANTHROPIC_API_KEY environment variable not set"

AI enhancement requires an API key:

# Get API key from Anthropic Console
# https://console.anthropic.com/

# Set environment variable
export ANTHROPIC_API_KEY=sk-ant-api03-...

# Or add to shell config
echo 'export ANTHROPIC_API_KEY=sk-ant-...' >> ~/.bashrc
source ~/.bashrc

Workflow Not Triggering

For changelog generation:

  • Ensure tag matches pattern v*.*.* (e.g., v1.0.0, not 1.0.0)
  • Check GitHub Actions tab for workflow runs
  • Verify workflows are enabled in repository settings

For breaking change detection:

  • Ensure PR modifies files in packages/server/api/src/**
  • Check the "Files changed" tab on the PR
  • Wait a few minutes for workflow to complete

Advanced Usage

Comparing Arbitrary Commits

Compare any two commits (not just tags):

# Generate spec from commit A
git checkout abc123
cd packages/server/api && pnpm run generate:openapi
cp dist/openapi.json /tmp/spec-a.json

# Generate spec from commit B
git checkout def456
pnpm run build && pnpm run generate:openapi
cp dist/openapi.json /tmp/spec-b.json

# Compare
oasdiff diff /tmp/spec-a.json /tmp/spec-b.json --format text

Filtering Changes

oasdiff supports filtering by specific paths or operations:

# Only show changes to /flows endpoints
oasdiff diff prev.json curr.json --filter-path="/api/v1/flows.*"

# Only show POST/PUT/DELETE (mutations)
oasdiff diff prev.json curr.json --filter-method="POST,PUT,DELETE"

JSON Output for Automation

Generate machine-readable output:

# JSON format for programmatic use
oasdiff diff prev.json curr.json --format json > changes.json

# Parse with jq
cat changes.json | jq '.pathsDiff.added | length'
# Output: 5 (number of new endpoints)

Custom AI Prompts

Modify the AI enhancement prompt for different audiences:

# Edit scripts/generate-ai-changelog.py
# Find the prompt variable (line ~743)

prompt = f"""Please provide an API changelog for {version}...

<custom_instructions>
Focus on: [Frontend developers / Backend integrators / Mobile app teams]
Include: [Code examples in JavaScript / Python / cURL]
Tone: [Technical / Beginner-friendly / Executive summary]
</custom_instructions>
"""

Integration with Development Process

Sprint Planning

Use changelogs to estimate migration effort for API consumers:

# Preview breaking changes for next release
./scripts/generate-changelog.sh v1.0.0 main

# Estimate migration work based on breaking changes count

Release Notes

Combine automated changelogs with manual release notes:

# Release v1.1.0

## Highlights
- New flow execution API
- Improved connection health monitoring
- Performance improvements

## Complete API Changes
See [API Changelog](/changelogs/CHANGELOG-v1.1.0)

## Breaking Changes
⚠️ None - fully backward compatible

Deprecation Workflow

When deprecating an endpoint:

  1. v1.0.0: Add new endpoint, mark old as deprecated in docs
  2. v1.1.0: Changelog shows both endpoints exist
  3. v2.0.0: Remove old endpoint, changelog shows breaking change
# Changelog will show:
# v1.1.0: Added new endpoint (no breaking changes)
# v2.0.0: Removed deprecated endpoint (breaking change)

ToolPurposeDocumentation
SDK GenerationAuto-generate TypeScript/Python SDKsSDK Guide
Mock ServersPrism-based API mockingMock Server Guide
Postman CollectionsGUI-based API testingPostman Guide

Reference

Command Reference

# Generate standard changelog
./scripts/generate-changelog.sh <prev> <curr>

# Generate AI-enhanced changelog
python3 scripts/generate-ai-changelog.py <prev-spec> <curr-spec> <version> <output>

# Check for breaking changes
oasdiff breaking <prev> <curr> --format text

# Generate diff
oasdiff diff <prev> <curr> --format text

# Changelog format options
oasdiff changelog <prev> <curr> --format markdown
oasdiff changelog <prev> <curr> --format json

File Locations

FilePurpose
scripts/generate-changelog.shMain changelog script
scripts/generate-ai-changelog.pyAI enhancement script
.github/workflows/changelog-generation.ymlAuto-generate on tags
.github/workflows/api-breaking-changes.ymlPR breaking change detection
requirements-changelog.txtPython dependencies
docs-new/changelogs/Generated changelog output

Environment Variables

VariableRequiredPurpose
ANTHROPIC_API_KEYOptionalClaude API key for AI-enhanced changelogs
OASDIFF_BINOptionalPath to oasdiff binary (auto-detected)

Next Steps

  1. Try generating a test changelog
  2. Configure ANTHROPIC_API_KEY for AI enhancement (optional)
  3. Create your first version tag when ready to release
  4. Review generated changelogs in Docusaurus

For more information, see:


Questions? Contact the Platform team or open an issue on GitHub.