In its simplest syntax Akwatype allows to define the facade returned by a route by using the response property followed by the name of the facade (CustomerDTO in the example below).
Apprenez à gérer des réponses multiples pour vos routes grâce à des techniques avancées.
service _Customer{ url:"customer" expose customer{ url:"customers" route detail{
label:"customer detail" url:"customer/id:String" response:CustomerDTO } } }
For more advanced use cases, you can use the responses: { ... } property. The responses block allows you to define a response for each http code.
each http code between quotation marks is followed by:
- A valid type or facade name
- property block between { }, e.g. "200": CustomerDTO { ... }
service _Customer{ url:"customer" expose customers{ url:"customers" route detail{ label:"customer detail" url:"customer/id:String" responses: { "200": CustomerDTO { description: "Success" } "400": BadRequest { description: "Bad request" } "404": NotFound { description: "Not found" } } } } }
Response properties in responses block :
- description (String)
- description of the response
- mediaType(String)
- format of the response ("application/json","application/xml",...)
- optional default "application/json"
- example (String)
- if the response is a facade, name of an example on this type or facade
- if the response is a scalar (String, Integer ...), example value of the type of the response ("My response", 45, ...)
- examples (map of examples)
- key : String
- value :
- if the response is a facade, name of an example on this type or facade
- if the response is a scalar (String, Integer ...), example value of the type of the response ("My response", 45, ...)
- headers