Any identifier in raml to know if schema is embedded or refferenced



there are two ways of defining schema as shown below ,how to pragmatically know if schema is embedded or referenced.I am using java raml parser.

              schema: apiContact

            schema: |
                "$schema": "",
                "javaType": "",
                "type": "object",
                "description": "A object containing an array of apiContact",
                "properties": {
                  "size": { "type": "integer", "required": true },
                  "contacts": {
                    "type": "array",
                    "items": { "$ref": "apiContact" }


I am not really sure if you can as the parser embed the schema right away if I am not wrong, right?


If you can lookup the schema value, attached to the MIME type you’re working with, in the consolidated schemas, then the net result - as far as the processor is concerned - is that it was referenced.

org.raml.model.Raml model;
org.raml.model.MimeType type;


If the intent was to use a reference, yet the value of the reference cannot be found as a key under schemas, then the reference value will be processed as embedded. There is no explicit syntax to distinguish between the two, hence this confusion.

Furthermore, if one tries to understand if the schema is external or not (i.e. via !include), then what @christian_vogel noted is correct. The way we’ve dealt with it, was to hook straight into the yaml stream reading, and collect additional metadata. The fundamental thing here is that the RAML “model” (in the API) is a “compiled” model, rather than an “authoring/source code” model. Certain aspects from an “authoring/source code” model perspective, would be even harder to harvest, due to YAML’s nature (e.g. anchors/references).


@gardea Thank you for this clarification.


@christian_vogel Thank you for this clarification.