You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+33-23Lines changed: 33 additions & 23 deletions
Original file line number
Diff line number
Diff line change
@@ -18,16 +18,17 @@ This repo publishes to two different NPM packages:
18
18
For the older version of swagger-ui, refer to the [*2.x branch*](https://github.com/swagger-api/swagger-ui/tree/2.x).
19
19
20
20
## Compatibility
21
-
The OpenAPI Specification has undergone 4 revisions since initial creation in 2010. Compatibility between swagger-ui and the OpenAPI Specification is as follows:
21
+
The OpenAPI Specification has undergone 5 revisions since initial creation in 2010. Compatibility between swagger-ui and the OpenAPI Specification is as follows:
22
22
23
-
Swagger UI Version | Release Date | OpenAPI Spec compatibility | Notes | Status
@@ -74,7 +75,6 @@ To help with the migration, here are the currently known issues with 3.X. This l
74
75
75
76
- Only part of the [parameters](#parameters) previously supported are available.
76
77
- The JSON Form Editor is not implemented.
77
-
- Shebang URL support for operations is missing.
78
78
- Support for `collectionFormat` is partial.
79
79
- l10n (translations) is not implemented.
80
80
- Relative path support for external files is not implemented.
@@ -89,22 +89,23 @@ To use swagger-ui's bundles, you should take a look at the [source of swagger-ui
89
89
90
90
```javascript
91
91
constui=SwaggerUIBundle({
92
-
url:"http://petstore.swagger.io/v2/swagger.json",
93
-
dom_id:'#swagger-ui',
94
-
presets: [
95
-
SwaggerUIBundle.presets.apis,
96
-
SwaggerUIStandalonePreset
97
-
],
98
-
plugins: [
99
-
SwaggerUIBundle.plugins.DownloadUrl
100
-
],
101
-
layout:"StandaloneLayout"
102
-
})
92
+
url:"http://petstore.swagger.io/v2/swagger.json",
93
+
dom_id:'#swagger-ui',
94
+
presets: [
95
+
SwaggerUIBundle.presets.apis,
96
+
SwaggerUIStandalonePreset
97
+
],
98
+
plugins: [
99
+
SwaggerUIBundle.plugins.DownloadUrl
100
+
],
101
+
layout:"StandaloneLayout"
102
+
})
103
103
```
104
104
105
105
#### OAuth2 configuration
106
106
You can configure OAuth2 authorization by calling `initOAuth` method with passed configs under the instance of `SwaggerUIBundle`
107
-
default `client_id` and `client_secret`, `realm`, an application name `appName`, `scopeSeparator`, `additionalQueryStringParams`.
107
+
default `client_id` and `client_secret`, `realm`, an application name `appName`, `scopeSeparator`, `additionalQueryStringParams`,
108
+
`useBasicAuthenticationWithAccessCodeGrant`.
108
109
109
110
Config Name | Description
110
111
--- | ---
@@ -114,6 +115,7 @@ realm | realm query parameter (for oauth1) added to `authorizationUrl` and `toke
114
115
appName | application name, displayed in authorization popup. MUST be a string
115
116
scopeSeparator | scope separator for passing scopes, encoded before calling, default value is a space (encoded value `%20`). MUST be a string
116
117
additionalQueryStringParams | Additional query parameters added to `authorizationUrl` and `tokenUrl`. MUST be an object
118
+
useBasicAuthenticationWithAccessCodeGrant | Only activated for the `accessCode` flow. During the `authorization_code` request to the `tokenUrl`, pass the [Client Password](https://tools.ietf.org/html/rfc6749#section-2.3.1) using the HTTP Basic Authentication scheme (`Authorization` header with `Basic base64encoded[client_id:client_secret]`). The default is `false`
117
119
118
120
```
119
121
const ui = SwaggerUIBundle({...})
@@ -144,13 +146,17 @@ spec | A JSON object describing the OpenAPI Specification. When used, the `url`
144
146
validatorUrl | By default, Swagger-UI attempts to validate specs against swagger.io's online validator. You can use this parameter to set a different validator URL, for example for locally deployed validators ([Validator Badge](https://github.com/swagger-api/validator-badge)). Setting it to `null` will disable validation.
145
147
dom_id | The id of a dom element inside which SwaggerUi will put the user interface for swagger.
146
148
oauth2RedirectUrl | OAuth redirect URL
149
+
tagsSorter | Apply a sort to the tag list of each API. It can be 'alpha' (sort by paths alphanumerically) or a function (see [Array.prototype.sort()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) to learn how to write a sort function). Two tag name strings are passed to the sorter for each pass. Default is the order determined by Swagger-UI.
147
150
operationsSorter | Apply a sort to the operation list of each API. It can be 'alpha' (sort by paths alphanumerically), 'method' (sort by HTTP method) or a function (see Array.prototype.sort() to know how sort function works). Default is the order returned by the server unchanged.
148
151
configUrl | Configs URL
149
152
parameterMacro | MUST be a function. Function to set default value to parameters. Accepts two arguments parameterMacro(operation, parameter). Operation and parameter are objects passed for context, both remain immutable
150
153
modelPropertyMacro | MUST be a function. Function to set default values to each property in model. Accepts one argument modelPropertyMacro(property), property is immutable
151
154
docExpansion | Controls the default expansion setting for the operations and tags. It can be 'list' (expands only the tags), 'full' (expands the tags and operations) or 'none' (expands nothing). The default is 'list'.
152
155
displayOperationId | Controls the display of operationId in operations list. The default is `false`.
153
-
displayRequestDuration | Controls the display of the request duration (in milliseconds) for `Try it out` requests. The default is `false`.
156
+
displayRequestDuration | Controls the display of the request duration (in milliseconds) for `Try it out` requests. The default is `false`.
157
+
maxDisplayedTags | If set, limits the number of tagged operations displayed to at most this many. The default is to show all operations.
158
+
filter | If set, enables filtering. The top bar will show an edit box that you can use to filter the tagged operations that are shown. Can be true/false to enable or disable, or an explicit filter string in which case filtering will be enabled using that string as the filter expression. Filtering is case sensitive matching the filter expression anywhere inside the tag.
159
+
deepLinking | If set to `true`, enables dynamic deep linking for tags and operations. [Docs](https://github.com/swagger-api/swagger-ui/blob/master/docs/deep-linking.md)
Only headers with these names will be allowed to be sent by Swagger-UI.
242
248
249
+
## Security contact
250
+
251
+
Please disclose any security-related issues or vulnerabilities by emailing [[email protected]](mailto:[email protected]), instead of using the public issue tracker.
Swagger-UI allows you to deeply link into tags and operations within a spec. When Swagger-UI is provided a URL fragment at runtime, it will automatically expand and scroll to a specified tag or operation.
4
+
5
+
## Usage
6
+
7
+
👉🏼 Add `deepLinking: true` to your Swagger-UI configuration to enable this functionality.
8
+
9
+
When you expand a tag or operation, Swagger-UI will automatically update its URL fragment with a deep link to the item.
10
+
Conversely, when you collapse a tag or operation, Swagger-UI will clear the URL fragment.
11
+
12
+
You can also right-click a tag name or operation path in order to copy a link to that tag or operation.
13
+
14
+
#### Fragment format
15
+
16
+
The fragment is formatted in one of two ways:
17
+
18
+
-`#/{tagName}`, to trigger the focus of a specific tag
19
+
-`#/{tagName}/{operationId}`, to trigger the focus of a specific operation within a tag
20
+
21
+
`operationId` is the explicit operationId provided in the spec, if one exists.
22
+
Otherwise, Swagger-UI generates an implicit operationId by combining the operation's path and method, and escaping non-alphanumeric characters.
23
+
24
+
## FAQ
25
+
26
+
> I'm using Swagger-UI in an application that needs control of the URL fragment. How do I disable deep-linking?
27
+
28
+
This functionality is disabled by default, but you can pass `deepLinking: false` into Swagger-UI as a configuration item to be sure.
29
+
30
+
> Can I link to multiple tags or operations?
31
+
32
+
No, this is not supported.
33
+
34
+
> Can I collapse everything except the operation or tag I'm linking to?
35
+
36
+
Sure - use `docExpansion: none` to collapse all tags and operations. Your deep link will take precedence over the setting, so only the tag or operation you've specified will be expanded.
0 commit comments