Skip to main content

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:

  1. Open a simulation
  2. Click Integration in the top navigation
  3. 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

  1. Open the Integration Hub
  2. Select a route from your simulation
  3. Choose a language/tool from the dropdown
  4. The snippet is generated with your simulation URL and route details
  5. 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

  1. Open the Integration Hub
  2. Click Framework Guides tab
  3. Select your framework
  4. Follow step-by-step instructions with code examples
  5. 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

  1. Open the Integration Hub
  2. Click Docker Compose tab
  3. Select one or more simulations
  4. Click Generate docker-compose.yml
  5. 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

  1. Save the generated docker-compose.yml
  2. Set the SURESTAGE_API_KEY environment variable
  3. Run:
    docker-compose up
  4. 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

FormatDescriptionUse Case
OpenAPI 3.0OpenAPI specification (JSON or YAML)API documentation, code generation
Swagger 2.0Legacy Swagger formatOlder tooling compatibility
Postman CollectionPostman v2.1 collectionImport into Postman for testing
HARHTTP ArchiveBrowser DevTools, performance analysis
JSONSureStage native formatBackup, version control
YAMLSureStage native format (YAML)Human-readable backup

Exporting

  1. Open the Integration Hub
  2. Click Export tab
  3. Select export format
  4. Click Export
  5. 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

  1. Open the Integration Hub
  2. Click Import tab
  3. Choose import format
  4. Upload file or paste content
  5. Review detected routes and responses
  6. 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

  1. Click the Export button in the simulation editor
  2. The Export Menu opens with all available formats
  3. Select a format
  4. 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.

Next Steps

  • Imports - Detailed guide to importing API definitions
  • Sharing - Share simulations with team members
  • Analytics - Monitor simulation usage in CI/CD