Open eleonoraortega opened 7 years ago
It should be if you, and only if you, declare entity
to be of type resourceTypes.item
.
#%RAML 1.0
title: Example API
version: v1
mediaType: application/json
uses:
resourceTypes: resourceTypes.raml
/entity:
type: resourceTypes.item
get:
The version where the resource type from the library is applied, should look like the following:
#%RAML 1.0
title: Example API
version: v1
mediaType: application/json
/entity:
put:
body:
example: {"property":"value"}
get:
And the fully expanded version:
#%RAML 1.0
title: Example API
version: v1
mediaType: application/json
/entity:
put:
body:
application/json:
example: {"property":"value"}
get:
Does that answer your question?
Again, its not inherited into libraries, since the concept of expansion basically applies nodes only; not inherit.
The problem with this approach is that a library cannot be validated in isolation. It will be only valid when referenced from RAML files which have a default media type defined, which renders the library not much reusable.
That's a big problem in general. How can we make fragment's valid in isolation or actually should they only be able in the context of a root RAML file? There is no good answer atm.
ResourceType defined inside an imported library. The root raml file has a default media type (application/json). The resource type has a put method with a request body and this request body doesn't define the media type.
Root file:
Library file looks like this:
This case is not documented on the RAML specification. It's not clear if the default media type is inherited in the imported libraries.