-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: support custom brands handling in Documentation and Integration (…
…#1750) Based on #1470 and thanks to #1730 This will be a feature in v19. I'd like to keep changes of 19.0.0 smaller, making it easier to migrate. Thus, I'm going to separate breaking changes from features and release this as 19.1.0. This will be the interface: ```ts import { z } from "zod"; import { Documentation, Integration } from "express-zod-api"; const myBrand = Symbol("MamaToldMeImSpecial"); // I highly recommend using symbols for this purpose const myBrandedSchema = z.string().brand(myBrand); new Documentation({ /* config, routing, title, version */ brandHandling: { [myBrand]: ( schema: typeof myBrandedSchema, // you should assign type yourself { next, path, method, isResponse }, // handle a nested schema using next() ) => { const defaultResult = next(schema.unwrap()); // { type: string } return { summary: "Special type of data" }; }, }, }); import ts from "typescript"; const { factory: f } = ts; new Integration({ /* routing */ brandHandling: { [myBrand]: ( schema: typeof myBrandedSchema, // you should assign type yourself { next, isResponse, serializer }, // handle a nested schema using next() ) => f.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword), }, }); ```
- Loading branch information
Showing
19 changed files
with
856 additions
and
755 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.