Skip to content

Commit

Permalink
# This is a combination of 2 commits.
Browse files Browse the repository at this point in the history
# This is the 1st commit message:

add support of filter prop to swagger-ui-react

# This is the commit message swagger-api#2:

#`null` replaced with `false`
  • Loading branch information
andriysemenyuk committed Oct 8, 2021
1 parent 491d641 commit 408bc1d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 6 additions & 0 deletions flavors/swagger-ui-react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ 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.

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

Boolean=false OR String. 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.

⚠️ 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
10 changes: 8 additions & 2 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 {
tryItOutEnabled: this.props.tryItOutEnabled,
showMutatedRequest: typeof this.props.showMutatedRequest === "boolean" ? this.props.showMutatedRequest : true,
deepLinking: typeof this.props.deepLinking === "boolean" ? this.props.deepLinking : false,
filter: (typeof this.props.filter === "boolean" || typeof this.props.filter === "string") ? this.props.filter : false,
})

this.system = ui
Expand Down Expand Up @@ -94,15 +95,19 @@ SwaggerUI.propTypes = {
docExpansion: PropTypes.oneOf(["list", "full", "none"]),
supportedSubmitMethods: PropTypes.arrayOf(
PropTypes.oneOf(["get", "put", "post", "delete", "options", "head", "patch", "trace"])
),
),
plugins: PropTypes.arrayOf(PropTypes.object),
displayOperationId: PropTypes.bool,
showMutatedRequest: PropTypes.bool,
defaultModelExpandDepth: PropTypes.number,
defaultModelsExpandDepth: PropTypes.number,
presets: PropTypes.arrayOf(PropTypes.func),
deepLinking: PropTypes.bool,
tryItOutEnabled: PropTypes.bool
tryItOutEnabled: PropTypes.bool,
filter: PropTypes.oneOfType([
PropTypes.string,
PropTypes.bool,
]),
}

SwaggerUI.defaultProps = {
Expand All @@ -112,4 +117,5 @@ SwaggerUI.defaultProps = {
defaultModelsExpandDepth: 1,
presets: [],
deepLinking: false,
filter: false,
}

0 comments on commit 408bc1d

Please sign in to comment.