|
| 1 | +# Detecting your Swagger-UI version |
| 2 | + |
| 3 | +At times, you're going to need to know which version of Swagger-UI you use. |
| 4 | + |
| 5 | +The first step would be to detect which major version you currently use, as the method of detecting the version has changed. If your Swagger-UI has been heavily modified and you cannot detect from the look and feel which major version you use, you'd have to try both methods to get the exact version. |
| 6 | + |
| 7 | +To help you visually detect which version you're using, we've included supporting images. |
| 8 | + |
| 9 | + |
| 10 | +# Swagger-UI 3.X |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | +Some distinct identifiers to Swagger-UI 3.X: |
| 15 | +- The API version appears as a badge next to its title. |
| 16 | +- If there are schemes or authorizations, they'd appear in a bar above the operations. |
| 17 | +- Try it out functionality is not enabled by default. |
| 18 | +- All the response codes in the operations appear at after the parameters. |
| 19 | +- There's a models section after the operations. |
| 20 | + |
| 21 | +If you've determined this is the version you have, to find the exact version: |
| 22 | +- Open your browser's web console (changes between browsers) |
| 23 | +- Type `versions` in the console and execute the call. |
| 24 | +- You might need to expand the result, until you get a string similar to `swaggerUi : Object { version: "3.1.6", gitRevision: "g786cd47", gitDirty: true, … }`. |
| 25 | +- The version taken from that example would be `3.1.6`. |
| 26 | + |
| 27 | +Note: This functionality was added in 3.0.8. If you're unable to execute it, you're likely to use an older version, and in that case the first step would be to upgrade. |
| 28 | + |
| 29 | + |
| 30 | +# Swagger-UI 2.X and under |
| 31 | + |
| 32 | + |
| 33 | + |
| 34 | +Some distinct identifiers to Swagger-UI 3.X: |
| 35 | +- The API version appears at the bottom of the page. |
| 36 | +- Schemes are not rendered. |
| 37 | +- Authorization, if rendered, will appear next to the navigation bar. |
| 38 | +- Try it out functionality is enabled by default. |
| 39 | +- The successful response code would appear above the parameters, the rest below them. |
| 40 | +- There's no models section after the operations. |
| 41 | + |
| 42 | +If you've determined this is the version you have, to find the exact version: |
| 43 | +- Navigate to the sources of the UI. Either on your disk or via the view page source functionality in your browser. |
| 44 | +- Find an open the `swagger-ui.js` |
| 45 | +- At the top of the page, there would be a comment containing the exact version of swagger-ui. This example shows version `2.2.9`: |
| 46 | + |
| 47 | +``` |
| 48 | +/** |
| 49 | + * swagger-ui - Swagger UI is a dependency-free collection of HTML, JavaScript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API |
| 50 | + * @version v2.2.9 |
| 51 | + * @link http://swagger.io |
| 52 | + * @license Apache-2.0 |
| 53 | + */ |
| 54 | + ``` |
0 commit comments