Schema validation
Often times, your API Definition may drift from your server implementation. If you are concerned about this, you can toggle on schema validation in the SDKs.
Itβs worth nothing that this feature is optional for duck-typed languages like Python, TypeScript, and Ruby. However, for strongly typed languages like Go, Java, and C# this is always on.
TypeScript
The TypeScript SDK contains a serialization
folder when generated.
Inside of this serialization folder, are zod-like schemas for every generated model.
For example, if you had a Movie
schema defined in your API Definition and
wanted to validate the schema, you could simply do:
Fern allows you to generate the SDK in three different modes:
- No validation: In this mode, there is no serialization layer generated. Types exist at compile time, but they are completely removed at runtime.
- Request validation only: In this mode, the serialization layer is only used to validate requests. Responses are always returned even if they do not match the schema. This is the recommended mode for public API companies.
- Full validation: In this mode, the serialization layer is used to validate both requests and responses. This is the recommended mode for internal SDKs so that you can catch issues as soon as possible.