You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the REST API only validates an Order during creation (POST /order).
This makes it impossible for clients to pre-validate a payload before actually creating the resource.
As discussed in the issue, implementing full validation across multiple workflows would be large and hard to review.
So this PR focuses on a minimal and safe first step — a dedicated /order/validate endpoint.
Solution
Added a new endpoint:
POST /ws/rest/v1/order/validate
The endpoint internally uses the same conversion + validation logic used by the create operation, but does not persist anything.
It:
Converts the request body using DelegatingCrudResource.convert()
Returns validation result instead of creating the order
This keeps behavior consistent with existing REST validation rules while avoiding duplication of validation logic.
It also keeps the PR small and reviewable, allowing further validation improvements in follow-up PRs.
Testing
Manually tested using Postman with valid and invalid payloads.
The endpoint returns the same validation result as POST /order but without persisting data.
I was hoping that this was integrated into the existing OrderResource and not just adding a new dangling endpoint / controller.
Okk @ibacher, agreed this to live within OrderResource rather than as a separate endpoint.
Before refactoring, I just want to confirm the preferred pattern: would you like this exposed as an action on the existing resource (e.g. POST /order?action=validate) similar to other RESTWS actions, or is there another established approach in this module for validation-only operations?
I want to make sure the implementation follows the intended REST conventions before updating the PR.
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
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.
Problem
Currently the REST API only validates an Order during creation (
POST /order).This makes it impossible for clients to pre-validate a payload before actually creating the resource.
As discussed in the issue, implementing full validation across multiple workflows would be large and hard to review.
So this PR focuses on a minimal and safe first step — a dedicated
/order/validateendpoint.Solution
Added a new endpoint:
POST
/ws/rest/v1/order/validateThe endpoint internally uses the same conversion + validation logic used by the create operation, but does not persist anything.
It:
DelegatingCrudResource.convert()Response Format
Valid payload:
Invalid payload:
Why this approach
This keeps behavior consistent with existing REST validation rules while avoiding duplication of validation logic.
It also keeps the PR small and reviewable, allowing further validation improvements in follow-up PRs.
Testing
Manually tested using Postman with valid and invalid payloads.
The endpoint returns the same validation result as
POST /orderbut without persisting data.