lundi 29 novembre 2021

Is good practice with REST APIs to assume default values when values are not present?

An application let others applications to get weather information for a region. This application implements a REST API and JSON objects to represent the resources and the users indicates the region via region attribute in a JSON object in the request.

It is working this way: if the region is not indicated in the request, this is if the attribute is not present in the JSON or it has null value, the application assumes region is "Tenesse" (some region by default). Is this a good practice? What is the disadvantage of doing this against making the region a required attribute and explicitly indicates the region?




Aucun commentaire:

Enregistrer un commentaire