Closed ScriptType closed 1 week ago
The updates enhance the PatchResource
function in autopatch/autopatch.go
by introducing makeOptionalSchema
, which creates schemas with optional fields for more flexible PATCH operations. Corresponding tests in autopatch/autopatch_test.go
ensure the correct transformation of schemas. Additional tests validate various schema scenarios, including nested schemas and different schema constructs.
File | Change Summary |
---|---|
autopatch/autopatch.go |
Added makeOptionalSchema function and updated PatchResource to use optional schemas for PATCH operations. |
autopatch/autopatch_test.go |
Added TestAutoPatchOptionalSchema to test the new optional schema. Included various tests for different schema scenarios. |
In the code where schemas bloom,
Optional fields now make room,
For PATCH requests with ease and grace,
Flexibility in every case. 🌸
Tests ensure no fields resist,
As all turn optional, none are missed.
Hail the new schema's space,
Patched with elegance in this place. 🐇
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?
Attention: Patch coverage is 93.65079%
with 4 lines
in your changes missing coverage. Please review.
Project coverage is 92.84%. Comparing base (
4a07c36
) to head (1b351ea
). Report is 4 commits behind head on main.
Files | Patch % | Lines |
---|---|---|
autopatch/autopatch.go | 93.65% | 3 Missing and 1 partial :warning: |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
@ScriptType this looks great, but can we get the test coverage up a little before merging?
Will do it over the weekend :). Glad that you like it
Improve AutoPatch to generate optional schema for PATCH operations
Problem
The current AutoPatch functionality generates PATCH operations for resources with GET and PUT operations, but it doesn't create a specific type for the PATCH request that matches the PUT operation with all fields optional.
Solution
This PR modifies the AutoPatch function to create an optional schema for PATCH operations based on the PUT operation's schema.
makeOptionalSchema
function that creates an optional version of a given schema.PatchResource
function to use this new optional schema for PATCH operations.Changes
makeOptionalSchema
function inautopatch.go
PatchResource
function to use the new optional schemaTesting
A new test function
TestAutoPatchOptionalSchema
has been added to verify that:Its my First contribution in golang would be happy to hear from your review :).
Summary by CodeRabbit
New Features
Tests