From bbb080cfc16854d1388d6c4357454c070020b3bc Mon Sep 17 00:00:00 2001 From: Laurence Hudson Date: Sun, 17 Mar 2019 20:22:36 +0000 Subject: [PATCH 1/5] improvement: expose docExpansion setting as a prop in swagger-ui-react --- flavors/swagger-ui-react/README.md | 6 ++++++ flavors/swagger-ui-react/index.js | 2 ++ 2 files changed, 8 insertions(+) diff --git a/flavors/swagger-ui-react/README.md b/flavors/swagger-ui-react/README.md index b3d9feb1814..df24530e4f0 100644 --- a/flavors/swagger-ui-react/README.md +++ b/flavors/swagger-ui-react/README.md @@ -65,6 +65,12 @@ 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. +#### `initalDocExpansion`: 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 only applied on mount, subsequent changes to this prop will not be applied. + ## Limitations * Not all configuration bindings are available. diff --git a/flavors/swagger-ui-react/index.js b/flavors/swagger-ui-react/index.js index c19ca93b841..4c26b0e2e30 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.initalDocExpansion, }) this.system = ui @@ -80,4 +81,5 @@ SwaggerUI.propTypes = { requestInterceptor: PropTypes.func, responseInterceptor: PropTypes.func, onComplete: PropTypes.func, + initalDocExpansion: PropTypes.oneOf(['list', 'full', 'none']), } From 493ab6a4c9beeeeb79165f6287adbe475b5c3dc7 Mon Sep 17 00:00:00 2001 From: kyle Date: Tue, 19 Mar 2019 18:43:46 -0700 Subject: [PATCH 2/5] Update README.md --- flavors/swagger-ui-react/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/flavors/swagger-ui-react/README.md b/flavors/swagger-ui-react/README.md index df24530e4f0..7a68efc464d 100644 --- a/flavors/swagger-ui-react/README.md +++ b/flavors/swagger-ui-react/README.md @@ -65,7 +65,7 @@ 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. -#### `initalDocExpansion`: PropTypes.oneOf(['list', 'full', 'none']) +#### `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'. @@ -74,6 +74,7 @@ Controls the default expansion setting for the operations and tags. It can be 'l ## 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. From 6c5fe4522b7374e21d9beb266c102cde7e62ad7f Mon Sep 17 00:00:00 2001 From: kyle Date: Tue, 19 Mar 2019 18:44:23 -0700 Subject: [PATCH 3/5] Update index.js --- flavors/swagger-ui-react/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flavors/swagger-ui-react/index.js b/flavors/swagger-ui-react/index.js index 4c26b0e2e30..206ee74973d 100644 --- a/flavors/swagger-ui-react/index.js +++ b/flavors/swagger-ui-react/index.js @@ -16,7 +16,7 @@ export default class SwaggerUI extends React.Component { requestInterceptor: this.requestInterceptor, responseInterceptor: this.responseInterceptor, onComplete: this.onComplete, - docExpansion: this.props.initalDocExpansion, + docExpansion: this.props.docExpansion, }) this.system = ui @@ -81,5 +81,5 @@ SwaggerUI.propTypes = { requestInterceptor: PropTypes.func, responseInterceptor: PropTypes.func, onComplete: PropTypes.func, - initalDocExpansion: PropTypes.oneOf(['list', 'full', 'none']), + docExpansion: PropTypes.oneOf(['list', 'full', 'none']), } From d1707fc28d6063e2d6ce34bf2e570498c9ee124f Mon Sep 17 00:00:00 2001 From: kyle Date: Tue, 19 Mar 2019 18:45:45 -0700 Subject: [PATCH 4/5] Update README.md --- flavors/swagger-ui-react/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flavors/swagger-ui-react/README.md b/flavors/swagger-ui-react/README.md index 7a68efc464d..d103fcaa59b 100644 --- a/flavors/swagger-ui-react/README.md +++ b/flavors/swagger-ui-react/README.md @@ -69,7 +69,7 @@ or a Promise that resolves to a response object. 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 only applied on mount, subsequent changes to this prop will not be applied. +⚠️ This prop is only applied once on mount. Changes to this prop's value will not be propagated to the underlying Swagger UI instance. ## Limitations From 04ef62392d0b09d62275bc8cf25784ee3e9348d6 Mon Sep 17 00:00:00 2001 From: kyle Date: Tue, 19 Mar 2019 18:59:16 -0700 Subject: [PATCH 5/5] Update README.md --- flavors/swagger-ui-react/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flavors/swagger-ui-react/README.md b/flavors/swagger-ui-react/README.md index d103fcaa59b..4c658da4816 100644 --- a/flavors/swagger-ui-react/README.md +++ b/flavors/swagger-ui-react/README.md @@ -69,7 +69,7 @@ or a Promise that resolves to a response object. 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 only applied once on mount. Changes to this prop's value will not be propagated to the underlying Swagger UI instance. +⚠️ 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