-
-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(openapi): type "id" field according to ZModel schema type #1929
Conversation
📝 WalkthroughWalkthroughThe pull request introduces modifications to the OpenAPI plugin's REST generator, focusing on improving how ID fields are represented in the generated OpenAPI schema. The changes allow the Changes
Assessment against linked issues
Possibly related PRs
Tip CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🔇 Additional comments (6)packages/plugins/openapi/tests/openapi-restful.test.ts (3)
Making the spec version configurable fosters flexibility and ensures smoother test coverage for multiple OpenAPI specs.
Repeating the same pattern used earlier helps maintain consistency in test generation for different spec versions.
Verifying that an integer-typed ID is correctly represented as an integer in the resulting schema ensures better type fidelity. The test coverage for integer-based IDs is now solid. packages/plugins/openapi/src/rest-generator.ts (3)
Switching from a hardcoded string to dynamic schema extraction for single field IDs better aligns with the underlying model definition. However, note the comment regarding JSON:API’s requirement for string-based IDs—be sure to confirm that this approach is acceptable for your API consumers.
Including an ID field only when there’s no default for create operations avoids overwriting auto-generated IDs. This logic should be verified in edge cases (e.g., custom generation strategies).
Ensuring the ID property is universally present in read and update schemas preserves a stable contract. This aligns with most REST conventions where the consumer always expects an 'id' field. Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
fixes #1908