'should a PUT request to a StoplightIO Prism mock server return an updated object?

I am sending a PUT request to a Stoplightio Prism mock server endpoint but the data in the response is still the same as before the PUT request was sent.

For example GET http://127.0.0.1:4010/api/v2/users/1

returns the same thing: { firstName: Sander lastName: Cohen email: [email protected] }

as a PUT request that updates the firstName to Pablo.

Do I need to connect the Prism server to a db in order for this to work? Or does Prism not care since technically this is not required for a PUT request.



Solution 1:[1]

Prism is only for mocking, not for real requests.

If you would connect the Prism Server to a Database, it feels like a real application server.

I would create a valid response for the PUT request, because it's not the responsibility of mock to make requests work.

If for example a frontend sends the PUT requests, the frontend is only responsible for handling the updated user (in your case), but it trusts the backend that the request will work. That is at least how we do it.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 alexander