Conversation
|
@waji-io is attempting to deploy a commit to the sorikairox's projects Team on Vercel. A member of the Team first needs to authorize it. |
📝 WalkthroughWalkthroughThe documentation for Danet's Zod OpenAPI integration was updated to remove outdated prerequisites about extending Zod with external packages, replace SwaggerModule explanation with modern decorator-based validation examples, and add a new section documenting Zod v4 support with relevant utility methods. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/zod/openapi.md`:
- Around line 19-27: The examples use z.object and z.infer but never import z,
so add the missing import (e.g., "import { z } from 'zod';") at the top of each
TypeScript snippet that defines CreateTodoSchema (the snippets referencing
z.object and type CreateTodoSchema = z.infer<...>) so the examples are
copy-paste runnable; apply the same change to the second example as noted (lines
showing the same CreateTodoSchema usage).
- Line 7: The intro warning contains duplicated wording "familiar with are
familiar with"; update the sentence in src/zod/openapi.md (the intro warning
line) to read cleanly, e.g. "This page assumes that you are familiar with
Danet's controllers. If you are not, please read the
[Controllers](/overview/controllers) page first." — remove the extra "are
familiar with" and ensure spacing and punctuation are correct.
- Around line 70-80: The heading level jumps from "# ZOD Version 4 Support" to
"### z.fromJSONSchema()", causing an MD001 lint error; change the "###
z.fromJSONSchema()" heading to "## z.fromJSONSchema()" so it is a second-level
heading like "## z.toJSONSchema()", ensuring consistent heading hierarchy and
keeping "## z.toJSONSchema()" unchanged.
- Around line 72-108: The docs incorrectly claim `@danet/zod`@^0.1.0 (and thus Zod
v4) is supported and show examples for z.fromJSONSchema() / z.toJSONSchema();
update the section to reflect reality by removing or correcting the Zod v4 claim
and the non-working examples: state that current `@danet/zod` (latest 0.0.9)
targets Zod v3 (≈3.23.8), remove or replace the z.fromJSONSchema() example
(since fromJSONSchema is not available in Zod v3 and is experimental in Zod v4),
and either remove the z.toJSONSchema() example or rewrite it to demonstrate only
features supported by Zod v3; also remove the version string `@danet/zod`@^0.1.0
or change it to the actual released version and add a short note indicating that
Zod v4 support is not yet available.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
|
|
||
| ::: danger | ||
| The SwaggerModule is currently in Alpha, maaaany features are missing. If something you need is not here yet, [please fill an issue/feature request](https://github.com/Savory/Danet-Swagger/issues) | ||
| This page assumes that you are familiar with are familiar with Danet's controllers. If you are not, please read the [Controllers](/overview/controllers) page first. |
There was a problem hiding this comment.
Fix duplicated wording in the intro warning.
There’s a typo: “familiar with are familiar with”.
Suggested fix
-This page assumes that you are familiar with are familiar with Danet's controllers. If you are not, please read the [Controllers](/overview/controllers) page first.
+This page assumes that you are familiar with Danet's controllers. If you are not, please read the [Controllers](/overview/controllers) page first.📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| This page assumes that you are familiar with are familiar with Danet's controllers. If you are not, please read the [Controllers](/overview/controllers) page first. | |
| This page assumes that you are familiar with Danet's controllers. If you are not, please read the [Controllers](/overview/controllers) page first. |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/zod/openapi.md` at line 7, The intro warning contains duplicated wording
"familiar with are familiar with"; update the sentence in src/zod/openapi.md
(the intro warning line) to read cleanly, e.g. "This page assumes that you are
familiar with Danet's controllers. If you are not, please read the
[Controllers](/overview/controllers) page first." — remove the extra "are
familiar with" and ensure spacing and punctuation are correct.
| import { Controller, Post } from '@danet/core'; | ||
| import { Body } from '@danet/zod'; | ||
|
|
||
| Danet Swagger module uses the following versions: | ||
| const CreateTodoSchema = z.object({ | ||
| title: z.string(), | ||
| description: z.string(), | ||
| }); | ||
|
|
||
| ``` | ||
| "zod": "npm:zod@3.23.8", | ||
| "zod-openapi": "npm:@anatine/zod-openapi@2.2.6" | ||
| ``` | ||
| type CreateTodoSchema = z.infer<typeof CreateTodoSchema>; |
There was a problem hiding this comment.
Add missing z import in both TypeScript examples.
Both snippets use z.object / z.infer but don’t import z, so the examples aren’t copy-paste runnable.
Suggested fix
import { Controller, Post } from '@danet/core';
import { Body } from '@danet/zod';
+import { z } from 'zod'; import { Controller, Get } from '@danet/core';
import { Query } from '@danet/zod';
+import { z } from 'zod';Also applies to: 45-53
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/zod/openapi.md` around lines 19 - 27, The examples use z.object and
z.infer but never import z, so add the missing import (e.g., "import { z } from
'zod';") at the top of each TypeScript snippet that defines CreateTodoSchema
(the snippets referencing z.object and type CreateTodoSchema = z.infer<...>) so
the examples are copy-paste runnable; apply the same change to the second
example as noted (lines showing the same CreateTodoSchema usage).
| # ZOD Version 4 Support | ||
|
|
||
| Danet now supports Zod version 4 `@danet/zod@^0.1.0`, which is a major upgrade from version 3. | ||
|
|
||
| ::: note | ||
| All previous versions of `@danet/zod` support only Zod version 3. | ||
| ::: | ||
|
|
||
| One of the new features is the ability to generate JSON Schema from Zod schemas and vice versa. | ||
|
|
||
| ### z.fromJSONSchema() |
There was a problem hiding this comment.
Fix heading-level jump to satisfy markdown lint.
Line 80 jumps to ### right after a # heading, which violates MD001.
Suggested fix
-### z.fromJSONSchema()
+## z.fromJSONSchema()(And keep ## z.toJSONSchema() at Line 97, which then matches correctly.)
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| # ZOD Version 4 Support | |
| Danet now supports Zod version 4 `@danet/zod@^0.1.0`, which is a major upgrade from version 3. | |
| ::: note | |
| All previous versions of `@danet/zod` support only Zod version 3. | |
| ::: | |
| One of the new features is the ability to generate JSON Schema from Zod schemas and vice versa. | |
| ### z.fromJSONSchema() | |
| # ZOD Version 4 Support | |
| Danet now supports Zod version 4 `@danet/zod@^0.1.0`, which is a major upgrade from version 3. | |
| ::: note | |
| All previous versions of `@danet/zod` support only Zod version 3. | |
| ::: | |
| One of the new features is the ability to generate JSON Schema from Zod schemas and vice versa. | |
| ## z.fromJSONSchema() |
🧰 Tools
🪛 markdownlint-cli2 (0.22.0)
[warning] 80-80: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3
(MD001, heading-increment)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/zod/openapi.md` around lines 70 - 80, The heading level jumps from "# ZOD
Version 4 Support" to "### z.fromJSONSchema()", causing an MD001 lint error;
change the "### z.fromJSONSchema()" heading to "## z.fromJSONSchema()" so it is
a second-level heading like "## z.toJSONSchema()", ensuring consistent heading
hierarchy and keeping "## z.toJSONSchema()" unchanged.
| Danet now supports Zod version 4 `@danet/zod@^0.1.0`, which is a major upgrade from version 3. | ||
|
|
||
| ::: note | ||
| All previous versions of `@danet/zod` support only Zod version 3. | ||
| ::: | ||
|
|
||
| One of the new features is the ability to generate JSON Schema from Zod schemas and vice versa. | ||
|
|
||
| ### z.fromJSONSchema() | ||
|
|
||
| ```ts | ||
| @ReturnedSchema(TodoSchema) | ||
| @Get(':id') | ||
| async getById(@Param('id') id: string): Todo { | ||
| return this.todoService.getById(id); | ||
| } | ||
| import { z } from 'zod'; | ||
|
|
||
| const jsonSchema = { | ||
| type: 'object', | ||
| properties: { | ||
| name: { type: 'string' }, | ||
| age: { type: 'number' } | ||
| }, | ||
| required: ['name', 'age'] | ||
| }; | ||
|
|
||
| const zodSchema = z.fromJSONSchema(jsonSchema); | ||
| ``` | ||
|
|
||
| If your route returns an array, pass `true` as the second argument of `ReturnedSchema` : | ||
|
|
||
| ### z.toJSONSchema() | ||
|
|
||
| ```ts | ||
| @ReturnedSchema(TodoSchema, true) | ||
| @Get() | ||
| async getTodos(): Todo[] { | ||
| return this.todoService.getAll(); | ||
| } | ||
| ``` No newline at end of file | ||
| import { z } from 'zod'; | ||
|
|
||
| const zodSchema = z.object({ | ||
| name: z.string(), | ||
| age: z.number() | ||
| }); | ||
|
|
||
| const jsonSchema = z.toJSONSchema(zodSchema); | ||
| ``` |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
For Zod v4, are z.fromJSONSchema()andz.toJSONSchema()official public APIs? Also verify whether@danet/zod@^0.1.0 is documented as the version that adds Zod v4 support.
💡 Result:
For Zod v4, z.toJSONSchema is an official public API, introduced as a stable first-party feature in the release notes and documented in the JSON Schema guide. z.fromJSONSchema is also an official API but marked as experimental and not part of the stable API, likely to change in future releases, as stated in the official JSON Schema documentation. @danet/zod@^0.1.0 is not documented as the version adding Zod v4 support. The latest version is 0.0.9 (published ~5 months ago), and Danet documentation specifies compatibility with Zod 3.23.8. No changelog, release notes, or documentation mention Zod v4 support in any version, including around 0.1.0.
Citations:
- 1: https://v4.zod.dev/json-schema
- 2: https://v4.zod.dev/v4?id=json-schema-conversion
- 3: [v4] Feature Request: Add
fromJSONSchemamethod to construct Zod schemas from JSON Schema colinhacks/zod#5233 - 4: https://zod.dev/json-schema
- 5: https://jsr.io/%40danet/zod
- 6: https://danet.land/zod/openapi.html
Remove or correct section claiming Zod v4 support—it does not exist in @danet/zod.
The documentation claims @danet/zod@^0.1.0 adds Zod v4 support, but the latest published version is 0.0.9 (released ~5 months ago) and only supports Zod 3.23.8. No version of @danet/zod supports Zod v4. Additionally, z.fromJSONSchema() is marked experimental in Zod v4 and not part of the stable API. The code examples shown cannot execute with the current package. Either remove this section or update it to reflect actual Zod 3 capabilities.
🧰 Tools
🪛 markdownlint-cli2 (0.22.0)
[warning] 80-80: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3
(MD001, heading-increment)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/zod/openapi.md` around lines 72 - 108, The docs incorrectly claim
`@danet/zod`@^0.1.0 (and thus Zod v4) is supported and show examples for
z.fromJSONSchema() / z.toJSONSchema(); update the section to reflect reality by
removing or correcting the Zod v4 claim and the non-working examples: state that
current `@danet/zod` (latest 0.0.9) targets Zod v3 (≈3.23.8), remove or replace
the z.fromJSONSchema() example (since fromJSONSchema is not available in Zod v3
and is experimental in Zod v4), and either remove the z.toJSONSchema() example
or rewrite it to demonstrate only features supported by Zod v3; also remove the
version string `@danet/zod`@^0.1.0 or change it to the actual released version and
add a short note indicating that Zod v4 support is not yet available.
Summary by CodeRabbit