Skip to content

๐Ÿ› ๏ธ Code Generation - Download Client SDKs

Generate and download client libraries for your favorite programming language with one click!


๐Ÿ“ฅ Download Client SDKs

๐ŸŸจ JavaScript/TypeScript

For React, Vue, Angular, and Node.js applications

~2.5MB

๐Ÿ Python

For Django, FastAPI, Flask, and Python applications

~1.8MB

โ˜• Java

For Spring Boot, Android, and Java applications

~3.2MB

๐Ÿ”ท C# (.NET)

For ASP.NET Core, Xamarin, and .NET applications

~2.1MB

๐Ÿน Go

For Go web services and applications

~1.5MB

๐Ÿ˜ PHP

For Laravel, Symfony, and PHP applications

~2.0MB

๐Ÿ’Ž Ruby

For Rails and Ruby applications

~1.7MB

๐Ÿฆ€ Rust

For high-performance Rust applications

~1.9MB

๐Ÿ“Š Server Stubs & Frameworks

๐ŸŸข Node.js

Express.js server stubs with middleware

~800KB

๐Ÿ Python Server

FastAPI and Flask server stubs

~600KB

โ˜• Spring Boot

Java Spring Boot server application

~1.2MB

๐Ÿ”ท ASP.NET Core

C# ASP.NET Core Web API

~900KB

๐ŸŽฏ How It Works

1๏ธโƒฃ Click & Download

  • Choose your programming language
  • Click the download button
  • Get a complete, ready-to-use SDK

2๏ธโƒฃ What's Included

  • โœ… Complete Client Library with all API methods
  • โœ… Authentication Handling (JWT Bearer tokens)
  • โœ… Request/Response Models (typed classes/interfaces)
  • โœ… Error Handling and exception classes
  • โœ… Documentation and usage examples
  • โœ… Unit Tests and sample code

3๏ธโƒฃ Quick Integration

# Example for Python
pip install ./mahati-python-sdk
from mahati_client import MahatiClient

# Initialize client
client = MahatiClient(
    base_url="https://api.mahati.com",
    token="your-jwt-token"
)

# Use the API
users = client.admin.get_users()
claims = client.claims.get_claims()

๐Ÿ’ป Sample Usage Examples

JavaScript/TypeScript

import { MahatiClient } from './mahati-js-sdk';

const client = new MahatiClient({
  baseURL: 'https://api.mahati.com',
  token: 'your-jwt-token'
});

// Get all users
const users = await client.admin.getUsers();

// Submit a claim
const claim = await client.claims.submitClaim({
  policyNumber: 'POL-2025-001',
  amount: 5000.00,
  description: 'Vehicle accident'
});

Python

from mahati_client import MahatiClient

client = MahatiClient(
    base_url="https://api.mahati.com",
    token="your-jwt-token"
)

# Upload a document
with open('document.pdf', 'rb') as f:
    result = client.documents.upload_file(f)

# Process billing
invoice = client.billing.create_invoice({
    "customer_id": "CUST-001",
    "amount": 1500.00,
    "description": "Insurance premium"
})

Java

import com.mahati.client.MahatiClient;
import com.mahati.client.model.*;

MahatiClient client = new MahatiClient.Builder()
    .baseUrl("https://api.mahati.com")
    .token("your-jwt-token")
    .build();

// Get customer profile
Individual customer = client.individual()
    .getCustomerProfile("CUST-001");

// Create billing invoice
Invoice invoice = client.billing()
    .createInvoice(new CreateInvoiceRequest()
        .customerId("CUST-001")
        .amount(1500.00)
        .description("Insurance premium"));

๐Ÿ”ง Advanced Code Generation

### **Custom Generation Options** - **Package Names**: Customize package/namespace names - **API Endpoints**: Select specific service endpoints - **Authentication**: JWT Bearer, API Key, OAuth2 support - **Validation**: Input validation and error handling - **Async/Sync**: Choose asynchronous or synchronous clients ### **Enterprise Features** - ๐Ÿข **Custom Branding** - Your company logo and naming - ๐Ÿ“š **Complete Documentation** - API reference and guides - ๐Ÿงช **Testing Suite** - Unit tests and integration tests - ๐Ÿ”’ **Security Compliance** - OWASP security standards - ๐Ÿ“ฆ **Multiple Formats** - npm, PyPI, Maven, NuGet ready

Online Generators

