Skip to content

Commit 38def57

Browse files
improvement: expose docExpansion as a prop in swagger-ui-react (via swagger-api#5242)
* improvement: expose docExpansion setting as a prop in swagger-ui-react * Update README.md * Update index.js * Update README.md * Update README.md
1 parent 1a62988 commit 38def57

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

flavors/swagger-ui-react/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,16 @@ or a Promise that resolves to a request object.
6565
A function that accepts a response object, and returns either a response object
6666
or a Promise that resolves to a response object.
6767

68+
#### `docExpansion`: PropTypes.oneOf(['list', 'full', 'none'])
69+
70+
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'.
71+
72+
⚠️ 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.
73+
6874
## Limitations
6975

7076
* Not all configuration bindings are available.
77+
* Some props are only applied on mount, and cannot be updated reliably.
7178
* OAuth redirection handling is not supported.
7279
* Topbar/Standalone mode is not supported.
7380
* Custom plugins are not supported.

flavors/swagger-ui-react/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export default class SwaggerUI extends React.Component {
1616
requestInterceptor: this.requestInterceptor,
1717
responseInterceptor: this.responseInterceptor,
1818
onComplete: this.onComplete,
19+
docExpansion: this.props.docExpansion,
1920
})
2021

2122
this.system = ui
@@ -80,4 +81,5 @@ SwaggerUI.propTypes = {
8081
requestInterceptor: PropTypes.func,
8182
responseInterceptor: PropTypes.func,
8283
onComplete: PropTypes.func,
84+
docExpansion: PropTypes.oneOf(['list', 'full', 'none']),
8385
}

0 commit comments

Comments
 (0)