Search code examples
jsonjsonschemaraml

JSON schema reference ($ref) not expanded when using raml2html


I'm using raml2html to generate HTML pages from JSON schemas. But the schema reference ($ref) used in my JSON schema is not expanded as expected and I'm not sure why.

I've followed instructions from raml-jsonschema-expander, the tool used by raml2html to expand references.

My referencing JSON schema:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "id": "http://raw.github.com/path/to/balances.json#",
  ...
  ...
      "$ref": "balance.json#"
  ...

My referenced JSON schema, balance.json, which is hosted on GitHub:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "id": "http://raw.github.com/path/to/balance.json#",
  ...

Solution

  • The problem seems to come from the way GitHub serves contents, as discussed in this SO question.

    I ended up setting up a gh-pages branch in that repository and stored the JSON schema files in that branch. Now the referenced schemas are properly fetched and rendered.