Multi-Version Swagger Management
One of Nidra's strengths is the ability to work with multiple versions of the same API simultaneously, making it perfect for API version migrations and backwards compatibility testing.
Why Multiple Versions?
Managing multiple API versions is essential when:
- Supporting legacy clients during migration
- Testing backwards compatibility
- Developing new versions while maintaining old ones
- Comparing behavior across versions
- Coordinating with teams on different versions
Strategy 1: Separate Collections
The simplest approach is to maintain each version in its own collection:
Collections/
├── MyAPI v1/
│ ├── Users
│ ├── Posts
│ └── Comments
├── MyAPI v2/
│ ├── Users
│ ├── Posts
│ └── Comments
└── MyAPI v3 (Beta)/
├── Users
└── Posts
Pros
- Clear separation
- Easy to manage
- No confusion about which version
Cons
- Duplication of similar requests
- Harder to compare versions side-by-side
Strategy 2: Version-Specific Environments
Use a single collection with version-specific environments:
Collection: MyAPI (All Versions)
Environments:
| Environment | baseUrl | version |
|---|---|---|
v1-dev | https://api-dev.example.com/v1 | 1.0 |
v1-prod | https://api.example.com/v1 | 1.0 |
v2-dev | https://api-dev.example.com/v2 | 2.0 |
v2-prod | https://api.example.com/v2 | 2.0 |
Benefits
- Single collection to maintain
- Easy version switching
- Shared request structure
- Efficient for similar APIs
Suitable For
- APIs with minor version differences
- Path-based versioning (
/v1/,/v2/) - Header-based versioning
Strategy 3: Hybrid Approach
Combine both strategies:
- Separate collections for major versions (v1, v2, v3)
- Environments for deployment stages (dev, staging, prod)
This works well when major versions have significant differences but minor versions are similar.
Importing Multiple Versions
Initial Import
- Import the first version as usual
- Name it clearly:
MyAPI v1 - Set up v1 environments
Adding New Versions
- Import the new version specification
- Choose "Create new collection" (not update)
- Name it:
MyAPI v2 - Set up v2 environments
Keeping Versions Updated
When a specification changes:
- Import the updated spec
- Select "Update existing collection"
- Choose the correct version collection
- Review changes
- Test affected endpoints
Cross-Version Testing
Test the same workflow across versions using Conduits:
Approach 1: Duplicate Conduits
- Create a conduit for v1
- Duplicate it for v2
- Update any version-specific differences
- Run both with their respective environments
Approach 2: Parameterized Conduits
Create conduits that work across versions:
- Use environment variables for version-specific values
- Switch environments to test different versions
- Compare results
Version Comparison Workflow
To compare behavior between versions:
- Set up identical requests in both version collections
- Use the same input data (copy request bodies)
- Run requests against both versions
- Compare responses:
- Status codes
- Response structure
- Data values
- Performance
Example: Testing User Creation
v1 Request:
POST {{baseUrl}}/users
{
"name": "John Doe",
"email": "john@example.com"
}
v2 Request:
POST {{baseUrl}}/users
{
"fullName": "John Doe",
"email": "john@example.com",
"preferences": {}
}
Note the field name change (name → fullName) and new required field.
Handling Breaking Changes
When a new version introduces breaking changes:
- Document the changes: Note what's different
- Update conduits: Modify test flows for new structure
- Maintain backward compatibility tests: Keep v1 tests running
- Create migration guides: Help team members transition
Version-Specific Variables
Use variables to handle version differences:
v1 environment:
userNameField: "name"
v2 environment:
userNameField: "fullName"
Then in requests:
{
"{{userNameField}}": "John Doe"
}
Best Practices
- Use consistent naming: Make version numbers obvious
- Tag versions clearly: Use labels or tags in collection names
- Document differences: Keep notes on what changed between versions
- Automate regression tests: Use conduits to test all versions regularly
- Plan deprecation: Know when to stop supporting old versions
- Communicate with stakeholders: Keep team informed of version status
Example: Complete Multi-Version Setup
Collections
Payment API v1(stable, legacy)Payment API v2(current production)Payment API v3(beta testing)
Environments
v1-prod,v1-stagingv2-prod,v2-staging,v2-devv3-dev(beta only)
Conduits
Payment Flow v1(regression tests)Payment Flow v2(current tests)Payment Flow v3(experimental)
Next Steps
- Learn about using variables →
- Set up parent environments →
- Build conduits → for testing