Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reuse objects in schema of API BluePrint?

I have created an API that delivers a resource named "Thumbnail" (/thumbnails)

{
    "name": "toto",
    "uri": "http://xxx"
}

In other hand I have multiple resources that includes that Thumbnail resource in them (like /articles, /videos ...):

{
    "name": "playlist",
    "thumbnail": 
    {
        "name": "toto",
        "uri": "http://xxx"
    }
}

When I write the schemas of those webservices in the BluePrint markdown, I would like to be able to reuse the schema that I've created for the Thumbnail schema in order to not repeat the code in the schemas. I've heart of the Trait feature ( https://github.com/apiaryio/api-blueprint/issues/47 ) but I don't know if it will fit my needs and if it works with aglio and dredd.

Do you know the best thing to do in my case?

like image 788
Stéphane Pessin Avatar asked Jul 13 '15 12:07

Stéphane Pessin


1 Answers

You can use MSON in Attributes section of the API Blueprint to define reusable objects.

You can see some examples in here, here and here.

like image 137
Pavan Kumar Sunkara Avatar answered Nov 24 '22 10:11

Pavan Kumar Sunkara