Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider re-factoring swagger-ui into a component #777

Closed
thegecko opened this issue Dec 13, 2014 · 8 comments
Closed

Consider re-factoring swagger-ui into a component #777

thegecko opened this issue Dec 13, 2014 · 8 comments
Milestone

Comments

@thegecko
Copy link

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.

@fehguy fehguy added this to the v2.1.0-M2 milestone Dec 29, 2014
@fehguy
Copy link
Contributor

fehguy commented Dec 29, 2014

thanks, we'll take this into account

@swbullis
Copy link

I would like to second thegecko's request, trying to integrate AMD functionality has been a hair puller.

@alycda
Copy link

alycda commented Feb 10, 2015

@swbullis have you been able to implement swagger-ui via AMD/require? If not, I would also like to request this feature.

@mohsen1
Copy link
Contributor

mohsen1 commented Mar 10, 2015

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.

@swbullis
Copy link

@alycda no I finally opted to just use an iframe.

@mwcz
Copy link

mwcz commented Mar 18, 2015

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. :)

@mohsen1
Copy link
Contributor

mohsen1 commented Mar 18, 2015

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.

@mwcz
Copy link

mwcz commented Mar 19, 2015

Awesome, great to hear!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants