Type Generator
Plugin Info
Author: Parv Bajaj | Version: 1.0.2 | Repository: parvbajaj1/voiden-type-generator
Generate strongly-typed model code from your API responses, without leaving Voiden.
Built on quicktype. Supports TypeScript, Dart, Go, Kotlin, Swift, and Java.
Features
- Automatic capture — hooks into the request pipeline so the latest response is always ready, no manual copy-paste
- 6 languages — TypeScript · Dart · Go · Kotlin · Swift · Java
- Live generation — types regenerate as you adjust options or edit the JSON
- Per-language options — null safety, readonly, serialization frameworks, package names, and more
- Persistent preferences — remembers your last language, class name, and options
- Tab-aware — switching between
.voidfiles instantly loads the correct response - Edit JSON panel — manually paste or edit the JSON if needed
Installation
- Download the latest
.zipfrom Releases - In Voiden: Extensions → ⋯ → Install from file → select the
.zip - The Types tab appears in the right sidebar
Usage
- Run any HTTP request that returns JSON
- Open the Types tab in the right sidebar
- Select your target language and set a class name
- Click Options to configure language-specific settings
- Generated code appears instantly — click the copy button to grab it
Language Options
| Language | Options |
|---|---|
| TypeScript | Readonly fields, Types-only (no runtime code), Prefer unions |
| Dart | Null safety, copyWith method, Freezed support |
| Go | Package name |
| Kotlin | @Serializable (kotlinx), Package name |
| Swift | Structs (vs classes), Explicit casts |
| Java | Getters/setters, Package name |
Development
Prerequisites
- Node.js 18+
- A local checkout of the Voiden app (for the
@voiden/sdktype definitions)
Setup
npm install
Build
npm run build # compiles src/ → dist/main.js
npm run zip # packages dist/main.js + manifest.json → dist/type-generator.zip
Project structure
src/
plugin.ts # SDK entry point — pipeline hooks, sidebar registration
ui/
GenerateTab.tsx # Sidebar UI component
generator/
quicktypeRunner.ts # quicktype invocation wrapper
languageConfig.ts # Per-language renderer options
types/
pluginTypes.ts # Shared TypeScript types
build.mjs # Vite build script with Voiden shim plugin
zip.mjs # Packages dist/ into an installable .zip
manifest.json # Plugin metadata and permissions
How it works
The plugin registers two pipeline hooks:
- PreProcessing — captures the request URL, method, and the active tab ID before the request is sent
- PostProcessing — captures the response body and stores it keyed by tab ID
When the sidebar tab is open, it subscribes to incoming responses and to tab:changed events. On a tab switch it immediately loads (or clears) the stored response for that tab, then passes the JSON through quicktype to produce typed output.
Permissions
| Permission | Why |
|---|---|
events | Listens to tab:changed to track which .void file is active |
requestPipeline | Hooks into PreProcessing + PostProcessing to capture request/response data |
sidebar | Registers the "Types" tab in the right sidebar |
Contributing
Pull requests are welcome. For significant changes, please open an issue first to discuss the approach.
- Fork the repo
- Create a feature branch:
git checkout -b my-feature - Commit your changes
- Open a pull request
License
MIT — see LICENSE