Skip to content

Commit 408bc1d

Browse files
author
andriysemenyuk
committed
# This is a combination of 2 commits.
# This is the 1st commit message: add support of filter prop to swagger-ui-react # This is the commit message #2: #`null` replaced with `false`
1 parent 491d641 commit 408bc1d

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

flavors/swagger-ui-react/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,12 @@ Controls whether the "Try it out" section should start enabled. The default is f
119119

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

122+
#### `filter`: PropTypes.oneOfType([PropTypes.string, PropTypes.bool])
123+
124+
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.
125+
126+
⚠️ 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.
127+
122128
## Limitations
123129

124130
* Not all configuration bindings are available.

flavors/swagger-ui-react/index.jsx

+8-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export default class SwaggerUI extends React.Component {
2626
tryItOutEnabled: this.props.tryItOutEnabled,
2727
showMutatedRequest: typeof this.props.showMutatedRequest === "boolean" ? this.props.showMutatedRequest : true,
2828
deepLinking: typeof this.props.deepLinking === "boolean" ? this.props.deepLinking : false,
29+
filter: (typeof this.props.filter === "boolean" || typeof this.props.filter === "string") ? this.props.filter : false,
2930
})
3031

3132
this.system = ui
@@ -94,15 +95,19 @@ SwaggerUI.propTypes = {
9495
docExpansion: PropTypes.oneOf(["list", "full", "none"]),
9596
supportedSubmitMethods: PropTypes.arrayOf(
9697
PropTypes.oneOf(["get", "put", "post", "delete", "options", "head", "patch", "trace"])
97-
),
98+
),
9899
plugins: PropTypes.arrayOf(PropTypes.object),
99100
displayOperationId: PropTypes.bool,
100101
showMutatedRequest: PropTypes.bool,
101102
defaultModelExpandDepth: PropTypes.number,
102103
defaultModelsExpandDepth: PropTypes.number,
103104
presets: PropTypes.arrayOf(PropTypes.func),
104105
deepLinking: PropTypes.bool,
105-
tryItOutEnabled: PropTypes.bool
106+
tryItOutEnabled: PropTypes.bool,
107+
filter: PropTypes.oneOfType([
108+
PropTypes.string,
109+
PropTypes.bool,
110+
]),
106111
}
107112

108113
SwaggerUI.defaultProps = {
@@ -112,4 +117,5 @@ SwaggerUI.defaultProps = {
112117
defaultModelsExpandDepth: 1,
113118
presets: [],
114119
deepLinking: false,
120+
filter: false,
115121
}

0 commit comments

Comments
 (0)