Can an included schema work for both XML & JSON?


#1

From my observations, schema files can be written in JSON, XML, & YAML format.
My question is: Let’s say I include a schema file of one format. Can I use it for multiple return formats, i.e. applicaton/json & applicaton/xml.

To put this in a specific case, here’s portions of my RAML file…

schemas:
    - toasterSchema: !include file://toaster.json

/toaster:
  get:
    responses:
      200:
        body:
          application/json:
            schema: toasterSchema
          application/xml:
            schema: toasterSchema

I attempt to convert this to JAX-RS annotated classes and receive an error for the applicaton/xml section, shown below:

[ERROR] -1 invalid XML schema (toasterSchema): Content is not allowed in prolog. [ERROR] -> [Help 1]

Thanks for your response.