From 38def57c2d957d680ecb177d9ae5d8dfdc6ff6c5 Mon Sep 17 00:00:00 2001 From: Laurence Hudson <40167760+laurence-hudson-mindfoundry@users.noreply.github.com> Date: Wed, 20 Mar 2019 02:04:34 +0000 Subject: [PATCH] improvement: expose docExpansion as a prop in swagger-ui-react (via #5242) * improvement: expose docExpansion setting as a prop in swagger-ui-react * Update README.md * Update index.js * Update README.md * Update README.md --- flavors/swagger-ui-react/README.md | 7 +++++++ flavors/swagger-ui-react/index.js | 2 ++ 2 files changed, 9 insertions(+) diff --git a/flavors/swagger-ui-react/README.md b/flavors/swagger-ui-react/README.md index b3d9feb1814..4c658da4816 100644 --- a/flavors/swagger-ui-react/README.md +++ b/flavors/swagger-ui-react/README.md @@ -65,9 +65,16 @@ or a Promise that resolves to a request object. A function that accepts a response object, and returns either a response object or a Promise that resolves to a response object. +#### `docExpansion`: PropTypes.oneOf(['list', 'full', 'none']) + +Controls the default expansion setting for the operations and tags. It can be 'list' (expands only the tags), 'full' (expands the tags and operations) or 'none' (expands nothing). The default value is 'list'. + +⚠️ 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. +* Some props are only applied on mount, and cannot be updated reliably. * OAuth redirection handling is not supported. * Topbar/Standalone mode is not supported. * Custom plugins are not supported. diff --git a/flavors/swagger-ui-react/index.js b/flavors/swagger-ui-react/index.js index c19ca93b841..206ee74973d 100644 --- a/flavors/swagger-ui-react/index.js +++ b/flavors/swagger-ui-react/index.js @@ -16,6 +16,7 @@ export default class SwaggerUI extends React.Component { requestInterceptor: this.requestInterceptor, responseInterceptor: this.responseInterceptor, onComplete: this.onComplete, + docExpansion: this.props.docExpansion, }) this.system = ui @@ -80,4 +81,5 @@ SwaggerUI.propTypes = { requestInterceptor: PropTypes.func, responseInterceptor: PropTypes.func, onComplete: PropTypes.func, + docExpansion: PropTypes.oneOf(['list', 'full', 'none']), }