A company has defined two RAML fragments, Book Data Type and Book Example to be used in APIs.
What would be valid RAML to use these fragments ?
A.
1. #%RAML 1.0
2. title: Books
3. types:
4. Book: ABC/Examples/bookDataType.raml
5. /books:
6. post:
7. body:
8. application/json:
9. type: Book
10. examples:
11. input: ABC/Examples/bookExample.raml
12. responses:
13.
201:
14.
body:
15.
application/json:
16.
example:
17.
message: Book added
B.
1.
#%RAML 1.0
2.
title: Books
3.
Book: !include bookDataType.raml
4.
/books:
5.
post:
6.
body:
7.
application/json:
8.
type: Book
9.
examples:
10.
input: !include bookExample.raml
11.
responses:
12.
201:
13.
body:
14.
application/json:
15.
example:
16.
message: Book added
C.
1.
#%RAML 1.0
2.
title: Books
3.
Book: bookDataType.raml
4.
/books:
5.
post:
6.
body:
7.
application/json:
8.
type: Book
9.
examples:
10.
input: bookExample.raml
11.
responses:
12.
201:
13.
body:
14.
application/json:
15.
example:
16.
message: Book added
D.
1.
#%RAML 1.0
2.
title: Books
3.
Book: bookDataType.raml
4.
/books:
5.
post:
6.
body:
7.
application/json:
8.
type: Book
9.
examples:
10.
input: bookExample.raml
11.
responses:
12.
201:
13.
body:
14.
application/json:
15.
example:
16.
message: Book added
D
Explanation:
* RAML file contains lot of information that could be considered as "not API-describing". Sort of
"economy-class" members.
Equally important, but not necessarily part of the main RAML file.
* Through !includes, RAML allows us to build file-distributed API definitions, which is not only useful
to encourage code reuse but also improves readability.
* We can create RAML fragments with such code and then include them in main RAML project using
!include like:
types:
Book: !include bookDataType.raml and
examples:
input: !include bookExample.raml
* Additionally for
--------------------------------------------------------------------------------------------------------------------------------------
--
Correct Answer: D
Explanation:
Reference: INCLUDES section under
https://medium.com/raml-api/raml-101-libraries-and-
datatypes-fragments-1889b2e82c27
Answer is B