Skip to content

Conversation

lambdank
Copy link
Contributor

@lambdank lambdank commented Sep 22, 2025

A humble attempt to solve the issue described in #1900.
Please let me know, if I can do anything more to help. :)

Summary by CodeRabbit

  • Style
    • Generated code now consistently quotes object property names in getter declarations for certain schema cases.
    • This only affects emitted source text/signatures; runtime behavior and public APIs remain unchanged.
    • Expect minor diffs in generated output; no action required from consumers.

Copy link

changeset-bot bot commented Sep 22, 2025

🦋 Changeset detected

Latest commit: 10f4b61

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 21 packages
Name Type
@kubb/plugin-zod Patch
@kubb/mcp Patch
@kubb/plugin-client Patch
@kubb/plugin-mcp Patch
@kubb/plugin-react-query Patch
@kubb/plugin-solid-query Patch
@kubb/plugin-svelte-query Patch
@kubb/plugin-swr Patch
@kubb/plugin-vue-query Patch
@kubb/cli Patch
@kubb/core Patch
@kubb/oas Patch
@kubb/parser-ts Patch
@kubb/plugin-cypress Patch
@kubb/plugin-faker Patch
@kubb/plugin-msw Patch
@kubb/plugin-oas Patch
@kubb/plugin-redoc Patch
@kubb/plugin-ts Patch
@kubb/react Patch
kubb Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

coderabbitai bot commented Sep 22, 2025

Walkthrough

Updated code generation in packages/plugin-zod/src/parser.ts to emit quoted getter method names (get "name"()) for object properties when producing v4 code with a ref, across nullish, optional, nullable, and default branches. No exported API signatures changed.

Changes

Cohort / File(s) Summary
Getter name quoting update
packages/plugin-zod/src/parser.ts
Adjusts emitted getter method signatures to quote property names (get "name"()) across four object property branches (nullish, optional, nullable, default) for v4 with ref. Change affects only the generated code string content; runtime logic and public API remain unchanged.
Changeset entry
.changeset/legal-zebras-think.md
Adds a changeset noting the patch release for @kubb/plugin-zod and documents that recursive fields now use string literals. No exported/public entity signature changes.

Sequence Diagram(s)

(omitted — changes are a localized code-generation formatting update; control flow is unchanged)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I nibble code with careful bite,
Quoting names to make them right.
get "carrot"() now clear and bright—
A tiny hop, a tidy sight.
In fields of types, I dance with glee 🥕✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly and accurately summarizes the main change — recursive Zod fields now use string literal names — and it references the related issue (#1900), so it is specific and relevant to the changeset. It is concise and understandable for reviewers scanning history.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 56a75eb and 2c8882b.

📒 Files selected for processing (2)
  • .changeset/legal-zebras-think.md (1 hunks)
  • packages/plugin-zod/src/parser.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .changeset/legal-zebras-think.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/plugin-zod/src/parser.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Build and test (windows-latest, 20)
  • GitHub Check: Build and test (ubuntu-latest, 20)
  • GitHub Check: Typecheck

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@dosubot dosubot bot added @kubb/plugin-zod bug Something isn't working labels Sep 22, 2025
Copy link

dosubot bot commented Sep 22, 2025

Related Documentation

Checked 1 published document(s). No updates required.

You have 2 draft document(s). Publish docs to keep them always up-to-date

How did I do? Any feedback?  Join Discord

Copy link

pkg-pr-new bot commented Sep 22, 2025

More templates

@kubb/cli

npm i https://pkg.pr.new/kubb-labs/kubb/@kubb/cli@1901

@kubb/core

npm i https://pkg.pr.new/kubb-labs/kubb/@kubb/core@1901

kubb

npm i https://pkg.pr.new/kubb-labs/kubb@1901

@kubb/mcp

npm i https://pkg.pr.new/kubb-labs/kubb/@kubb/mcp@1901

@kubb/oas

npm i https://pkg.pr.new/kubb-labs/kubb/@kubb/oas@1901

@kubb/parser-ts

npm i https://pkg.pr.new/kubb-labs/kubb/@kubb/parser-ts@1901

@kubb/plugin-client

npm i https://pkg.pr.new/kubb-labs/kubb/@kubb/plugin-client@1901

@kubb/plugin-cypress

npm i https://pkg.pr.new/kubb-labs/kubb/@kubb/plugin-cypress@1901

@kubb/plugin-faker

npm i https://pkg.pr.new/kubb-labs/kubb/@kubb/plugin-faker@1901

@kubb/plugin-mcp

npm i https://pkg.pr.new/kubb-labs/kubb/@kubb/plugin-mcp@1901

@kubb/plugin-msw

npm i https://pkg.pr.new/kubb-labs/kubb/@kubb/plugin-msw@1901

@kubb/plugin-oas

npm i https://pkg.pr.new/kubb-labs/kubb/@kubb/plugin-oas@1901

@kubb/plugin-react-query

npm i https://pkg.pr.new/kubb-labs/kubb/@kubb/plugin-react-query@1901

@kubb/plugin-redoc

npm i https://pkg.pr.new/kubb-labs/kubb/@kubb/plugin-redoc@1901

@kubb/plugin-solid-query

npm i https://pkg.pr.new/kubb-labs/kubb/@kubb/plugin-solid-query@1901

@kubb/plugin-svelte-query

npm i https://pkg.pr.new/kubb-labs/kubb/@kubb/plugin-svelte-query@1901

@kubb/plugin-swr

npm i https://pkg.pr.new/kubb-labs/kubb/@kubb/plugin-swr@1901

@kubb/plugin-ts

npm i https://pkg.pr.new/kubb-labs/kubb/@kubb/plugin-ts@1901

@kubb/plugin-vue-query

npm i https://pkg.pr.new/kubb-labs/kubb/@kubb/plugin-vue-query@1901

@kubb/plugin-zod

npm i https://pkg.pr.new/kubb-labs/kubb/@kubb/plugin-zod@1901

@kubb/react

npm i https://pkg.pr.new/kubb-labs/kubb/@kubb/react@1901

unplugin-kubb

npm i https://pkg.pr.new/kubb-labs/kubb/unplugin-kubb@1901

commit: 10f4b61

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/plugin-zod/src/parser.ts (1)

370-373: Escape the property name to handle embedded quotes/backslashes

Use the existing transformers.stringify to safely emit the string literal; avoids edge cases when name contains " or .

Apply this diff:

-            return `get "${name}"(){
+            return `get ${transformers.stringify(name)}(){
               return ${zodKeywordMapper.nullish(objectValue)}
             }`

-            return `get "${name}"(){
+            return `get ${transformers.stringify(name)}(){
               return ${zodKeywordMapper.optional(objectValue)}
             }`

-            return `get "${name}"(){
+            return `get ${transformers.stringify(name)}(){
               return ${zodKeywordMapper.nullable(objectValue)}
             }`

-          return `get "${name}"(){
+          return `get ${transformers.stringify(name)}(){
               return ${objectValue}
             }`

Also applies to: 377-380, 384-387, 389-392

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 738f13c and 56a75eb.

📒 Files selected for processing (1)
  • packages/plugin-zod/src/parser.ts (1 hunks)
🔇 Additional comments (1)
packages/plugin-zod/src/parser.ts (1)

370-373: Quoting getter names is the right call for non-identifier keys

This prevents failures on keys like default, 123, or foo-bar and aligns with the intent of #1900. Looks good.

Also applies to: 377-380, 384-387, 389-392

Copy link

codecov bot commented Sep 22, 2025

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.11%. Comparing base (a4d11d3) to head (0b66670).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
packages/plugin-zod/src/parser.ts 0.00% 4 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1901   +/-   ##
=======================================
  Coverage   84.11%   84.11%           
=======================================
  Files         184      184           
  Lines       13500    13500           
  Branches     2694     2694           
=======================================
  Hits        11356    11356           
  Misses       2116     2116           
  Partials       28       28           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@stijnvanhulle stijnvanhulle merged commit 6730096 into kubb-labs:main Sep 22, 2025
9 checks passed
Copy link

dosubot bot commented Sep 22, 2025

Documentation Updates

Checked 1 published document(s). No updates required.

You have 2 draft document(s). Publish docs to keep them always up-to-date

How did I do? Any feedback?  Join Discord

@github-actions github-actions bot mentioned this pull request Sep 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working @kubb/plugin-zod
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants