So I have the requirement that part of the output models must include UI important information. This information is essentially text translations and suggested formats for dates, prices, lengths.
So an example of an output model could be:
{
statuses : {
enumValue1 : "Display This Text",
enumValue2 : "Display This Text2",
},
thePrice : {
value : 3.50,
formattedValue : "$3.50"
},
length : {
meters 3,
formattedValue : "3 ft."
},
iAmAPropertyOnlyInGet : 42
}
Now if I have this as my output model, is it "ok" to have a completely different input model?
{
status : {
enumValue1,
enumValue2,
},
thePrice : 3.50,
lengthInMeters : 3
}
Good REST APIs: are well-documented and reliable. use HTTP verbs as Fielding originally defined. support X-HTTP-METHOD-Override to accommodate picky proxies.
A request body is usually a JSON document, and the structure of that JSON document can be defined in a Model. The structure of a request body is not currently validated by the IBM Integration Bus run time. However, the Model definition can be used with a Mapping node to graphically implement the REST API operation.
The API should always return sensible HTTP status codes. API errors typically break down into 2 types: 400 series status codes for client issues & 500 series status codes for server issues. At a minimum, the API should standardize that all 400 series errors come with consumable JSON error representation.
Representations you send to the origin server can be completely different than the representations you receive. Consider the way web browsers work. You GET text/html
and you POST application/x-www-urlencoded-form
.
When using the PUT method it is normal for what you PUT and what GET to be similar if not identical.
The REST architectural style puts no constraints on the shape of the HTTP payloads, other than the fact that the semantics must be explicitly specified in the message.
So, in fact, sharing a model type between a client and server without explicitly identifying that type in the message is a violation of the self-descriptive REST sub-constraint.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With