feat: configurable depiction of the HEAD method#2872
Conversation
WalkthroughThis change introduces a new Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Documentation
participant Integration
participant Router
User->>Documentation: new Documentation({ hasHeadMethod })
alt hasHeadMethod = true
Documentation->>Router: walkRoutes(withHead(onEndpoint))
else hasHeadMethod = false
Documentation->>Router: walkRoutes(onEndpoint)
end
User->>Integration: new Integration({ hasHeadMethod })
alt hasHeadMethod = true
Integration->>Router: walkRoutes(withHead(onEndpoint))
else hasHeadMethod = false
Integration->>Router: walkRoutes(onEndpoint)
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing Touches🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
CHANGELOG.md (2)
10-10: Minor grammar fix – missing verb
Handling the HEAD method the feature of Expressis missing a verb.
Suggest:Handling the HEAD method is a feature of Express.
9-9: Clarity – add article before “HEAD method”
Depicts HEAD method for each Endpoint …→Depicts the HEAD method for each endpoint …for consistency with surrounding text.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
express-zod-api/tests/__snapshots__/documentation.spec.ts.snapis excluded by!**/*.snapexpress-zod-api/tests/__snapshots__/integration.spec.ts.snapis excluded by!**/*.snap
📒 Files selected for processing (6)
CHANGELOG.md(1 hunks)README.md(1 hunks)express-zod-api/src/documentation.ts(3 hunks)express-zod-api/src/integration.ts(3 hunks)express-zod-api/tests/documentation.spec.ts(1 hunks)express-zod-api/tests/integration.spec.ts(1 hunks)
🧰 Additional context used
🧠 Learnings (11)
📓 Common learnings
Learnt from: RobinTail
PR: RobinTail/express-zod-api#2697
File: CHANGELOG.md:5-5
Timestamp: 2025-06-02T21:11:20.768Z
Learning: In the express-zod-api repository, RobinTail follows a release workflow where package.json version is only updated on the master branch after merging all planned release changes. Changelog entries may show future version numbers while package.json remains at the previous version during feature development, and this is intentional workflow, not a version inconsistency that needs to be flagged.
📚 Learning: the type-only import `import type {} from "qs";` in express-zod-api/src/index.ts is necessary to avo...
Learnt from: RobinTail
PR: RobinTail/express-zod-api#2428
File: express-zod-api/src/index.ts:44-44
Timestamp: 2025-05-28T18:58:10.064Z
Learning: The type-only import `import type {} from "qs";` in express-zod-api/src/index.ts is necessary to avoid TS2742 errors for exported functions like attachRouting, makeRequestMock, testEndpoint, and testMiddleware that have types depending on @types/qs. This import provides the reference TypeScript needs to infer portable type names.
Applied to files:
express-zod-api/tests/integration.spec.tsexpress-zod-api/src/integration.tsexpress-zod-api/src/documentation.tsexpress-zod-api/tests/documentation.spec.ts
📚 Learning: in express-zod-api tsup configurations, the direct mutation of `options.supported` in the `esbuildop...
Learnt from: RobinTail
PR: RobinTail/express-zod-api#2736
File: express-zod-api/tsup.config.ts:12-26
Timestamp: 2025-06-14T16:42:52.972Z
Learning: In express-zod-api tsup configurations, the direct mutation of `options.supported` in the `esbuildOptions` callback is intentional behavior and should not be flagged as a side effect issue.
Applied to files:
express-zod-api/tests/integration.spec.tsexpress-zod-api/src/integration.tsexpress-zod-api/src/documentation.tsexpress-zod-api/tests/documentation.spec.ts
📚 Learning: in express-zod-api/tests/zts.spec.ts, the `fruits` enum intentionally contains both string and numer...
Learnt from: RobinTail
PR: RobinTail/express-zod-api#2546
File: express-zod-api/tests/zts.spec.ts:160-162
Timestamp: 2025-05-27T20:22:30.428Z
Learning: In express-zod-api/tests/zts.spec.ts, the `Fruits` enum intentionally contains both string and numeric members (Apple = "apple", Banana = "banana", Cantaloupe = "cantaloupe", A = 5) and is used with `z.enum(Fruits)` to test how the system handles mixed enum types. This is by design for testing purposes.
Applied to files:
express-zod-api/tests/integration.spec.tsexpress-zod-api/tests/documentation.spec.ts
📚 Learning: in the express-zod-api project, tests are run from the `express-zod-api` workspace directory, and th...
Learnt from: RobinTail
PR: RobinTail/express-zod-api#2546
File: express-zod-api/tests/buffer-schema.spec.ts:32-37
Timestamp: 2025-05-27T19:35:57.357Z
Learning: In the express-zod-api project, tests are run from the `express-zod-api` workspace directory, and the project uses an ESM-first environment without `__dirname`. Relative paths like `../logo.svg` in test files correctly resolve to the repository root due to this test execution context.
Applied to files:
express-zod-api/tests/integration.spec.tsexpress-zod-api/tests/documentation.spec.ts
📚 Learning: the `cjs-test` directory in the express-zod-api repository is a test workspace and should be exclude...
Learnt from: RobinTail
PR: RobinTail/express-zod-api#2697
File: CHANGELOG.md:5-5
Timestamp: 2025-06-02T21:08:56.475Z
Learning: The `cjs-test` directory in the express-zod-api repository is a test workspace and should be excluded when checking for main project version consistency with changelog entries.
Applied to files:
express-zod-api/tests/integration.spec.tsexpress-zod-api/tests/documentation.spec.ts
📚 Learning: in express-zod-api's `flattenio` function in json-schema-helpers.ts, the `additionalproperties` fiel...
Learnt from: RobinTail
PR: RobinTail/express-zod-api#2546
File: express-zod-api/src/json-schema-helpers.ts:75-87
Timestamp: 2025-05-27T20:40:19.548Z
Learning: In express-zod-api's `flattenIO` function in json-schema-helpers.ts, the `additionalProperties` field is used as a template to generate property schemas for literal property names extracted from `propertyNames.const` and `propertyNames.enum`. Converting boolean `additionalProperties` values to empty objects `{}` via `Object(entry.additionalProperties)` is intentional behavior, as the function only needs property schema templates, not the boolean semantics of `additionalProperties`.
Applied to files:
express-zod-api/src/integration.tsexpress-zod-api/src/documentation.tsexpress-zod-api/tests/documentation.spec.ts
📚 Learning: in express-zod-api, when migrating from zod v3 to v4, the correct approach for internal type imports...
Learnt from: RobinTail
PR: RobinTail/express-zod-api#0
File: :0-0
Timestamp: 2025-08-01T09:48:13.742Z
Learning: In express-zod-api, when migrating from Zod v3 to v4, the correct approach for internal type imports is to change from `import type { $ZodType } from "zod/v4/core"` to `import { z } from "zod"` and then use `z.core.$ZodType`. The zod/v4/core module is reexported as z.core by the main zod package, making this a valid and working approach.
Applied to files:
express-zod-api/src/integration.tsexpress-zod-api/tests/documentation.spec.ts
📚 Learning: in express-zod-api, the `somemethod` type (defined as `lowercase`) is intentionally broad to...
Learnt from: RobinTail
PR: RobinTail/express-zod-api#2833
File: express-zod-api/src/method.ts:3-3
Timestamp: 2025-07-20T11:09:58.980Z
Learning: In express-zod-api, the `SomeMethod` type (defined as `Lowercase<string>`) is intentionally broad to represent raw, unvalidated HTTP methods from requests. The narrower `Method` type is used after validation with `isMethod()`. This defensive programming pattern separates raw external input types from validated types, allowing graceful handling of unknown methods.
Applied to files:
express-zod-api/src/integration.ts
📚 Learning: in express-zod-api, when working with zod's json schema override callbacks, using `delete` to mutate...
Learnt from: RobinTail
PR: RobinTail/express-zod-api#2546
File: express-zod-api/src/documentation-helpers.ts:508-512
Timestamp: 2025-05-28T07:58:09.853Z
Learning: In express-zod-api, when working with Zod's JSON schema override callbacks, using `delete` to mutate `ctx.jsonSchema` is the recommended approach per Zod's official documentation, even if it triggers performance linting warnings. This is preferable to creating copies with `undefined` values, especially for snapshot testing.
Applied to files:
express-zod-api/src/integration.ts
📚 Learning: the `_zod` property in zod v4 schemas is officially documented and recommended for library authors t...
Learnt from: RobinTail
PR: RobinTail/express-zod-api#2546
File: express-zod-api/src/metadata.ts:5-13
Timestamp: 2025-05-27T20:08:50.699Z
Learning: The `_zod` property in Zod v4 schemas is officially documented and recommended for library authors to differentiate between Zod 3 and Zod 4 schemas at runtime, despite the underscore prefix. This is explicitly mentioned in Zod's library authors documentation and is not a private internal property.
Applied to files:
express-zod-api/src/integration.ts
🧬 Code Graph Analysis (2)
express-zod-api/src/integration.ts (1)
express-zod-api/src/routing-walker.ts (1)
withHead(15-20)
express-zod-api/src/documentation.ts (1)
express-zod-api/src/routing-walker.ts (1)
withHead(15-20)
⏰ 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). (5)
- GitHub Check: build (24.x)
- GitHub Check: build (22.12.0)
- GitHub Check: build (22.x)
- GitHub Check: build (20.19.0)
- GitHub Check: build (20.x)
🔇 Additional comments (9)
README.md (1)
87-87: LGTM! Appropriate contributor recognition.The addition of @GreaterTamarack to the contributors section follows the established format and properly acknowledges their contribution to the HEAD method feature.
express-zod-api/src/integration.ts (3)
50-54: Well-documented parameter addition.The
hasHeadMethodparameter is properly documented with clear JSDoc description and appropriate default value that maintains backward compatibility.
98-98: Consistent parameter handling.The constructor parameter correctly defaults to
true, ensuring backward compatibility while enabling the new feature.
157-157: Correct conditional implementation.The conditional logic properly applies the
withHeadwrapper only whenhasHeadMethodistrue, allowing users to disable HEAD method generation for GET endpoints. This implementation is consistent with the same pattern used indocumentation.ts.express-zod-api/src/documentation.ts (3)
62-66: Consistent parameter documentation.The
hasHeadMethodparameter documentation matches the implementation inintegration.ts, ensuring consistent behavior across documentation and client generation.
157-157: Backward-compatible default value.The default value of
truemaintains existing behavior while enabling the new feature to disable HEAD method depiction.
265-265: Consistent implementation pattern.The conditional logic mirrors the exact implementation in
integration.ts(line 157), ensuring uniform behavior across both documentation generation and client integration when controlling HEAD method depiction.express-zod-api/tests/documentation.spec.ts (1)
55-55: Good test coverage for the new feature.The addition of
hasHeadMethod: falseappropriately tests the new configurable HEAD method feature. This ensures the Documentation class correctly handles the option when HEAD method generation is disabled.express-zod-api/tests/integration.spec.ts (1)
69-86: Excellent parameterized test for the HEAD method feature.The test comprehensively covers both the default behavior (
undefined) and explicit disable behavior (false) for thehasHeadMethodoption in the Integration class. The test structure follows established patterns and uses appropriate snapshot testing to verify the generated output.
Based on #2791 (reply in thread)
Summary by CodeRabbit