-
Notifications
You must be signed in to change notification settings - Fork 104
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
feat(rest): endpoint to merge vendor. #2870
base: main
Are you sure you want to change the base?
Conversation
...ce-server/src/main/java/org/eclipse/sw360/rest/resourceserver/vendor/Sw360VendorService.java
Outdated
Show resolved
Hide resolved
...ce-server/src/main/java/org/eclipse/sw360/rest/resourceserver/vendor/Sw360VendorService.java
Outdated
Show resolved
Hide resolved
...ce-server/src/main/java/org/eclipse/sw360/rest/resourceserver/vendor/Sw360VendorService.java
Outdated
Show resolved
Hide resolved
685d793
to
8c8359b
Compare
Made the changes. |
...ce-server/src/main/java/org/eclipse/sw360/rest/resourceserver/vendor/Sw360VendorService.java
Outdated
Show resolved
Hide resolved
...urce-server/src/main/java/org/eclipse/sw360/rest/resourceserver/vendor/VendorController.java
Show resolved
Hide resolved
8c8359b
to
f86453f
Compare
Made the changes. |
The current implementation of the mergeVendors method in the VendorController class is not ideal because it mixes request parameters and request body in a PATCH request. A better approach would be to encapsulate all the required data in a single request body object. This makes the API cleaner and easier to use. Test Findings:
Attached are the screenshot of API test through rest client |
Hi @bibhuti230185 , In SW360, mixing request parameters and the request body in a PATCH request is generally acceptable. Since PATCH is intended for partial updates, it makes sense to send some parameters in the query string while including others in the request body. Additionally, we are not exposing any actual fields being updated—only the IDs, which is acceptable. |
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.
Minor documentation changes needed. Rest looks good.
content = { | ||
@Content(mediaType = "application/json", | ||
examples = @ExampleObject( | ||
value = "{\"message\": \"Merge failed.\"}" |
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.
Please use actual message if possible.
value = "{\"message\": \"Merge failed.\"}" | |
value = "{\"message\": \"Vendor used as source or target has an open MR\"}" |
@ApiResponse(responseCode = "409", description = "Merge failed because vendor is used.", | ||
content = { | ||
@Content(mediaType = "application/json", | ||
examples = @ExampleObject( | ||
value = "{\"message\": \"Merge failed because vendor is used.\"}" | ||
)) | ||
}), |
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.
409
conflict is not returned by this method as far as I can see. Instead there is a 500
undocumented with message Internal server error while merging the vendors
.
Maybe you meant with the RequestStatus.IN_USE
scenario which will currently throw 400 BAD REQUEST
due to HttpMessageNotReadableException
The idea is good @bibhuti230185 and @rudra-superrr , however given the current situation of other endpoints the current implementation would suffice. We can work on simplifying the entire API when we have good documentation and the current state complete. And maybe even release v3 of the API with it. |
f86453f
to
e8ac47b
Compare
Signed-off-by: Rudra Chopra <[email protected]>
e8ac47b
to
45dc757
Compare
Hi @GMishx , made the changes as requested. |
Closes: #2869
Description: this new endpoint will merge the source vendor to the target vendor.