Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@devup-api/zod

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@devup-api/zod

latest
npmnpm
Version
0.1.3
Version published
Weekly downloads
16
166.67%
Maintainers
1
Weekly downloads
 
Created
Source

@devup-api/zod

Zod schema generation for devup-api. This package provides runtime validation schemas generated from your OpenAPI specification.

Installation

npm install @devup-api/zod zod

Usage

This package works in conjunction with devup-api bundler plugins. The Zod schemas are provided as virtual files by the bundler plugins.

With Vite

// vite.config.ts
import { defineConfig } from 'vite'
import devupApi from '@devup-api/vite-plugin'

export default defineConfig({
  plugins: [devupApi()],
})

Using the Schemas

import { schemas } from '@devup-api/zod'

// Access generated Zod schemas
const userSchema = schemas.response.User
const createUserSchema = schemas.request.CreateUserRequest
const errorSchema = schemas.error.ApiError

// Validate data
const result = userSchema.safeParse(data)
if (result.success) {
  console.log('Valid user:', result.data)
} else {
  console.error('Validation errors:', result.error)
}

Type Inference

import { schemas, type SchemaTypes } from '@devup-api/zod'
import { z } from 'zod'

// Infer types from schemas
type User = z.infer<typeof schemas.response.User>
type CreateUserRequest = z.infer<typeof schemas.request.CreateUserRequest>

// Or use the pre-defined types
type User = SchemaTypes['response']['User']

How It Works

  • Your bundler plugin reads the OpenAPI specification
  • Zod schemas are generated from the OpenAPI schemas
  • When you import from @devup-api/zod, the bundler provides the generated schemas as a virtual file
  • You get fully typed, runtime-validated schemas

Cold Typing vs Boild Typing

Similar to @devup-api/fetch, this package uses a two-phase typing system:

  • Cold Typing: Before the build runs, schemas are typed as any to prevent type errors
  • Boild Typing: After the build runs, full type safety is enforced

License

Apache 2.0

FAQs

Package last updated on 04 Apr 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts