Clarify how schemas can be used for composite objects


#1

I’m unclear how XML schema are used for composite objects. Consider a case where an API has two resources, models and targets; a model contains a collection of targets:

/models:
  /{modelId}:
    get:
        body:
           application/xml: 
               schema: model      
    /targets/{targetId}:
      get:
         body:
            application/xml: 
               schema: target      

When I use JAXB schemagen, it puts the schema for all my domain objects in the same XSD file which I’ve renamed domain.xsd . Thus, my domain.xsd has definitions for both model and target.

If I use

schemas:
  - model: !include domain.xsd

How do I also bind the schema for target? Can a schema only define one element? Does RAML pick the first defined xs:element or xs:complexType in a schema? Do I have to split the schema into two separate files, with lots of duplication? (I tried schema includes, but got namespace errors that I don’t know how to resolve.)

(This may be related to this Nested schemas and references thread; I’m not sure)

Thanks,
djb


#2

Does anyone have an answer?


#3

I’d like to understand this as well. I would assume something like #name-in-schema-file could be added to the include… sort of like an anchor link in a web page? I’ve not had to worry about this issue yet, but I suspect you’re not alone with this.