Skip to content

Commit

Permalink
feat(swagger-ui-react): Enable displayRequestDuration prop (#7522)
Browse files Browse the repository at this point in the history
* feat(react): allow displayRequestDuration via react

* docs(react): added displayRequestDuration prop

* Update flavors/swagger-ui-react/README.md

Co-authored-by: Vladimir Gorej <vladimir.gorej@gmail.com>
Co-authored-by: Tim Lai <timothy.lai@gmail.com>
  • Loading branch information
3 people authored Jan 18, 2022
1 parent 3af8acf commit 85597b9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions flavors/swagger-ui-react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ Controls whether the "Try it out" section should start enabled. The default is f

⚠️ 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.

#### `displayRequestDuration`: PropTypes.bool

Controls the display of the request duration (in milliseconds) for "Try it out" requests. The default is false.

#### `filter`: PropTypes.oneOfType([PropTypes.string, PropTypes.bool])

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 Boolean to enable or disable, or a 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. See Swagger UI's [Plug Points](https://github.com/swagger-api/swagger-ui/blob/master/docs/customization/plug-points.md#fnopsfilter) to customize the filtering behavior.
Expand Down
3 changes: 3 additions & 0 deletions flavors/swagger-ui-react/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default class SwaggerUI extends React.Component {
defaultModelExpandDepth: this.props.defaultModelExpandDepth,
displayOperationId: this.props.displayOperationId,
tryItOutEnabled: this.props.tryItOutEnabled,
displayRequestDuration: this.props.displayRequestDuration,
requestSnippetsEnabled: this.props.requestSnippetsEnabled,
requestSnippets: this.props.requestSnippets,
showMutatedRequest: typeof this.props.showMutatedRequest === "boolean" ? this.props.showMutatedRequest : true,
Expand Down Expand Up @@ -118,6 +119,7 @@ SwaggerUI.propTypes = {
requestSnippetsEnabled: PropTypes.bool,
requestSnippets: PropTypes.object,
tryItOutEnabled: PropTypes.bool,
displayRequestDuration: PropTypes.bool,
}

SwaggerUI.defaultProps = {
Expand All @@ -129,6 +131,7 @@ SwaggerUI.defaultProps = {
defaultModelRendering: "example",
presets: [],
deepLinking: false,
displayRequestDuration: false,
showExtensions: false,
filter: false,
requestSnippetsEnabled: false,
Expand Down

0 comments on commit 85597b9

Please sign in to comment.