Skip to content
This repository has been archived by the owner on Aug 4, 2023. It is now read-only.

Update swagger-ui distribution #163

Closed
whitlockjc opened this issue Feb 19, 2015 · 12 comments
Closed

Update swagger-ui distribution #163

whitlockjc opened this issue Feb 19, 2015 · 12 comments

Comments

@whitlockjc
Copy link
Member

The swagger-ui distribution shipped with swagger-tools is old and needs to be updated.

@bebraw
Copy link
Contributor

bebraw commented Feb 23, 2015

@whitlockjc
Copy link
Member Author

Not sure if you are aware but you can use a custom swagger-ui distribution with swagger-tools. This will let you do whatever you want from a swagger-ui perspective. To answer your specific questions, I'm using response headers from the server to wire up the API URL for the "Try it now!" feature so I could do something like this for what you're wanting but then we're into the situation where we're putting application specific stuff into swagger-tools, something I don't want to do unless it's consumable by many.

If you've got some proposal about how to do this in a more generic/pluggable way, I can do it but you already have the same mechanisms available (extra routes on your server and a custom loader for swagger-ui).

@bebraw
Copy link
Contributor

bebraw commented Feb 23, 2015

Why do you have to maintain a copy of swagger-ui within the project? I'm probably missing something obvious here, just curious.

From my point of view I can resolve the issue like this:

  1. Depend on swagger-ui directly.
  2. Copy node_modules/swagger-ui/dist to some place when building
  3. Copy tweaked index.html with API specific changes on top of swagger-ui one when building
  4. Point swagger-tools to use this version.

I guess that's about it. It feels a little bit nasty that the JS is within index.html but that's more of a swagger-ui issue.

@whitlockjc
Copy link
Member Author

I don't have to but the idea was to make it as simple as possible to get swagger-ui deployed. (You'd be surprised how many people struggle with this.) I didn't realize I could install swagger-ui as an NPM dependency, I'd much rather do that, but I do have a custom index.html that gets the API URL from the server. (Like you said, having JavaScript in index.html sucks but that's a swagger-ui mechanism I built on top of.) If I could figure out some way to wire things up without that, I'd love to stop shipping swagger-ui with the project.

@bebraw
Copy link
Contributor

bebraw commented Feb 23, 2015

I set up an issue for this. See swagger-api/swagger-ui#952 and feel free to chime in if needed.

I think in swagger-tools case you might be get away with by setting swagger-ui as a peer dependency to the project and then documenting basic usage. It is important to avoid a direct dependency as then you could end up in a situation where there is a conflict between project swagger-ui and swagger-tools version. Having it as a peer dependency should help to alleviate this.

You'll need some sort of copy step no matter what given you have customizations in place. On the bright side you could provide multiple customized init files to pick from making it easier to adjust to various API setups.

@bebraw
Copy link
Contributor

bebraw commented Feb 23, 2015

Ok, apparently they have a milestone for exactly this! See swagger-api/swagger-ui#804 .

@whitlockjc
Copy link
Member Author

I've subscribed to the issue. In the meantime, I'm going to update swagger-ui as I always have and when that issue allows for it, I will then move the included swagger-ui out of the module and use a dependency to get the bundle in.

@bebraw
Copy link
Contributor

bebraw commented Feb 23, 2015

Great. That should simplify things. :)

@bebraw
Copy link
Contributor

bebraw commented Apr 8, 2015

@whitlockjc Looks like they have resolve the issue. See swagger-api/swagger-ui#804 (comment) .

@whitlockjc
Copy link
Member Author

This was fixed in the last release, v0.8.6.

@dkhanal
Copy link

dkhanal commented Aug 27, 2015

@whitlockjc Any chance you could update the Swagger UI distribution in Swagger Tools? I'd like to take advantage of the multi-line (textarea) input for string array parameters -- available in latest Swagger UI but not in the version that ships with Swagger Tools.

@whitlockjc
Copy link
Member Author

I will be doing that sometime next week.

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

No branches or pull requests

3 participants