Skip to content

Commit 296f73a

Browse files
pmooney-jamatlemoine-jamashockey
committed
feat(swagger-ui-react): defaultModelExpandDepth and plugins props (#5594)
* Add plugins as React prop * Add defaultModelExpandDepth as React prop * Add documentation re: defaultModelExpandDepth and plugins props * Fetched latest and rebased on that * add on-mount-only warning messages to new options Co-authored-by: Todd Lemoine <43755148+tlemoine-jama@users.noreply.github.com> Co-authored-by: kyle shockey <kyleshockey@gmail.com>
1 parent 87dfc8d commit 296f73a

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

flavors/swagger-ui-react/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,18 @@ Controls the default expansion setting for the operations and tags. It can be 'l
7171

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

74+
#### `defaultModelExpandDepth`: PropTypes.number
75+
76+
The default expansion depth for models (set to -1 completely hide the models).
77+
78+
⚠️ 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.
79+
80+
#### `plugins`: PropTypes.arrayOf(PropTypes.object),
81+
82+
An array of objects that augment and modify Swagger UI's functionality. See Swagger UI's [Plugin API](https://github.com/swagger-api/swagger-ui/blob/master/docs/customization/plugin-api.md) for more details.
83+
84+
⚠️ 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.
85+
7486
## Limitations
7587

7688
* Not all configuration bindings are available.

flavors/swagger-ui-react/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ export default class SwaggerUI extends React.Component {
1111

1212
componentDidMount() {
1313
const ui = swaggerUIConstructor({
14+
plugins: this.props.plugins,
1415
spec: this.props.spec,
1516
url: this.props.url,
1617
requestInterceptor: this.requestInterceptor,
1718
responseInterceptor: this.responseInterceptor,
1819
onComplete: this.onComplete,
1920
docExpansion: this.props.docExpansion,
21+
defaultModelExpandDepth: this.props.defaultModelExpandDepth,
2022
})
2123

2224
this.system = ui
@@ -82,4 +84,6 @@ SwaggerUI.propTypes = {
8284
responseInterceptor: PropTypes.func,
8385
onComplete: PropTypes.func,
8486
docExpansion: PropTypes.oneOf(['list', 'full', 'none']),
87+
defaultModelExpandDepth: PropTypes.number,
88+
plugins: PropTypes.arrayOf(PropTypes.object),
8589
}

0 commit comments

Comments
 (0)