zowe / sample-spring-boot-api-service

Zowe REST API service SDK and sample API service that integrates with Zowe API Mediation Layer
Other
26 stars 18 forks source link

Error and warning message format in the API response #22

Closed plavjanik closed 5 years ago

plavjanik commented 5 years ago
plavjanik commented 5 years ago

Original documentation (taken from https://docops.ca.com/x/r9SVH):

REST API Document Format

Document format

The response is to be in a JSON format and media type value is application/json. The name of the fields is to use camelCase. If the request is processed without any errors and warnings, then the response format is to be either a JSON object or JSON array. If the request is processed with an error or warning, then the response is to follow the JSON format as in the following code:

{
  "messages": [
    {
      "messageType": "ERROR",
      "messageNumber": "CSR0001",
      "messageContent": "Pet with id '404' is not found"
    }
  ]
}

The above response contains a messages section. The messages array is a place for application (or service) status and message descriptions to complement and enhance the basic HTTP status codes that are returned in the HTTP status line.

Rules for messages

Follow the principle that message key (for example org.zowe.sdk.apiml.serviceCertificateNotTrusted) is for the code and message content (readable text) is for people. When an error occurs, The HTTP status codes are returned. Provide more details within this message structure. The meaning of the fields is (in order of importance):