Swagger-ui: Add Swagger UI version to runtime dist

Created on 28 Sep 2018  路  4Comments  路  Source: swagger-api/swagger-ui

Is your feature request related to a problem?

It will help with problem reporting etc. if swagger-ui revealed which version is running

Describe the solution you'd like

Add version.txt to the dist folder
Ideally, the build would extract this from the version in package.json when creating the dist contents

Describe alternatives you've considered

Consider adding version to the UI presentation as well

Additional context

packaging enhancement

Most helpful comment

@hkosova Thanks, yes, I saw that in the docs, but I think that is very cumbersome. a version.txt or version.html (or some _About_ link in the client) would also be more helpful/easier to use.

All 4 comments

Currently you can find the Swagger UI version in the following way: open the browser console and evaluate versions. The result contains something like this:

swaggerUi: {version: "3.19.0", gitRevision: "g13341658", ...

@hkosova Thanks, yes, I saw that in the docs, but I think that is very cumbersome. a version.txt or version.html (or some _About_ link in the client) would also be more helpful/easier to use.

@DavidBiesack you can add some custom code to your UI to show the version:

tb = document.getElementsByClassName("topbar")[0];
tb_link = tb.getElementsByClassName("link")[0];
var small = document.createElement("small");
small.appendChild(document.createTextNode(versions.swaggerUi.version));
tb_link.appendChild(small);

just six lines of code, you can inject that in the onComplete parameter

Here is my custom version
http://swagger-net-test.azurewebsites.net/swagger/ui/index

cc: comment from #4909

@DavidBiesack Thanks for the PR! While I understand the desired convenience of this feature, per comments in the related #4907, there exists multiple options that do not require additional file access and creation. Closing feature request and PR.

Was this page helpful?
0 / 5 - 0 ratings