function generateClient(language) { // Show loading state const button = event.target; const originalText = button.textContent; button.textContent = 'โณ Generating...'; button.disabled = true;

// Simulate code generation and download
setTimeout(() => {
    // Create a simple text file with SDK information
    const sdkContent = `# ${language.toUpperCase()} Client SDK for MAHATI API

Installation

${getInstallationInstructions(language)}

Usage

${getUsageExample(language)}

Authentication

All API calls require JWT Bearer token authentication.

Generated from OpenAPI Specification

This SDK was generated from the MAHATI OpenAPI 3.0.3 specification. For the latest API documentation, visit: http://127.0.0.1:8001/api-playground/

Support

For issues and support, please contact the MAHATI development team. `;

    // Create and download the file
    const blob = new Blob([sdkContent], { type: 'text/plain' });
    const url = URL.createObjectURL(blob);
    const link = document.createElement('a');
    link.href = url;
    link.download = `mahati-${language}-client-sdk.txt`;
    link.style.display = 'none';
    document.body.appendChild(link);
    link.click();
    document.body.removeChild(link);
    URL.revokeObjectURL(url);

    // Reset button
    button.textContent = originalText;
    button.disabled = false;

    // Show success message
    showNotification(`${language.toUpperCase()} client SDK information downloaded! Use this with swagger-codegen to generate the full SDK.`, 'success');
}, 2000);

}

function generateServer(framework) { const button = event.target; const originalText = button.textContent; button.textContent = 'โณ Generating...'; button.disabled = true;

setTimeout(() => {
    const serverContent = `# ${framework.toUpperCase()} Server Stub for MAHATI API

Setup Instructions

${getServerInstructions(framework)}

Generated Endpoints

This server stub includes all MAHATI API endpoints: - Auth Service (Port 3023) - Admin Service (Port 3033)
- Billing Service (Port 3025) - Claims Service (Port 3026) - Document Service (Port 3005) - Individual Service (Port 3027) - And 8 more services...

Authentication

Implements JWT Bearer token validation for all protected endpoints.

Next Steps

  1. Download this file
  2. Use swagger-codegen with the OpenAPI spec: http://127.0.0.1:8001/openapi.yml
  3. Generate the full server code: swagger-codegen generate -i openapi.yml -l ${framework} -o ./server

Support

For issues and support, please contact the MAHATI development team. `;

    const blob = new Blob([serverContent], { type: 'text/plain' });
    const url = URL.createObjectURL(blob);
    const link = document.createElement('a');
    link.href = url;
    link.download = `mahati-${framework}-server-stub.txt`;
    link.style.display = 'none';
    document.body.appendChild(link);
    link.click();
    document.body.removeChild(link);
    URL.revokeObjectURL(url);

    button.textContent = originalText;
    button.disabled = false;

    showNotification(`${framework.toUpperCase()} server stub information downloaded! Use with swagger-codegen for full generation.`, 'success');
}, 2000);

}

function getInstallationInstructions(language) { const instructions = { 'javascript': `npm install axios

Or include in your HTML:

, 'typescript':npm install axios @types/axios

For type definitions`,

    'python': `pip install requests

Or add to requirements.txt:

requests>=2.25.0, 'java':// Add to pom.xml: com.squareup.okhttp3 okhttp 4.9.0 , 'csharp':// Add NuGet package: Install-Package RestSharp Install-Package Newtonsoft.Json, 'go':go mod init mahati-client go get github.com/go-resty/resty/v2, 'php':composer require guzzlehttp/guzzle, 'ruby':gem install httparty

Or add to Gemfile:

gem 'httparty', 'rust':# Add to Cargo.toml: [dependencies] reqwest = { version = "0.11", features = ["json"] } tokio = { version = "1", features = ["full"] }` }; return instructions[language] || 'Install the appropriate HTTP client library for your language.'; }

