swagger-ui icon indicating copy to clipboard operation
swagger-ui copied to clipboard

Referencing operation from an external file seems to interfere with local resolution of definitions.

Open watnotte opened this issue 10 years ago • 3 comments

I updated to the latest from the master branch and still see the same behaviour.

I have a swagger file:

sandbox-swagger.txt

that defines a Base and Composite resource definition. When I load it up in Swagger UI, it displays fine and the composite resource Example Value shows all the properties from both definitions.

without-external-ref

However, when I add a new operation that references an external resource:

    "/imported": {
        "$ref": "https://raw.githubusercontent.com/Voyent/swagger-ui/master/src/main/html/services/ops-swagger.json#/import"
    }

sandbox-swagger-import.txt

The Example Value now showing for the composite parameter is incorrect. It seems like it's not resolving the local definitions properly.

with-external-ref

Note:

  • I don't see any errors in the browser console.
  • Both files appear to get loaded properly.
  • I do not see the same issue in the Swagger Editor.
  • It doesn't matter if the reference is relative or absolute.
  • It works if I remove the reference or inline the information from the external file.

watnotte avatar Jul 13 '16 23:07 watnotte

Just to follow up, I was playing around with other externally referenced files, for example this default response:

          "default": {
            "description": "An error occurred.",
            "schema": {
              "$ref": "definitions.json#/Error"
            }
          }

It appears that any externally referenced file interferes with the Example Value when it relies on an internal reference for composition. I'm really hoping to avoid copying and pasting all the external information into the specific API files.

watnotte avatar Jul 14 '16 15:07 watnotte

Could you please open an issue in swagger-js for this?

fehguy avatar Jul 15 '16 05:07 fehguy

No problem: https://github.com/swagger-api/swagger-js/issues/811

watnotte avatar Jul 15 '16 16:07 watnotte