feat(swagger-ui-react): Add withCredentials prop (#7980)

Co-authored-by: Tim Lai <timothy.lai@gmail.com>
This commit is contained in:
Simon Podlipsky
2022-05-02 23:25:36 +02:00
committed by GitHub
parent 630178f6a1
commit 31717dbb38
2 changed files with 8 additions and 0 deletions

View File

@@ -158,6 +158,12 @@ If set, it persists authorization data and it would not be lost on browser close
⚠️ 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. ⚠️ 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.
#### `withCredentials`: PropTypes.bool
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.
⚠️ 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.
## Limitations ## Limitations
* Not all configuration bindings are available. * Not all configuration bindings are available.

View File

@@ -35,6 +35,7 @@ export default class SwaggerUI extends React.Component {
showExtensions: this.props.showExtensions, showExtensions: this.props.showExtensions,
filter: ["boolean", "string"].includes(typeof this.props.filter) ? this.props.filter : false, filter: ["boolean", "string"].includes(typeof this.props.filter) ? this.props.filter : false,
persistAuthorization: this.props.persistAuthorization, persistAuthorization: this.props.persistAuthorization,
withCredentials: this.props.withCredentials,
}) })
this.system = ui this.system = ui
@@ -129,6 +130,7 @@ SwaggerUI.propTypes = {
tryItOutEnabled: PropTypes.bool, tryItOutEnabled: PropTypes.bool,
displayRequestDuration: PropTypes.bool, displayRequestDuration: PropTypes.bool,
persistAuthorization: PropTypes.bool, persistAuthorization: PropTypes.bool,
withCredentials: PropTypes.bool,
} }
SwaggerUI.defaultProps = { SwaggerUI.defaultProps = {