Skip to content

Latest commit

 

History

History
11 lines (7 loc) · 497 Bytes

prefer-openapi-last.md

File metadata and controls

11 lines (7 loc) · 497 Bytes

Prefers that the .openapi() method be the last method (prefer-openapi-last)

Prefers that the .openapi() method be the last method in a Zod Schema chain. This is done mainly out of consistency but also because there are some methods that can override the .openapi() method. eg. pick, omit

A simple example

const NameSchema = z.string().openapi({ example: 'Fred' }).length(5); // ❌ error

const NameSchema = z.string().length(5).openapi({ example: 'Fred' }); // ✅ correct