Skip to content

Added the zod schemas for all the API methods#118

Open
cb-alish wants to merge 7 commits into
experimental/zod-validationfrom
experimental/zod-schemas
Open

Added the zod schemas for all the API methods#118
cb-alish wants to merge 7 commits into
experimental/zod-validationfrom
experimental/zod-schemas

Conversation

@cb-alish
Copy link
Copy Markdown
Collaborator

@cb-alish cb-alish commented May 6, 2026

Description

All the necessary schemas for the zod validation.

@snyk-io
Copy link
Copy Markdown

snyk-io Bot commented May 6, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Comment thread src/validation/addon/copy.validation.ts Outdated
@@ -0,0 +1,11 @@
// Generated Zod validator: Addon.copy
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest generating all the schemas in the src/schema directory with the <resource>.schema.ts file name. This keeps it consistent with the naming pattern, and eventually allows us to add a export type Addon = z.infer<Addon> in the same file.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @cb-srinaths, I have addressed this. Would you please re-review once?

Comment thread src/validation/addon/copy.validation.ts Outdated
// Do not edit manually – regenerate via sdk-generator

import { z } from 'zod';
const copyAddonBodySchema = z.looseObject({
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest pascal case for these schema declarations as our types are pascal cased.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @cb-srinaths, Yes that makes sense. I have changed this to pascal case.

…r output

Replace src/validation/<resource>/<action>.validation.ts with flat
src/schema/<resource_snake>.schema.ts (and shared.schema.ts), matching the
sdk-generator VALIDATOR_ZOD layout. Each file aggregates all body/query
schemas for that resource and exports z.infer-derived types per action.

- Point validationLoader at ./schema/<resource_snake>.schema.js (CJS build).
- Resolve exports using PascalCase body const names aligned with
  ZodNamingStrategy.bodySchemaName in sdk-generator.

Regenerated from the same OpenAPI spec via sdk-generator; requires the paired
validator emitter changes in sdk-generator.
@cb-alish cb-alish force-pushed the experimental/zod-schemas branch from 4246a8b to c14c44c Compare May 11, 2026 05:25
cb-alish and others added 4 commits May 11, 2026 12:05
…o API call time

Replace manual createRequire-based module resolution with native dynamic import(),
allowing TypeScript compiler to handle ESM/CJS transpilation automatically. Schema
loading is now deferred to API call time (lazy), preserving synchronous SDK
initialization while maintaining validation functionality in both module systems.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Node.js automatically caches imported modules, making the manual Map-based
cache redundant. This simplifies the code while maintaining the same
performance characteristics.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants