Skip to content

Drop example, object-based examples and getExamples()#2842

Merged
RobinTail merged 4 commits intomake-v25from
drop-example-and-object-examples
Jul 25, 2025
Merged

Drop example, object-based examples and getExamples()#2842
RobinTail merged 4 commits intomake-v25from
drop-example-and-object-examples

Conversation

@RobinTail
Copy link
Copy Markdown
Owner

@RobinTail RobinTail commented Jul 25, 2025

Due to #2841

Summary by CodeRabbit

  • Breaking Changes
    • Removed support for specifying examples via the example property in .meta() and as an object under the examples property. Examples must now be provided via the .example() method or as an array under examples in .meta().
    • The getExamples() helper method has been removed; access examples directly via .meta().examples or globalRegistry.get().examples.
  • Other Updates
    • Updated documentation and internal handling to reflect the new approach for managing examples.
    • Adjusted the Middleware class: when no input schema is defined, the input argument is now typed as unknown.

@RobinTail RobinTail added this to the v25 milestone Jul 25, 2025
@RobinTail RobinTail added documentation Improvements or additions to documentation refactoring The better way to achieve the same result breaking Backward incompatible changes labels Jul 25, 2025
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jul 25, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This change removes the getExamples helper function and all legacy support for deprecated example metadata forms. All code now accesses example arrays directly from the global Zod registry. Related tests and type definitions for legacy example metadata are deleted, and the changelog documents these breaking changes and the new preferred usage patterns.

Changes

File(s) Change Summary
CHANGELOG.md Documents breaking changes: removal of getExamples, legacy metadata support, and new usage notes.
express-zod-api/src/metadata.ts Removes getExamples function and related imports.
express-zod-api/src/index.ts Removes export of getExamples.
express-zod-api/tests/metadata.spec.ts Deletes all tests related to getExamples and legacy metadata; keeps only getBrand tests.
express-zod-api/src/endpoint.ts Switches from getExamples to direct registry access for examples.
express-zod-api/src/result-handler.ts Replaces getExamples calls with direct registry example access and updates conditional checks.
express-zod-api/src/result-helpers.ts Uses registry for examples instead of getExamples; updates imports.
express-zod-api/src/zod-plugin.ts Removes legacy example metadata, updates interface, and accesses examples via registry.

Sequence Diagram(s)

sequenceDiagram
  participant Endpoint
  participant GlobalRegistry

  Endpoint->>GlobalRegistry: get(schema)
  GlobalRegistry-->>Endpoint: { examples: [...] }
  Endpoint->>Endpoint: Use examples array directly
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested labels

external bug

Poem

Oh, the examples have hopped away,
No more helpers in the hay.
Now the registry holds them tight,
Arrays of samples, clear and right.
Legacy fields wave goodbye,
As Zod’s new rules leap up high! 🐇✨

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch drop-example-and-object-examples

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Comment thread express-zod-api/src/metadata.ts Outdated
@coveralls-official
Copy link
Copy Markdown

coveralls-official Bot commented Jul 25, 2025

Coverage Status

coverage: 100.0%. remained the same
when pulling e5e82e8 on drop-example-and-object-examples
into c6cd683 on make-v25.

@RobinTail RobinTail changed the title Drop example and object-based examples Drop example, object-based examples and getExamples() Jul 25, 2025
@RobinTail
Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jul 25, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

1 similar comment
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jul 25, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
Owner Author

@RobinTail RobinTail left a comment

Choose a reason for hiding this comment

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

good

@RobinTail RobinTail merged commit 18024a9 into make-v25 Jul 25, 2025
12 checks passed
@RobinTail RobinTail deleted the drop-example-and-object-examples branch July 25, 2025 22:08
RobinTail added a commit that referenced this pull request Jul 26, 2025
RobinTail added a commit that referenced this pull request Aug 2, 2025
### Dedication


![image](https://github.com/user-attachments/assets/47dc18f9-70fa-4276-9c79-2a84ef360642)

**Sara Millerey González** was a 32 years young trans woman from Bello,
Antioquia, Colombia.
She was killed in April 2025. Millerey was raped, tortured, and thrown
into a ravine by a group of men. Denounced as a hate crime by press and
Antioquia's mayor, the Colombian National Working Group on Violence
Based on Victims' Sexual Orientation or Gender Identity is collaborating
with the Attorney's General's Office on identifying remaining suspects.

Transgender women suffer too frequently from transphobic violence and
cruelty, being the less protected social group. I'd like to raise an
awareness of this problem. Humans should be creators — not killers. But
most importantly, I want every transgender girl to have an opportunity
to create applications quickly and, in general, learn to write code
easily in order to receive job offers and leave dangerously transphobic
territories for more favorable and civilized ones, and live happily
there. Protect transgender women.

### Breaking

- `zod` version is `^4.0.0`;
  - Compatibility with `zod@^3` is dropped;
  - You SHOULD now `import { z } from "zod"` without the `/v4` suffix;
- Node.js version is `^20.19.0 || ^22.12.0 || ^24.0.0`;
  - The framework distribution is now ESM-only (finally);
  - All the Node.js versions listed above support `require(ESM)` syntax;
- Changes to the `Middleware` class:
- When the `input` schema is not defined, the `input` argument of the
`handler` method is now `unknown`;
- Plugin changes to metadata:
  - `example` removed;
  - object-based `examples` removed (only array remains);
- use either `.example()` or `.meta({})` with `examples` being an array.
- Public `getExamples()` helper removed:
  - use `.meta()?.examples` or `globalRegistry.get()?.examples` instead.

### Content

- #2622 
- #2711 
- #2740 
- #2742 
- #2777 
- #2809 
- #2814 
- #2815 
- #2842 
- #2843 
- #2844 

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

## Summary by CodeRabbit

* **New Features**
* Dropped support for Zod v3; now requires Zod v4 and updates all
imports to use `"zod"` directly.
* Framework is now distributed as ESM-only and supports Node.js
^20.19.0, ^22.12.0, or ^24.0.0.
  * Introduced a unified empty schema utility for input/output defaults.
* Added Vitest configuration with experimental eventsource flag for
testing.

* **Breaking Changes**
* Removed the public `getExamples()` helper; access examples via
`.meta()?.examples` or the global registry.
* Middleware and factory input schemas now default to `undefined` when
omitted, not an empty object schema.
* Dropped support for object-based `examples` in schema metadata; use
`.example()` or array-based `examples` instead.
* Removed deprecated enum and literal depicters from documentation
helpers.
* Updated import paths from `"zod/v4"` to `"zod"` throughout codebase
and examples.
* Adjusted migration rules to reflect import and metadata changes only.

* **Bug Fixes**
* Improved handling of empty schemas and type inference for middleware
and endpoint factories.

* **Chores**
* Updated documentation and changelogs for new Zod import paths and
version requirements.
* Updated build, test, and lint configurations for ESM-only output and
new dependency versions.
* Adjusted GitHub workflows to monitor new branches and updated Node.js
versions.
* Removed legacy migration rules and simplified migration logic focusing
on import and metadata changes.
* Removed legacy dependencies like `undici` and adjusted package
metadata.
  * Simplified ESLint and tsup configurations for ESM-only builds.
  * Updated startup logo dedication message.

* **Tests**
* Refactored and updated tests to align with new schema defaults and Zod
v4 usage.
* Simplified migration tests and rules to focus on import path changes.
  * Added tests for new empty schema utilities.

* **Style**
  * Updated dedication message in the startup logo.

* **Revert**
* Removed legacy and deprecated migration logic and configuration
overrides.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@dosubot dosubot Bot mentioned this pull request Oct 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Backward incompatible changes documentation Improvements or additions to documentation refactoring The better way to achieve the same result

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant