title: Import XSD to OpenAPI
body: <p>I have some model definition inside a XSD file and I need to reference these models from an OpenApi definition. Manually remodeling is no option since the file is too large, and I need to put it into a build system, so that if the XSD is changed, I can regenerate the models/schemas for OpenApi.</p>
  
  <p>What I tried and what nearly worked is using <a href="https://github.com/fnogatz/xsd2json" rel="noreferrer">xsd2json</a> and then converting it with the node module <a href="https://github.com/wework/json-schema-to-openapi-schema" rel="noreferrer">json-schema-to-openapi</a>. However <code>xsd2json</code> is dropping some of the <code>complexElement</code> models. For example <code>"$ref": "#/definitions/tns:ContentNode"</code> is used inside of one model as the child type but there is no definition for <code>ContentNode</code> in the schema, where when I look into the XSD, there is a <code>complexElement</code> definition for <code>ContentNode</code>.</p>
  
  <p>Another approach which I haven't tried yet but seems a bit excessive to me is using xjb to generate Java models from the XSD and then using JacksonSchema to generate the json schema.</p>
  
  <p>Is there any established library or way, to use XSD in OpenApi?</p>