-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HTTP interceptor strict JSON validation #106
Comments
Migration guideIn order to keep compatibility with client code bases with minimal changes, I'm proposing a new utility typed exported by
|
### Features - [#zimic] Added the utility types `JSONCompatible` and `JSONSerialized`. - [#zimic] Added strict JSON validation to interceptor schemas. Since this is a breaking change, see the [Migration guide](https://github.com/diego-aquino/zimic/issues/106#issuecomment-2002623779) to enable the strict validation! Closes #106.
) ### Fixes - [#zimic] Added support to declare HTTP schema bodies using `interface`. This became no longer possible after #106. Zimic now is less strict about the validation of JSON bodies in HTTP schemas, due to [limitations in TypeScript](microsoft/TypeScript#15300). Due to the type error message being somewhat cryptic ("Index signature is missing in type X"), we believe allowing `type` and `interface` and serializing JSON body types before use is a good compromise. - Deprecated `HttpResponseSchemaByStatusCode.Strict` in favor of `HttpResponseSchemaByStatusCode`. - Added `HttpFormDataSerialized` and updated the typegen code to wrap this type around raw schemas. This is to ensure that Zimic correctly understands schemas not strictly correct, as sometimes happens for search params and headers. ### Development - [#zimic] Updated `tsconfig.json` to ignore `interceptor/*.d.ts` and `http/*.d.ts` in type checking and linting. - [#eslint] Disabled the rule "no-redeclare", which is already enforced by the TypeScript copiler. Closes #350.
As of v0.2.x, JSON bodies are not completely statically validated. This allows defining bodies using non-JSON values, such as
Date
andError
.This issue means to add strict JSON validation to interceptor declarations. Unfortunately, it won't be possible to declare body types using raw TypeScript
interface
's, because they do not have automatic index signatures astype
's. See microsoft/TypeScript#15300 for more information.microsoft/TypeScript#1897 proposes a native
json
type, which might help in the future. Right now, though, theinterface
vstype
problem seems unsolvable natively.The text was updated successfully, but these errors were encountered: