Integration Hub
The Integration Hub provides tools for integrating SureStage simulations into your development workflow. Generate code snippets, export API definitions, import from external formats, and access framework-specific integration guides.
Accessing the Integration Hub
Open the Integration Hub from any simulation:
- Open a simulation
- Click Integration in the top navigation
- The Integration Hub opens with code snippets, export options, and import tools
Code Snippet Generation
Generate ready-to-use code for calling your simulation endpoints.
Supported Languages and Tools
- cURL - Command-line requests
- JavaScript (fetch) - Browser or Node.js
- JavaScript (axios) - Node.js with axios library
- Python (requests) - Python with requests library
- PowerShell - Windows PowerShell
- Bash - Shell scripting
Generating Snippets
- Open the Integration Hub
- Select a route from your simulation
- Choose a language/tool from the dropdown
- The snippet is generated with your simulation URL and route details
- Click Copy to copy to clipboard
Example: cURL
curl -X GET https://abc123.srstg.io/api/v1/users/42 \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json"
Example: JavaScript (fetch)
fetch('https://abc123.srstg.io/api/v1/users/42', {
method: 'GET',
headers: {
'Authorization': 'Bearer YOUR_TOKEN',
'Content-Type': 'application/json'
}
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
Example: PowerShell
$headers = @{
"Authorization" = "Bearer YOUR_TOKEN"
"Content-Type" = "application/json"
}
Invoke-RestMethod -Uri "https://abc123.srstg.io/api/v1/users/42" `
-Method GET `
-Headers $headers
Snippets include authentication headers, query parameters, and request bodies based on your route configuration.
Framework-Specific Integration Guides
The Integration Hub includes guides for popular development frameworks.
Available Guides
- React - Integrate simulations with React apps using fetch or axios
- Angular - Use HttpClient with SureStage mocks
- Vue.js - Axios configuration for Vue apps
- Next.js - API routes and environment variables
- Express.js - Proxy configuration for Node.js backends
- Spring Boot - RestTemplate and WebClient setup
- Django - Requests library integration
- .NET - HttpClient configuration
Using Framework Guides
- Open the Integration Hub
- Click Framework Guides tab
- Select your framework
- Follow step-by-step instructions with code examples
- Adapt the example to your simulation URL and routes
Each guide includes:
- Environment variable configuration
- HTTP client setup
- Example requests
- Error handling patterns
- Testing strategies
Docker Compose Integration
Run SureStage simulations locally using Docker Compose.
Generating Docker Compose Configuration
- Open the Integration Hub
- Click Docker Compose tab
- Select one or more simulations
- Click Generate docker-compose.yml
- Copy or download the configuration
Example Docker Compose Snippet
version: '3.8'
services:
surestage-mock:
image: surestage/mock-server:latest
environment:
- SIMULATION_ID=abc123def456
- SURESTAGE_API_KEY=${SURESTAGE_API_KEY}
ports:
- "8080:8080"
networks:
- app-network
networks:
app-network:
driver: bridge
Running Locally
- Save the generated
docker-compose.yml - Set the
SURESTAGE_API_KEYenvironment variable - Run:
docker-compose up - Your simulation is available at
http://localhost:8080
This is useful for offline development and CI/CD pipelines.
Exporting API Definitions
Export your simulation in standard API formats for use with other tools.
Export Formats
| Format | Description | Use Case |
|---|---|---|
| OpenAPI 3.0 | OpenAPI specification (JSON or YAML) | API documentation, code generation |
| Swagger 2.0 | Legacy Swagger format | Older tooling compatibility |
| Postman Collection | Postman v2.1 collection | Import into Postman for testing |
| HAR | HTTP Archive | Browser DevTools, performance analysis |
| JSON | SureStage native format | Backup, version control |
| YAML | SureStage native format (YAML) | Human-readable backup |
Exporting
- Open the Integration Hub
- Click Export tab
- Select export format
- Click Export
- Download the file
Using Exports
OpenAPI/Swagger - Import into Swagger UI, Stoplight, or use with code generators like OpenAPI Generator.
Postman Collection - Import into Postman to create a test suite from your simulation.
HAR - Analyze in browser DevTools or tools like Charles Proxy.
JSON/YAML - Store in version control to track simulation changes over time.
Importing from External Formats
Import API definitions from other tools and formats into SureStage.
Supported Import Formats
- OpenAPI 3.0 / Swagger 2.0 - REST API specifications
- Postman Collection - Postman v2.x collections
- Mockoon - Mockoon environment files
- AsyncAPI - Asynchronous API specifications (e.g., WebSocket, message queues)
- GraphQL Schema - GraphQL schema definitions (.graphql, .gql)
- gRPC / Protocol Buffers - gRPC service definitions (.proto)
- LDIF - LDAP Data Interchange Format
Importing a File
- Open the Integration Hub
- Click Import tab
- Choose import format
- Upload file or paste content
- Review detected routes and responses
- Click Import
Routes are created in your simulation based on the imported definition.
Import Behavior
- Merge - Imported routes are added alongside existing routes
- Replace - Existing routes are removed, then import is applied
- Preview - Review changes before importing
SureStage maps imported formats to native mock rules. Complex logic (e.g., GraphQL resolvers) may need manual adjustment.
Export Menu
Quick access to all export options.
Using the Export Menu
- Click the Export button in the simulation editor
- The Export Menu opens with all available formats
- Select a format
- Download the file
The Export Menu is available throughout the app for quick exports without opening the Integration Hub.
CI/CD Integration
Integrate SureStage simulations into automated pipelines.
Environment Variables
Set these variables in your CI/CD environment:
SURESTAGE_API_KEY=your_api_key
SURESTAGE_SIMULATION_URL=https://abc123.srstg.io
Example: GitHub Actions
name: Integration Tests
on: [push]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run tests against SureStage mock
env:
API_URL: ${{ secrets.SURESTAGE_SIMULATION_URL }}
run: npm test
Example: GitLab CI
test:
stage: test
variables:
API_URL: $SURESTAGE_SIMULATION_URL
script:
- npm install
- npm test
Point your test suite at the simulation URL. No need to stand up local mocks or depend on staging environments.
Best Practices
Use environment variables - Never hardcode simulation URLs. Use env vars for flexibility across environments.
Version control exports - Export to OpenAPI or YAML and commit to version control to track API changes.
Generate snippets early - Share code snippets with team members so everyone uses consistent request patterns.
Test locally with Docker Compose - Run simulations locally to avoid network dependencies during development.
Import from design tools - Start with an OpenAPI spec in Stoplight or Swagger Editor, then import into SureStage.
Automate with CI/CD - Use simulations in automated tests to catch integration issues early.