Skip to content

Commit 31717db

Browse files
simPodtim-lai
andauthored
feat(swagger-ui-react): Add withCredentials prop (#7980)
Co-authored-by: Tim Lai <[email protected]>
1 parent 630178f commit 31717db

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

flavors/swagger-ui-react/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,12 @@ If set, it persists authorization data and it would not be lost on browser close
158158

159159
⚠️ This prop is currently only applied once, on mount. Changes to this prop's value will not be propagated to the underlying Swagger UI instance. A future version of this module will remove this limitation, and the change will not be considered a breaking change.
160160

161+
#### `withCredentials`: PropTypes.bool
162+
163+
If set to `true`, enables passing credentials, [as defined in the Fetch standard](https://fetch.spec.whatwg.org/#credentials), in CORS requests that are sent by the browser. Note that Swagger UI cannot currently set cookies cross-domain (see [swagger-js#1163](https://github.com/swagger-api/swagger-js/issues/1163)) - as a result, you will have to rely on browser-supplied cookies (which this setting enables sending) that Swagger UI cannot control.
164+
165+
⚠️ This prop is currently only applied once, on mount. Changes to this prop's value will not be propagated to the underlying Swagger UI instance. A future version of this module will remove this limitation, and the change will not be considered a breaking change.
166+
161167
## Limitations
162168

163169
* Not all configuration bindings are available.

flavors/swagger-ui-react/index.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export default class SwaggerUI extends React.Component {
3535
showExtensions: this.props.showExtensions,
3636
filter: ["boolean", "string"].includes(typeof this.props.filter) ? this.props.filter : false,
3737
persistAuthorization: this.props.persistAuthorization,
38+
withCredentials: this.props.withCredentials,
3839
})
3940

4041
this.system = ui
@@ -129,6 +130,7 @@ SwaggerUI.propTypes = {
129130
tryItOutEnabled: PropTypes.bool,
130131
displayRequestDuration: PropTypes.bool,
131132
persistAuthorization: PropTypes.bool,
133+
withCredentials: PropTypes.bool,
132134
}
133135

134136
SwaggerUI.defaultProps = {

0 commit comments

Comments
 (0)