https://github.com/guimauvedigital/zodable
Generate zod schemas from Kotlin data classes.
https://github.com/guimauvedigital/zodable
kotlin ksp ts zod
Last synced: about 2 months ago
JSON representation
Generate zod schemas from Kotlin data classes.
- Host: GitHub
- URL: https://github.com/guimauvedigital/zodable
- Owner: guimauvedigital
- License: gpl-3.0
- Created: 2025-03-16T13:28:52.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2025-03-16T14:45:46.000Z (about 2 months ago)
- Last Synced: 2025-03-16T15:27:50.415Z (about 2 months ago)
- Topics: kotlin, ksp, ts, zod
- Language: Kotlin
- Homepage:
- Size: 76.2 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# zodable
Generate zod schemas from Kotlin data classes.
## Install the plugin
Add the following to your `build.gradle.kts`:
```kotlin
plugins {
id("digital.guimauve.zodable") version "1.0.1"
id("com.google.devtools.ksp") version "2.1.10-1.0.30" // Adjust version as needed
}
```And that's all! The plugin is ready to use.
## Usage
Add the `@Zodable` annotation to your data classes. The plugin will generate a zod schema for each annotated class.
```kotlin
@Zodable
data class User(
val id: Int,
val name: String
)
```The generated schema will look like this:
```typescript
import {z} from "zod"export const UserSchema = z.object({
id: z.number().int(),
name: z.string()
})
export type User = z.infer
```Generated schemas can be found in `build/zodable`. It is a ready to use npm package.