Tmkasun ft/5367 support passing presets and default models expand depth (#6275)
* feat(swagger-ui-react): support for presets and defaultModelsExpandDepth Co-authored-by: Kasun Thennakoon <tmkasun@gmail.com>
This commit is contained in:
@@ -101,6 +101,12 @@ If set to `true`, uses the mutated request returned from a requestInterceptor to
|
|||||||
|
|
||||||
⚠️ 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.
|
⚠️ 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.
|
||||||
|
|
||||||
|
#### `presets`: PropTypes.arrayOf(PropTypes.func),
|
||||||
|
|
||||||
|
An array of functions 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
|
## Limitations
|
||||||
|
|
||||||
* Not all configuration bindings are available.
|
* Not all configuration bindings are available.
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import React from "react"
|
import React from "react"
|
||||||
import PropTypes from "prop-types"
|
import PropTypes from "prop-types"
|
||||||
import swaggerUIConstructor from "./swagger-ui"
|
import swaggerUIConstructor, {presets} from "./swagger-ui"
|
||||||
|
|
||||||
export default class SwaggerUI extends React.Component {
|
export default class SwaggerUI extends React.Component {
|
||||||
constructor (props) {
|
constructor (props) {
|
||||||
super(props)
|
super(props)
|
||||||
@@ -14,6 +13,8 @@ export default class SwaggerUI extends React.Component {
|
|||||||
plugins: this.props.plugins,
|
plugins: this.props.plugins,
|
||||||
spec: this.props.spec,
|
spec: this.props.spec,
|
||||||
url: this.props.url,
|
url: this.props.url,
|
||||||
|
defaultModelsExpandDepth: this.props.defaultModelsExpandDepth,
|
||||||
|
presets: [presets.apis,...this.props.presets],
|
||||||
requestInterceptor: this.requestInterceptor,
|
requestInterceptor: this.requestInterceptor,
|
||||||
responseInterceptor: this.responseInterceptor,
|
responseInterceptor: this.responseInterceptor,
|
||||||
onComplete: this.onComplete,
|
onComplete: this.onComplete,
|
||||||
@@ -90,12 +91,16 @@ SwaggerUI.propTypes = {
|
|||||||
supportedSubmitMethods: PropTypes.arrayOf(
|
supportedSubmitMethods: PropTypes.arrayOf(
|
||||||
PropTypes.oneOf(['get', 'put', 'post', 'delete', 'options', 'head', 'patch', 'trace'])
|
PropTypes.oneOf(['get', 'put', 'post', 'delete', 'options', 'head', 'patch', 'trace'])
|
||||||
),
|
),
|
||||||
defaultModelExpandDepth: PropTypes.number,
|
|
||||||
plugins: PropTypes.arrayOf(PropTypes.object),
|
plugins: PropTypes.arrayOf(PropTypes.object),
|
||||||
displayOperationId: PropTypes.bool,
|
displayOperationId: PropTypes.bool,
|
||||||
showMutatedRequest: PropTypes.bool,
|
showMutatedRequest: PropTypes.bool,
|
||||||
|
defaultModelExpandDepth: PropTypes.number,
|
||||||
|
presets: PropTypes.arrayOf(PropTypes.func),
|
||||||
}
|
}
|
||||||
|
|
||||||
SwaggerUI.defaultProps = {
|
SwaggerUI.defaultProps = {
|
||||||
supportedSubmitMethods: ['get', 'put', 'post', 'delete', 'options', 'head', 'patch', 'trace'],
|
supportedSubmitMethods: ['get', 'put', 'post', 'delete', 'options', 'head', 'patch', 'trace'],
|
||||||
|
docExpansion: "list",
|
||||||
|
defaultModelsExpandDepth: 1,
|
||||||
|
presets: []
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user