-
-
Couldn't load subscription status.
- Fork 126
feat(openapi): add plugin option to omit generating input object details for RPC flavor #1852
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
Conversation
…ils for RPC flavor
|
Important Review skippedReview was skipped due to path filters ⛔ Files ignored due to path filters (2)
CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including You can disable this status message by setting the 📝 Walkthrough📝 WalkthroughWalkthroughThe changes in this pull request enhance the Changes
Assessment against linked issues
Possibly related PRs
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 (
|
There was a problem hiding this 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
🧹 Outside diff range and nitpick comments (3)
packages/plugins/openapi/tests/openapi-rpc.test.ts (2)
19-24: Well-implemented loop for testingomitInputDetailsThe loop effectively tests both states of the
omitInputDetailsoption. Consider adding a brief comment above the loop to explain its purpose for future maintainability.
105-111: Robust baseline comparison logicThe dynamic selection of baseline files based on the
omitInputDetailsflag ensures accurate testing against expected outputs. Ensure that the baseline files are regularly updated to reflect changes in the plugin's behavior.packages/plugins/openapi/src/rpc-generator.ts (1)
39-45: Simplify type validation foromitInputDetailsoptionThe current type check for
omitInputDetailscan be streamlined. Sincethis.getOption<boolean>('omitInputDetails', false)should always return a boolean, the check forundefinedmay be unnecessary.Consider simplifying the validation logic:
this.omitInputDetails = this.getOption<boolean>('omitInputDetails', false); - if (this.omitInputDetails !== undefined && typeof this.omitInputDetails !== 'boolean') { + if (typeof this.omitInputDetails !== 'boolean') { throw new PluginError(name, `Invalid option value for "omitInputDetails", boolean expected`); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
⛔ Files ignored due to path filters (2)
packages/plugins/openapi/tests/baseline/rpc-3.0.0-omit.baseline.yamlis excluded by!**/*.yamlpackages/plugins/openapi/tests/baseline/rpc-3.1.0-omit.baseline.yamlis excluded by!**/*.yaml
📒 Files selected for processing (3)
packages/plugins/openapi/src/rest-generator.ts(2 hunks)packages/plugins/openapi/src/rpc-generator.ts(19 hunks)packages/plugins/openapi/tests/openapi-rpc.test.ts(2 hunks)
🔇 Additional comments (26)
packages/plugins/openapi/tests/openapi-rpc.test.ts (4)
99-101: Clear conditional logging for test configurations
The logging statement effectively communicates the current configuration of the test, which aids in debugging and tracking test executions.
113-120: Comprehensive validation of the OpenAPI specification
The use of OpenAPIParser.validate along with specific checks for tags and paths ensures that the generated specification meets the expected standards and behaviors.
125-129: Proper handling and validation of deprecated API paths
The tests correctly verify the documentation of deprecated paths, ensuring that they are accurately represented in the OpenAPI specification.
130-132: Correct exclusion of ignored models from the OpenAPI paths
The tests ensure that models marked to be ignored are not included in the generated OpenAPI documentation, maintaining its relevance and cleanliness.
packages/plugins/openapi/src/rest-generator.ts (3)
10-11: Imports are correctly added for new functionality.
The addition of PluginError and PluginOptions is necessary for handling the new plugin options and error management in the constructor.
37-42: Constructor updated to handle new plugin options effectively.
The constructor now properly handles the omitInputDetails option by throwing a PluginError if it is used for the REST flavor. This ensures that the plugin's behavior is consistent with its intended use case.
37-42: Effective integration of new plugin options within the existing architecture.
The changes are well integrated, maintaining the existing functionality while extending the constructor to handle new configuration options appropriately.
packages/plugins/openapi/src/rpc-generator.ts (19)
3-3: Import necessary modules from '@zenstackhq/sdk'
The import statement correctly adds PluginError, PluginOptions, and other required modules for the new functionality.
26-26: Define ANY_OBJECT constant for generic object reference
Introducing the ANY_OBJECT constant enhances readability and supports the new omitInputDetails option effectively.
37-37: Add omitInputDetails property to control input detail omission
The class property omitInputDetails is appropriately declared to store the new plugin option.
166-168: Use omittableRef to conditionally reference input types
Applying this.omittableRef to select, include, and data correctly adjusts input references based on the omitInputDetails option.
192-193: Handle createMany inputs with omittableRef
Consistently using this.omittableRef for data ensures that input details are omitted when specified.
222-224: Update findUnique operation to respect omitInputDetails
The inputs for select, include, and where are appropriately modified to use this.omittableRef, aligning with the new option.
245-247: Adjust findFirst inputs using omittableRef
Consistent application of this.omittableRef enhances maintainability and ensures correct behavior based on the option.
268-270: Modify findMany operation inputs with omittableRef
Updating select, include, and where with this.omittableRef correctly implements the input detail omission.
292-295: Update updateOne operation to use omittableRef
The changes ensure that select, include, where, and data inputs respect the omitInputDetails setting.
317-318: Apply omittableRef to updateMany operation inputs
Using this.omittableRef for where and data maintains consistency across operations.
340-344: Refactor upsert operation inputs with omittableRef
The inputs for select, include, where, create, and update are correctly adjusted to handle input omission.
366-368: Ensure deleteOne operation inputs use omittableRef
Updating the input references aligns the deleteOne operation with the omitInputDetails functionality.
389-389: Modify deleteMany operation to respect omitInputDetails
Applying this.omittableRef to the where input ensures consistent behavior when omitting input details.
410-411: Adjust count operation inputs with omittableRef
Using this.omittableRef for select and where inputs correctly implements the new option.
440-442: Update aggregate operation inputs to handle input omission
Consistently applying this.omittableRef to where and orderBy supports the omitInputDetails option.
466-468: Apply omittableRef to groupBy operation inputs
The inputs where, orderBy, and by are appropriately modified, ensuring consistent handling of input details.
602-614: Use omittableRef in aggregate field definitions
Modifying _count, _min, _max, _sum, and _avg with this.omittableRef aligns aggregate operations with the new option.
632-638: Add catch-all object schema when omitInputDetails is enabled
Defining the ANY_OBJECT schema provides a generic object type, effectively reducing the size of the generated OpenAPI specification.
847-853: Implement omittableRef method for conditional references
The omittableRef method correctly returns a reference to ANY_OBJECT when omitInputDetails is true, improving performance for large models.
fixes #1717