Consider re-factoring swagger-ui into a component
IMO, swagger-ui should be a drop-in component which should behave as a module and have external dependencies, but is currently structured as an application.
This causes issues with baked-in dependencies and the need to distribute the project with copies of third party libraries.
Structuring the project as a module following AMD/CommonJS paradigms and utilising a registry such as bower for third-party dependencies could make the project far easier to manage, update and integrate into other applications.
thanks, we'll take this into account
I would like to second thegecko's request, trying to integrate AMD functionality has been a hair puller.
@swbullis have you been able to implement swagger-ui via AMD/require? If not, I would also like to request this feature.
The only way we can truly package an app like this is web components. I played with the idea of wrapping this app in a web component in this branch. Unfortunately because SwaggerUI relies of global objects and <body> element in too many places, it's not an easy task. There is also routing that needs to get refactored to allow multiple SwaggerUI instances live in the same page.
@alycda no I finally opted to just use an iframe.
I'll echo this desire too. Swagger can't be embedded on a site that uses RequireJS (or any AMD loader), because shred.bundle.js overwrites window.require and window.define. iframes are a fine solution, but do have some drawbacks if you want to hide the fact that an iframe is being used (main difficulties are keeping the size of the iframe consistent with the size of the content, so no inner scrolling is necessary, and allowing for links inside the iframe to navigate the parent, instead of navigating inside the iframe).
As far as I know, shred.bundle.js is the only barrier. If only shred would look for an existing AMD loader instead of jamming its own into the page, I like to think everything would suddenly play nicely together. :)
shred is a dependency of swagger-js. Plan is to remove that dependency. Once it's gone we will make swagger-ui.js a UMD compatible (requirejs and commonjs compatible) file.
Awesome, great to hear!