SDK Reference
What is the SDK Reference?
This section provides documentation for CVT's language-specific SDKs. Each SDK offers the same core functionality, allowing you to choose the one that best fits your application's technology stack.
SDK Architecture
For information about SDK design patterns, adapter architecture, and how SDKs maintain cross-language consistency, see SDK Architecture.
Published SDKs
CVT SDKs are published to public registries: Node.js to npmjs, Java to Maven Central, Python to PyPI, and Go via go get.
Available SDKs
| Language | Path | Status |
|---|---|---|
| Node.js | sdks/node | Production-ready |
| Python | sdks/python | Production-ready |
| Go | sdks/go | Production-ready |
| Java | sdks/java | Production-ready |
Installation
- Node.js
- Python
- Go
- Java
npm install @sahina/cvt-sdk
# From PyPI (recommended)
pip install cvt-sdk
go get github.com/sahina/cvt/sdks/go
<!-- Maven: add to pom.xml (find latest version on Maven Central) -->
<dependency>
<groupId>io.github.sahina</groupId>
<artifactId>cvt-sdk</artifactId>
<version>0.1.0</version>
</dependency>
Common Features
All SDKs provide:
- Schema Registration - Register OpenAPI v2/v3 schemas
- Interaction Validation - Validate request/response pairs
- Consumer Registration - Register as a consumer for deployment safety
- Schema Comparison - Detect breaking changes between versions
- Fixture Generation - Generate test data from schemas
- HTTP Adapters - Automatic validation for HTTP clients
- Producer Middleware - Automatic validation for HTTP servers
Architecture
┌─────────────────────────────────────────────────────────────┐
│ Your Application │
│ ┌───────────┐ ┌───────────┐ ┌───────────┐ ┌───────────┐ │
│ │ Node.js │ │ Python │ │ Go │ │ Java │ │
│ │ SDK │ │ SDK │ │ SDK │ │ SDK │ │
│ └─────┬─────┘ └─────┬─────┘ └─────┬─────┘ └─────┬─────┘ │
└────────┼──────────────┼──────────────┼──────────────┼───────┘
│ │ │ │
└──────────────┴──────────────┴──────────────┘
│
gRPC Protocol
│
▼
┌────────────────────────┐
│ CVT Server │
│ (Port 9550) │
└────────────────────────┘
Quick Comparison
Initialization
- Node.js
- Python
- Go
- Java
import { ContractValidator } from "@sahina/cvt-sdk";
const validator = new ContractValidator("localhost:9550");
from cvt_sdk import ContractValidator
validator = ContractValidator("localhost:9550")
import "github.com/sahina/cvt/sdks/go/cvt"
validator, err := cvt.NewValidator("localhost:9550")
if err != nil {
log.Fatal(err)
}
defer validator.Close()
import io.github.sahina.sdk.ContractValidator;
ContractValidator validator = new ContractValidator("localhost:9550");
Validation
- Node.js
- Python
- Go
- Java
const result = await validator.validate(request, response);
if (!result.valid) {
console.error("Errors:", result.errors);
}
result = validator.validate(request, response)
if not result["valid"]:
print("Errors:", result["errors"])
result, err := validator.Validate(ctx, request, response)
if err != nil {
log.Fatal(err)
}
if !result.Valid {
fmt.Println("Errors:", result.Errors)
}
ValidationResult result = validator.validate(request, response);
if (!result.isValid()) {
System.err.println("Errors: " + result.getErrors());
}
Choosing an SDK
All SDKs have equivalent functionality. Choose based on your application's language.
For detailed documentation, see the individual SDK guides:
- Node.js SDK - For Node.js and TypeScript applications
- Python SDK - For Python applications
- Go SDK - For Go applications
- Java SDK - For Java and JVM applications