From 67dd4f6a8daca575ef9b824f785f554d05079041 Mon Sep 17 00:00:00 2001 From: kyori19 Date: Tue, 1 Mar 2022 18:54:03 +0900 Subject: [PATCH] feat(swagger-ui-react): add support for persistAuthorization prop (#7842) Closes #7389 --- flavors/swagger-ui-react/README.md | 6 ++++++ flavors/swagger-ui-react/index.jsx | 3 +++ 2 files changed, 9 insertions(+) diff --git a/flavors/swagger-ui-react/README.md b/flavors/swagger-ui-react/README.md index f0ae7c09..02f4ac73 100644 --- a/flavors/swagger-ui-react/README.md +++ b/flavors/swagger-ui-react/README.md @@ -152,6 +152,12 @@ Configures the request snippet core plugin. See Swagger UI's [Display Configurat ⚠️ 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. +#### `persistAuthorization`: PropTypes.bool + +If set, it persists authorization data and it would not be lost on browser close/refresh. The default is false. + +⚠️ 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 * Not all configuration bindings are available. diff --git a/flavors/swagger-ui-react/index.jsx b/flavors/swagger-ui-react/index.jsx index aa5d0163..7762e4b7 100644 --- a/flavors/swagger-ui-react/index.jsx +++ b/flavors/swagger-ui-react/index.jsx @@ -33,6 +33,7 @@ export default class SwaggerUI extends React.Component { deepLinking: typeof this.props.deepLinking === "boolean" ? this.props.deepLinking : false, showExtensions: this.props.showExtensions, filter: ["boolean", "string"].includes(typeof this.props.filter) ? this.props.filter : false, + persistAuthorization: this.props.persistAuthorization, }) this.system = ui @@ -122,6 +123,7 @@ SwaggerUI.propTypes = { requestSnippets: PropTypes.object, tryItOutEnabled: PropTypes.bool, displayRequestDuration: PropTypes.bool, + persistAuthorization: PropTypes.bool, } SwaggerUI.defaultProps = { @@ -155,4 +157,5 @@ SwaggerUI.defaultProps = { defaultExpanded: true, languages: null, // e.g. only show curl bash = ["curl_bash"] }, + persistAuthorization: false, }