trebol-ecommerce / trebol-backend-monolith

Monolithic eCommerce backend web application that exposes a RESTful API.
MIT License
16 stars 21 forks source link

`PUT` APIs behave as if they were `PATCH` APIs #232

Closed bglamadrid closed 1 year ago

bglamadrid commented 1 year ago

Build context

Project version

v0.1.0

Latest commits

https://github.com/trebol-ecommerce/trebol-backend-monolith/commit/8474c7264b741d68f434be7167a2718006cf2486

Summary

How to Reproduce

Call any PUT endpoint from the REST API exposed by this backend, sending a partial object from the one expected by the API. e.g. if it's a Person type of data and you have a registry with an idNumber set to 1, send it like this:

{
  "idNumber": "1",
  "firstName": "Jumbo"
}

It will only update the firstName in the existing registry.

Expected behavior

It should reject the object, as it only partially contains the required data. A PUT request should only accept entire valid objects and only then should update any matches.

Additional context

The current behavior should be kept for later; as the Trébol API will eventually expose both PUT and PATCH methods.

Also, when this issue gets fixed, #226 should be resolved and merged too; PUT methods will require to annotate the request body for each endpoint with @Valid.

NyorJa commented 1 year ago

hi @bglamadrid,

May I know the exact endpoints?

bglamadrid commented 1 year ago

Hello @NyorJa

This involves all endpoints beginning with /data/ that have a PUT method, e.g.

And so on.

bglamadrid commented 1 year ago

I made a related issue on this matter on the repo of the API.

When said API gets an update including the feature, the resolution of this issue should go hand-in-hand with that, too 🦾

NyorJa commented 1 year ago

@Valid annotation works on my end in the controller but I have challenges in setting up the unit test like an integration test

bglamadrid commented 1 year ago

@Valid annotation works on my end in the controller but I have challenges in setting up the unit test like an integration test

That isn't really related to this issue though? And what do you mean by doing integration tests? How did you come up with the need to do some?

NyorJa commented 1 year ago

I'm trying to run a @WebMVCTest in the controller class and I am encountering an error.