Chore: Validation of Schema Definition with API Responses#36
Merged
Marty-Byrde merged 5 commits intocanaryfrom Feb 26, 2025
Merged
Chore: Validation of Schema Definition with API Responses#36Marty-Byrde merged 5 commits intocanaryfrom
Marty-Byrde merged 5 commits intocanaryfrom
Conversation
The reason for this change is that when a schema property uses the .transform utility method the type of this property includes ZodEffects. Without handling it in the schemaDefault method it will throw an error.
The reason for this change is that the value of this property can be of type number or null. Given the current definition of number or undefined, when the value is null it is transformed to undefined.
The reason for this change is that fetching invoices may return an empty array, hence the toBeGreaterThan assertions were updated to include equal and greaterThan.
Member
Author
|
🎉 This PR is included in version 1.5.0-canary.2 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request includes several changes to improve schema handling and enhance test coverage. The most important changes include updating the
RawArticleSchema, adding support forZodEffectsin schema default values, and enhancing test cases for theGETfunction and invoice retrieval.Schema Handling Improvements:
schemas/article/RawArticle.ts: Updatedarticle_category_idto transformnullvalues toundefinedbefore making it optional.schemas/utils/schemaDefaults.ts: Added support forZodEffectsin theschemaDefaultsfunction to handle schemas with effects.Test Enhancements:
tests/api/Get.test.ts: Added import statements forRawCustomersandsafeParseRawCustomers, updated the test for the 'articles' endpoint to include a limit parameter, and added a new test for validating the customer schema against the response of the/usersendpoint. [1] [2]tests/invoices/getInvoices.test.ts: Removed redundant tests and added a new test to check the default limit of thegetInvoicesfunction, ensuring it returns an array of invoices.