Menu

1 / 2

3 Breaking Differences Between OpenAPI 3.0 and 3.1 That Trip Up TypeScript & Zod Codegen

DEV Community: typescript·Jason Y. (dev_in_the_fog)·11 days ago
#gv2ImkYM
#devtotypescript#devto#dev#openapi#json
Reading 0:00
15s threshold

Upgrading FastAPI or Springdoc to emit OpenAPI 3.1.0 often breaks existing TypeScript and Zod generators silently—fields start typing as unknown , or runtime validation rejects valid null payloads. Because OpenAPI 3.1 aligned directly with JSON Schema Draft 2020-12, three schema constructs changed shape.

1. nullable: true Was Replaced by Type Arrays

OpenAPI 3.0 used { "type": "string", "nullable": true } . OpenAPI 3.1 drops nullable in favor of standard JSON Schema { "type": ["string", "null"] } (or anyOf ). Older 3.0-only generators miss the array form and omit .nullable() in generated Zod schemas.

2. exclusiveMinimum / exclusiveMaximum Changed From Boolean to Number

In 3.0, minimum: 0 paired with exclusiveMinimum: true . In 3.1, exclusiveMinimum: 0 carries the numeric bound directly. Validators expecting booleans either ignore the bound or produce NaN checks.

3.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.