Commit 8be955f
authored
feat(zod): place null at the end when converting ZodNullable (#672)
Currently, the Zod converter transforms nullable types into schemas in the order of [null, json]. Because null appears as the first value in the array, UIs like Swagger or Scalar display null as the example value.
```json
{
"nullableProperty": null
}
```
Although it is possible to customize the example using oz.openapi, I believe it is more reasonable to show a non-null default value as the example.
```json
{
"nullableProperty": "non-null example"
}
```
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit
- **Refactor**
- Updated the order of types in nullable schemas to prioritize the main type before null.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->1 parent e05ad8a commit 8be955f
2 files changed
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
286 | 286 | | |
287 | 287 | | |
288 | 288 | | |
289 | | - | |
| 289 | + | |
290 | 290 | | |
291 | 291 | | |
292 | 292 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
610 | 610 | | |
611 | 611 | | |
612 | 612 | | |
613 | | - | |
| 613 | + | |
614 | 614 | | |
615 | 615 | | |
616 | 616 | | |
| |||
0 commit comments