2
votes

I want to define custom objects as json schema files and associated examples as separate files. I want to do something like this:

#%RAML 1.0
title: MDM
version: v1
baseUri: http://api.mdm.ishafoundation.org
mediaType: application/json
types:
  Contact:
    type: !include schemas/contact.json
    example: !include examples/contact.example.json

But I get the following error message for the line starting with the "type:" statement - "Error: You cannot inherit from both types of different kind"

In the spec it says

External types cannot participate in type inheritance or specialization. In other words: You cannot define sub-types of external types that declare new properties or set facets. You can, however, create simple type wrappers that add metadata, examples and a description.

I'm guessing this is the problem. But I don't know what it means to create a "type wrapper". Can somebody tell me what is the best way to achieve what I want.

1

1 Answers

1
votes

The RAML spec shows an example exactly like what you post here, so it should work or there's an error in the spec.

Anyway, this way of writing the RAML worked:

#%RAML 1.0
title: MDM
version: v1
baseUri: http://api.mdm.ishafoundation.org
mediaType: application/json
types:
 Contact: !include schemas/contact.json

Not sure how to fit the example there but you can always add it directly to the method.