Skip to content

Commit

Permalink
feat(swagger-ui-react): defaultModelExpandDepth and plugins props (
Browse files Browse the repository at this point in the history
…#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 <[email protected]>
Co-authored-by: kyle shockey <[email protected]>
  • Loading branch information
3 people committed Jan 5, 2020
1 parent 87dfc8d commit 296f73a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions flavors/swagger-ui-react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ Controls the default expansion setting for the operations and tags. It can be 'l

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

#### `defaultModelExpandDepth`: PropTypes.number

The default expansion depth for models (set to -1 completely hide the models).

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

#### `plugins`: PropTypes.arrayOf(PropTypes.object),

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.

⚠️ 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
4 changes: 4 additions & 0 deletions flavors/swagger-ui-react/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ export default class SwaggerUI extends React.Component {

componentDidMount() {
const ui = swaggerUIConstructor({
plugins: this.props.plugins,
spec: this.props.spec,
url: this.props.url,
requestInterceptor: this.requestInterceptor,
responseInterceptor: this.responseInterceptor,
onComplete: this.onComplete,
docExpansion: this.props.docExpansion,
defaultModelExpandDepth: this.props.defaultModelExpandDepth,
})

this.system = ui
Expand Down Expand Up @@ -82,4 +84,6 @@ SwaggerUI.propTypes = {
responseInterceptor: PropTypes.func,
onComplete: PropTypes.func,
docExpansion: PropTypes.oneOf(['list', 'full', 'none']),
defaultModelExpandDepth: PropTypes.number,
plugins: PropTypes.arrayOf(PropTypes.object),
}

0 comments on commit 296f73a

Please sign in to comment.