Multi-Schema to JSON Converter
Introduction
The "Multi-Schema to JSON Converter" Visual Studio Code extension streamlines your API development workflow by effortlessly converting schemas from multiple popular libraries into ready-to-use JSON sample data. This universal extension harnesses the power of Google's Generative AI to generate realistic and meaningful test data, saving you valuable time and ensuring the accuracy of your API testing across different technology stacks.
Features
- Multi-Schema Support: Convert schemas from Mongoose, Prisma, Sequelize, and Zod libraries
- Automatic Detection: Intelligently detects the schema library type and applies the appropriate parser
- One-Click Conversion: Seamlessly transform any supported schema into JSON-compatible JSON with a single command
- AI-Powered: Leverages Google's Generative AI to create intelligent and context-aware sample data, ensuring realistic and meaningful test results
- Universal Compatibility: Works with MongoDB, PostgreSQL, MySQL, and other databases through their respective ORMs
- Time-Saving: Eliminates the need for manual sample data creation, significantly reducing your testing time
- Customizable: Allows for easy customization of the generated data to meet your specific testing requirements
- Usage Tracking: Free usage for the first 100 conversions, then requires your own Gemini API key
- API Key Management: Easy setup and management of your Gemini API key through VS Code commands
Installation
- Open Visual Studio Code.
- Navigate to the Extensions view (Ctrl+Shift+X or Cmd+Shift+X).
- Search for "Multi-Schema to JSON".
- Click the "Install" button.
How to Use Guide:
Go through the tutorial to see how to convert your Mongoose schemas into ready-to-use JSON sample data.
https://github.com/user-attachments/assets/c4a94ad5-00ce-4b62-826a-43705affa731
Usage
- Open a file containing your schema (Mongoose, Prisma, Sequelize, or Zod).
- Select the schema code.
- Open the Command Palette (Ctrl+Shift+P or Cmd+Shift+P).
- Type "Convert Schema to JSON Raw" and select the command.
- The converted JSON will open in a new editor tab.
Supported Schema Types:
- Mongoose: MongoDB schemas with validation rules
- Prisma: Database schemas with relations and constraints
- Sequelize: SQL database models with associations
- Zod: TypeScript-first schema validation
Configuration
The extension provides 100 free uses with a built-in API key. After 100 uses, you'll need to provide your own Gemini API key:
- Automatic Prompt: After 100 uses, the extension will automatically prompt you to enter your API key.
- Manual Setup: You can also set your API key anytime using the Command Palette:
- Press
Ctrl+Shift+P
(or Cmd+Shift+P
on Mac)
- Type "Set Gemini API Key" and select the command
- Enter your Gemini API key when prompted
Additional Commands:
- Set Gemini API Key: Manually set your API key
Getting a Gemini API Key:
- Visit Google AI Studio
- Sign in with your Google account
- Create a new API key
- Copy the key and use it in the extension
Examples
Mongoose Schema Example:
const UserSchema = new Schema({
username: { type: String, required: true },
email: { type: String, required: true, unique: true },
age: { type: Number, min: 18, max: 100 },
isActive: { type: Boolean, default: true },
createdAt: { type: Date, default: Date.now }
});
Prisma Schema Example:
model User {
id String @id @default(uuid())
username String @unique
email String @unique
age Int?
isActive Boolean @default(true)
createdAt DateTime @default(now())
}
Sequelize Schema Example:
const User = sequelize.define('User', {
username: {
type: DataTypes.STRING,
allowNull: false,
unique: true
},
email: {
type: DataTypes.STRING,
allowNull: false,
unique: true,
validate: { isEmail: true }
},
age: {
type: DataTypes.INTEGER,
allowNull: true,
validate: { min: 18, max: 100 }
}
});
Zod Schema Example:
const UserSchema = z.object({
username: z.string().min(3).max(30),
email: z.string().email(),
age: z.number().min(18).max(100).optional(),
isActive: z.boolean().default(true),
createdAt: z.date().default(() => new Date())
});
Output (JSON-ready JSON):
{
"username": "john_doe",
"email": "john.doe@example.com",
"age": 30,
"isActive": true,
"createdAt": "2023-08-15T10:30:00Z"
}
Contributing
We welcome contributions! Please refer to the CONTRIBUTING.md file for guidelines on submitting pull requests, reporting issues, or requesting features.