Generating Mocks to have a realistic idea of how an API will work is a challenge as it requires functionally consistent examples.

We will see in this article how to manage examples to feed tools such as Microcks to générate API Mocks.

In the rest of this article we will use the following types:

type Person{

type Address {    street:String    city:String    zipCode:String    country:String  }

on which we define the following data examples

example xLeo on Person{

example xParis on Address{     street:"Avenue Carnot"     zipCode"75000"     city"Paris"     country"France" }

As well as the following facade:

facade PersonDTO on Person{


Declaration of routes, parameters and use of examples

Tools like Microcks use the ability to name examples in OpenAPI statements to reconstruct scenarios.

In the following example

  • one of the values of the Id parameter is declared with the name Leslie (value "1")
  • a Json example of a response is also named Leslie. (xLesli)

The scenario can then be built, when the Id parameter will be passed with the value "1" in parameter for this route, the Mock will answer with the Json xLeslie.

Note that no example has ever been defined for the PersonDTO facade that is used for the response.
You have directly used the example defined on the Person type and Akwatype has automatically transformed it to match the PersonDTO facade.


service Person{
    expose Persons{
        route person{
                    id { Leslie:"1" , leo:"2" }
                    examples { Leslie:xLesli, Leo:xLeo }

Generated OpenAPI


Mocks in Microcks after uploading the OpenAPI into Microcks