Skip to content

Commit

Permalink
feat(swagger-ui-react): add support for persistAuthorization prop (#7842
Browse files Browse the repository at this point in the history
)

Closes #7389
  • Loading branch information
kyori19 committed Mar 1, 2022
1 parent 8009035 commit 67dd4f6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions flavors/swagger-ui-react/README.md
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions flavors/swagger-ui-react/index.jsx
Expand Up @@ -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
Expand Down Expand Up @@ -122,6 +123,7 @@ SwaggerUI.propTypes = {
requestSnippets: PropTypes.object,
tryItOutEnabled: PropTypes.bool,
displayRequestDuration: PropTypes.bool,
persistAuthorization: PropTypes.bool,
}

SwaggerUI.defaultProps = {
Expand Down Expand Up @@ -155,4 +157,5 @@ SwaggerUI.defaultProps = {
defaultExpanded: true,
languages: null, // e.g. only show curl bash = ["curl_bash"]
},
persistAuthorization: false,
}

0 comments on commit 67dd4f6

Please sign in to comment.