jensoleg / swagger-ui

Swagger UI is a dependency-free collection of HTML, Javascript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.
http://swagger.io
Other
1.14k stars 310 forks source link

$ref doesn't work #29

Open mategvo opened 8 years ago

mategvo commented 8 years ago

Hey, first of all, great theme!

We have a fairly complex JSON file so we've created lots of smaller $ref reusable bits but they don't seem to load properly. The sample data is empty and parameters aren't loaded neither. Do you know how we can fix this?

Note that the final .json file is completely self-contained. The _$ref_s only refer to other parts of the .json file, not outside documents

cviebrock commented 8 years ago

Following up to @mateuszgwozdz comment (we're working on the same project), I think it might be related to definitions that use allOf, for example:

  "definitions": {
    "Category": {
      "description": "A complete category model",
      "type": "object",
      "allOf": [
        {
          "$ref": "#/definitions/CategoryId"
        },
        {
          "$ref": "#/definitions/CategoryBase"
        },
        {
          "$ref": "#/definitions/CategoryImage"
        }
      ]
    },
    ...
  }

Could it be that your fork is behind the master source, and that it doesn't support parsing allOf entries?

mategvo commented 8 years ago

Seems that I've fixed the issue, copied the Resolution part of new swagger-ui.js and replaced in this one.

davidyin1212 commented 8 years ago

could you elaborate on how you fixed this issue I'm getting the same problem when using allOf

jeremy-skelton-hs commented 8 years ago

I'm also wondering if you could elaborate on how you resolved this issue? I'm seeing the same problem when using allOf

blockloop commented 8 years ago

@mateuszgwozdz could you explain what you did or upload your fix somehow?