Our api will have a reusable /posts
subroute that will apply to different top-level routes.
For example:
/me/posts
/users/{user-id}/posts
...
Example for posts:
/posts
/{post-id}
/likes
/comments
/{comment-id}
...
Posts will have fixed subroutes, parameters etc as well.
What is the standard way to define such a default, reusable subroute with RAML?
Of course, one could decide to turn this around and make a /posts endpoint, but I don't think that the API definition should be changed based on RAML capabilities. Also, I should be able to have multiple endpoints pointing to the same resource, if I wanted it to.
If you have an answer, please share an example according the requirements.
The first line of a RAML API definition document MUST begin with the text #%RAML followed by a single space followed by the text 1.0 and nothing else before the end of the line.
A RAML library is a collection of the data type declaration, security scheme declaration, and resource type declaration into a modular and reusable group.
In a RAML file, we can define simple and complex data types. Some properties are defined as data types. For example, the property modelTree in the type Brochure is a ModelTree data type.
You can define a ResourceType and specify you are using it in many places. You can do this in the same file or in an external file opreating as a Library.
http://raml.org/developers/whats-new-raml-10
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With