Akwatype allows to define responses templates with a set of return codes.

These templates can be used to standardize API responses

Declaration of a responses template

Responses templates are declared in services files.

A responses templates is declared by the keyword responses followed by the name of the responses template.

The body of responses template is identical to the content of responses declared inline on a route

responses ExampleResponses{
    "200": ShortBook {
        description : "not found"
        description : "internal server error"

Utilisation of a responses template

When declaring a response block in a route, it is possible to follow responses with : and the name of a template response.

All the template's response codes are then incorporated into the current block.

However, it is possible to

  • redefine the response corresponding to a code defined in the template ("200" in the example below)
  • add new return codes ("400" in the example below)
  • associate an empty block to a code defined in the template to remove it ("501" in the example below)


service Book{
    expose books{
        route book{
            responses: ExampleResponses {
                "200": BookDTO { description: "Success" }  
"400": { description: "Bad request" } "501": {} } } } }