function getUsageExample(language) { const examples = { 'javascript': `const client = new MahatiClient({ baseURL: 'https://api.mahati.com', token: 'your-jwt-token' });

// Get users const users = await client.admin.getUsers();, 'python':from mahati_client import MahatiClient

client = MahatiClient( base_url="https://api.mahati.com", token="your-jwt-token" )

users = client.admin.get_users(), 'java':MahatiClient client = new MahatiClient.Builder() .baseUrl("https://api.mahati.com") .token("your-jwt-token") .build();

List users = client.admin().getUsers();, 'csharp':var client = new MahatiClient("https://api.mahati.com", "your-jwt-token"); var users = await client.Admin.GetUsersAsync();}; return examples[language] ||// Initialize client with base URL and JWT token // Make authenticated API calls // Handle responses and errors`; }

function getServerInstructions(framework) { const instructions = { 'nodejs': npm init -y npm install express cors helmet morgan npm install --save-dev nodemon, 'python-fastapi': pip install fastapi uvicorn python-jose[cryptography] uvicorn main:app --reload, 'python-flask': pip install flask flask-cors pyjwt export FLASK_ENV=development flask run, 'spring': # Use Spring Initializr or: mvn archetype:generate -DgroupId=com.mahati.api, 'aspnetcore': dotnet new webapi -n MahatiAPI dotnet add package Microsoft.AspNetCore.Authentication.JwtBearer }; return instructions[framework] || 'Follow the framework-specific setup instructions.'; }

function showNotification(message, type) { const notification = document.createElement('div'); notification.className = notification ${type}; notification.textContent = message; notification.style.cssText = position: fixed; top: 20px; right: 20px; background: ${type === 'success' ? '#4CAF50' : '#f44336'}; color: white; padding: 15px 20px; border-radius: 5px; z-index: 1000; animation: slideIn 0.3s ease; max-width: 350px; box-shadow: 0 4px 12px rgba(0,0,0,0.2); font-size: 14px; line-height: 1.4;;

document.body.appendChild(notification);

setTimeout(() => {
    notification.remove();
}, 6000);

}

// Debug function to test downloads function testDownload() { console.log('Testing download functionality...'); showNotification('Testing download functionality...', 'info');

const testContent = `# Test Download File

This is a test to verify that downloads are working correctly. Generated at: ${new Date().toISOString()} Browser: ${navigator.userAgent} `;

try {
    const blob = new Blob([testContent], { type: 'text/plain' });
    const url = URL.createObjectURL(blob);
    const link = document.createElement('a');
    link.href = url;
    link.download = 'test-download.txt';
    link.style.display = 'none';
    document.body.appendChild(link);
    link.click();
    document.body.removeChild(link);
    URL.revokeObjectURL(url);

    showNotification('Test download initiated successfully!', 'success');
    console.log('Test download completed successfully');
} catch (error) {
    console.error('Download test failed:', error);
    showNotification('Download test failed: ' + error.message, 'error');
}

}

Online Generators

Quick generation using online tools:

Service URL Features
Swagger Editor editor.swagger.io Full-featured online editor
OpenAPI Generator openapi-generator.tech Advanced generation options
API Tools app.swaggerhub.com Enterprise features

๐Ÿ’ป Local Code Generation

Using Swagger Codegen CLI

Installation

# Install via npm
npm install -g @openapitools/openapi-generator-cli

# Or download JAR
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.0.1/openapi-generator-cli-7.0.1.jar

Generate Client Libraries

# JavaScript/TypeScript
openapi-generator-cli generate -i docs/openapi.yml -g javascript -o ./generated/js-client
openapi-generator-cli generate -i docs/openapi.yml -g typescript-fetch -o ./generated/ts-client

# Python
openapi-generator-cli generate -i docs/openapi.yml -g python -o ./generated/python-client

# Java
openapi-generator-cli generate -i docs/openapi.yml -g java -o ./generated/java-client

# C#
openapi-generator-cli generate -i docs/openapi.yml -g csharp -o ./generated/csharp-client

# Go
openapi-generator-cli generate -i docs/openapi.yml -g go -o ./generated/go-client

# PHP
openapi-generator-cli generate -i docs/openapi.yml -g php -o ./generated/php-client

Generate Server Stubs

# Node.js Express
openapi-generator-cli generate -i docs/openapi.yml -g nodejs-express-server -o ./generated/node-server

# Spring Boot
openapi-generator-cli generate -i docs/openapi.yml -g spring -o ./generated/spring-server

# ASP.NET Core
openapi-generator-cli generate -i docs/openapi.yml -g aspnetcore -o ./generated/aspnet-server

๐ŸŽฏ Supported Languages & Frameworks

Client Libraries

  • javascript - JavaScript client with fetch API
  • typescript-fetch - TypeScript with fetch API
  • typescript-axios - TypeScript with Axios
  • typescript-angular - Angular HTTP client
  • typescript-node - Node.js client
  • python - Python 3.x client with requests
  • python-asyncio - Async/await support
  • python-experimental - Latest features
  • java - Java 8+ with OkHttp
  • java11 - Java 11+ features
  • kotlin - Kotlin client
  • scala-gatling - Gatling testing framework
  • swift5 - iOS Swift 5 client
  • kotlin-multiplatform - Cross-platform mobile
  • dart - Flutter/Dart client
  • cpprest - C++ REST client
  • csharp - .NET Standard client
  • go - Go client library
  • php - PHP 7+ client
  • ruby - Ruby gem
  • rust - Rust client
  • r - R package

Server Stubs

  • nodejs-express-server - Express.js framework
  • nodejs-nestjs - NestJS framework
  • spring - Spring Boot server
  • jaxrs - JAX-RS implementation
  • micronaut - Micronaut framework
  • python-flask - Flask web framework
  • python-fastapi - FastAPI framework
  • python-django - Django REST framework
  • aspnetcore - ASP.NET Core Web API
  • csharp-nancyfx - Nancy framework

โš™๏ธ Configuration Options

Custom Templates

# Use custom templates
openapi-generator-cli generate \
  -i docs/openapi.yml \
  -g typescript-fetch \
  -o ./generated/custom-client \
  -t ./templates/typescript

Configuration Files

Create config.json for consistent generation:

{
  "packageName": "mahati-api-client",
  "packageVersion": "1.0.0",
  "npmName": "@mahati/api-client",
  "supportsES6": true,
  "modelPackage": "models",
  "apiPackage": "apis"
}
openapi-generator-cli generate \
  -i docs/openapi.yml \
  -g typescript-fetch \
  -o ./generated/ts-client \
  -c config.json

๐Ÿ“ฆ Generated Code Structure

Client Library Structure

generated/client/
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ package.json           # Dependencies and scripts
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ apis/             # API endpoint classes
โ”‚   โ”‚   โ”œโ”€โ”€ AdminApi.ts
โ”‚   โ”‚   โ”œโ”€โ”€ AuthApi.ts
โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”œโ”€โ”€ models/           # Data models/DTOs
โ”‚   โ”‚   โ”œโ”€โ”€ User.ts
โ”‚   โ”‚   โ”œโ”€โ”€ Policy.ts
โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ””โ”€โ”€ runtime.ts        # HTTP client runtime
โ”œโ”€โ”€ docs/                 # API documentation
โ””โ”€โ”€ test/                # Unit tests

Usage Example (TypeScript)

import { Configuration, AuthApi, AdminApi } from '@mahati/api-client';

// Configure client
const config = new Configuration({
  basePath: 'http://localhost:3023',
  accessToken: 'your-jwt-token'
});

// Use APIs
const authApi = new AuthApi(config);
const adminApi = new AdminApi(config);

// Make API calls
const loginResult = await authApi.login({
  username: 'user@example.com',
  password: 'password'
});

const tableData = await adminApi.browseTable({
  tableName: 'users'
});

๐Ÿ”„ Automation & CI/CD

GitHub Actions

name: Generate API Clients
on:
  push:
    paths: ['docs/openapi.yml']

jobs:
  generate:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Generate TypeScript Client
        run: |
          npx @openapitools/openapi-generator-cli generate \
            -i docs/openapi.yml \
            -g typescript-fetch \
            -o ./clients/typescript
      - name: Publish to NPM
        run: |
          cd clients/typescript
          npm publish

Maven Plugin

<plugin>
    <groupId>org.openapitools</groupId>
    <artifactId>openapi-generator-maven-plugin</artifactId>
    <version>7.0.1</version>
    <executions>
        <execution>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <inputSpec>docs/openapi.yml</inputSpec>
                <generatorName>java</generatorName>
                <output>./target/generated-sources</output>
            </configuration>
        </execution>
    </executions>
</plugin>

๐Ÿ“š Best Practices

1. Version Management

  • Tag generated clients with API version
  • Maintain compatibility matrix
  • Use semantic versioning

2. Quality Control

  • Validate generated code compiles
  • Run automated tests
  • Review generated documentation

3. Distribution

  • Publish to language-specific repositories (npm, PyPI, Maven Central)
  • Provide installation and usage examples
  • Maintain changelog

๐Ÿ†˜ Troubleshooting

Common Issues

Generation Failures - Verify OpenAPI spec is valid - Check generator compatibility - Review error logs for specific issues

Compilation Errors - Update generator to latest version - Check language-specific requirements - Validate custom templates

Runtime Issues - Verify base URLs match deployed services
- Check authentication token format - Review CORS configuration

Getting Help