Skip to content

Commit b71446c

Browse files
authored
feat(swagger-ui-react): add support of filter prop (#7547)
Co-authored-by: Mahtis Michel <mathis.michel@outlook.de> Co-authored-by: Vladimir Gorej <vladimir.gorej@gmail.com> Closes #7546
1 parent 9d2b35a commit b71446c

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

flavors/swagger-ui-react/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ Controls whether the "Try it out" section should start enabled. The default is f
125125

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

128+
#### `filter`: PropTypes.oneOfType([PropTypes.string, PropTypes.bool])
129+
130+
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.
131+
128132
#### `requestSnippetsEnabled`: PropTypes.bool,
129133

130134
Enables the request snippet section. When disabled, the legacy curl snippet will be used. The default is false.

flavors/swagger-ui-react/index.jsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export default class SwaggerUI extends React.Component {
2929
showMutatedRequest: typeof this.props.showMutatedRequest === "boolean" ? this.props.showMutatedRequest : true,
3030
deepLinking: typeof this.props.deepLinking === "boolean" ? this.props.deepLinking : false,
3131
showExtensions: this.props.showExtensions,
32+
filter: ["boolean", "string"].includes(typeof this.props.filter) ? this.props.filter : false,
3233
})
3334

3435
this.system = ui
@@ -97,7 +98,7 @@ SwaggerUI.propTypes = {
9798
docExpansion: PropTypes.oneOf(["list", "full", "none"]),
9899
supportedSubmitMethods: PropTypes.arrayOf(
99100
PropTypes.oneOf(["get", "put", "post", "delete", "options", "head", "patch", "trace"])
100-
),
101+
),
101102
plugins: PropTypes.arrayOf(PropTypes.object),
102103
displayOperationId: PropTypes.bool,
103104
showMutatedRequest: PropTypes.bool,
@@ -106,6 +107,10 @@ SwaggerUI.propTypes = {
106107
presets: PropTypes.arrayOf(PropTypes.func),
107108
deepLinking: PropTypes.bool,
108109
showExtensions: PropTypes.bool,
110+
filter: PropTypes.oneOfType([
111+
PropTypes.string,
112+
PropTypes.bool,
113+
]),
109114
requestSnippetsEnabled: PropTypes.bool,
110115
requestSnippets: PropTypes.object,
111116
tryItOutEnabled: PropTypes.bool,
@@ -119,6 +124,7 @@ SwaggerUI.defaultProps = {
119124
presets: [],
120125
deepLinking: false,
121126
showExtensions: false,
127+
filter: false,
122128
requestSnippetsEnabled: false,
123129
requestSnippets: {
124130
generators: {

0 commit comments

Comments
 (0)