Skip to content

Add skipValidation option for type-safe APIs without runtime validation#6

Merged
mast1ff merged 4 commits into
mainfrom
copilot/add-suggestions-only-option
Dec 21, 2025
Merged

Add skipValidation option for type-safe APIs without runtime validation#6
mast1ff merged 4 commits into
mainfrom
copilot/add-suggestions-only-option

Conversation

Copilot AI commented Dec 20, 2025

Copy link
Copy Markdown
Contributor

Validation overhead can impact performance in production, and unexpected API response changes can break deployed applications. This PR adds a skipValidation option to use schemas purely for TypeScript type inference without runtime validation.

Changes

  • Configuration: Added skipValidation to TypeFetcherConfig (global) and EndpointSchema (per-endpoint)
  • Validation logic: Modified TypeFetcher.request() to skip validation when configured, with endpoint-level overriding global setting
  • Type safety preserved: Schema-based type inference remains intact regardless of validation setting

Usage

// Global configuration
const client = new TypeFetcher({
  baseURL: "https://api.example.com",
  skipValidation: true  // Types inferred, validation skipped
});

// Per-endpoint override
const api = client
  .addEndpoint("GET", "/users", {
    response: z.array(UserSchema),
    skipValidation: true  // Skip for this endpoint
  })
  .addEndpoint("POST", "/users", {
    body: CreateUserSchema,
    response: UserSchema
    // Validates if global default is false
  });

The feature enables environment-based configuration (skip in production, validate in dev) and graceful handling of evolving API schemas without breaking type safety.

Original prompt

This section details on the original issue you should resolve

<issue_title>Add "Suggestions Only" Option</issue_title>
<issue_description>Is your feature request related to a problem? Please describe.
Currently, validation can often impact performance. Additionally, if the data type of an API response changes unexpectedly, it could cause errors in applications that are already in production.

Describe the solution you'd like
We'd like to introduce an option to use the schema solely for response type inference, without performing actual validation. This feature would help us avoid validation errors in responses.

Describe alternatives you've considered
Since this is a core system feature, we haven't considered any alternatives.</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits December 20, 2025 17:55
Co-authored-by: mast1ff <59213579+mast1ff@users.noreply.github.com>
Co-authored-by: mast1ff <59213579+mast1ff@users.noreply.github.com>
Co-authored-by: mast1ff <59213579+mast1ff@users.noreply.github.com>
Copilot AI changed the title [WIP] Add 'Suggestions Only' option for response type inference Add skipValidation option for type-safe APIs without runtime validation Dec 20, 2025
Copilot AI requested a review from mast1ff December 20, 2025 18:02
@mast1ff mast1ff marked this pull request as ready for review December 21, 2025 01:10
@mast1ff mast1ff merged commit ba22342 into main Dec 21, 2025
2 checks passed
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.

Add "Suggestions Only" Option

2 participants