Skip to content

Chore: Validation of Schema Definition with API Responses#36

Merged
Marty-Byrde merged 5 commits intocanaryfrom
validate-schema-integrity
Feb 26, 2025
Merged

Chore: Validation of Schema Definition with API Responses#36
Marty-Byrde merged 5 commits intocanaryfrom
validate-schema-integrity

Conversation

@Marty-Byrde
Copy link
Member

@Marty-Byrde Marty-Byrde commented Feb 26, 2025

✅ Description done

This pull request includes several changes to improve schema handling and enhance test coverage. The most important changes include updating the RawArticleSchema, adding support for ZodEffects in schema default values, and enhancing test cases for the GET function and invoice retrieval.

Schema Handling Improvements:

Test Enhancements:

  • tests/api/Get.test.ts: Added import statements for RawCustomers and safeParseRawCustomers, 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 /users endpoint. [1] [2]
  • tests/invoices/getInvoices.test.ts: Removed redundant tests and added a new test to check the default limit of the getInvoices function, ensuring it returns an array of invoices.

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.
@Marty-Byrde Marty-Byrde self-assigned this Feb 26, 2025
@Marty-Byrde Marty-Byrde changed the base branch from main to canary February 26, 2025 16:53
@Marty-Byrde Marty-Byrde merged commit 05e9272 into canary Feb 26, 2025
4 checks passed
@Marty-Byrde Marty-Byrde deleted the validate-schema-integrity branch February 26, 2025 16:54
@Marty-Byrde
Copy link
Member Author

🎉 This PR is included in version 1.5.0-canary.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant