feat(swagger-ui-react): add support for layout prop (#6639)
layout prop represents the name of a component available via the plugin system to use as the top-level layout for Swagger UI.
This commit is contained in:
@@ -43,6 +43,12 @@ Remote URL to an OpenAPI document that Swagger UI will fetch, parse, and display
|
|||||||
|
|
||||||
⚠️ Don't use this in conjunction with `spec` - unpredictable behavior may occur.
|
⚠️ Don't use this in conjunction with `spec` - unpredictable behavior may occur.
|
||||||
|
|
||||||
|
#### `layout`: PropTypes.string
|
||||||
|
|
||||||
|
The name of a component available via the plugin system to use as the top-level layout for Swagger UI. The default value is `BaseLayout`.
|
||||||
|
|
||||||
|
⚠️ 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.
|
||||||
|
|
||||||
#### `onComplete`: PropTypes.func
|
#### `onComplete`: PropTypes.func
|
||||||
|
|
||||||
> `(system) => void`
|
> `(system) => void`
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ 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,
|
||||||
|
layout: this.props.layout,
|
||||||
defaultModelsExpandDepth: this.props.defaultModelsExpandDepth,
|
defaultModelsExpandDepth: this.props.defaultModelsExpandDepth,
|
||||||
presets: [presets.apis,...this.props.presets],
|
presets: [presets.apis,...this.props.presets],
|
||||||
requestInterceptor: this.requestInterceptor,
|
requestInterceptor: this.requestInterceptor,
|
||||||
@@ -85,23 +86,26 @@ SwaggerUI.propTypes = {
|
|||||||
PropTypes.object,
|
PropTypes.object,
|
||||||
]),
|
]),
|
||||||
url: PropTypes.string,
|
url: PropTypes.string,
|
||||||
|
layout: PropTypes.string,
|
||||||
requestInterceptor: PropTypes.func,
|
requestInterceptor: PropTypes.func,
|
||||||
responseInterceptor: PropTypes.func,
|
responseInterceptor: PropTypes.func,
|
||||||
onComplete: PropTypes.func,
|
onComplete: PropTypes.func,
|
||||||
docExpansion: PropTypes.oneOf(['list', 'full', 'none']),
|
docExpansion: PropTypes.oneOf(["list", "full", "none"]),
|
||||||
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"])
|
||||||
),
|
),
|
||||||
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,
|
defaultModelExpandDepth: PropTypes.number,
|
||||||
|
defaultModelsExpandDepth: PropTypes.number,
|
||||||
presets: PropTypes.arrayOf(PropTypes.func),
|
presets: PropTypes.arrayOf(PropTypes.func),
|
||||||
deepLinking: PropTypes.bool,
|
deepLinking: PropTypes.bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
SwaggerUI.defaultProps = {
|
SwaggerUI.defaultProps = {
|
||||||
supportedSubmitMethods: ['get', 'put', 'post', 'delete', 'options', 'head', 'patch', 'trace'],
|
layout: "BaseLayout",
|
||||||
|
supportedSubmitMethods: ["get", "put", "post", "delete", "options", "head", "patch", "trace"],
|
||||||
docExpansion: "list",
|
docExpansion: "list",
|
||||||
defaultModelsExpandDepth: 1,
|
defaultModelsExpandDepth: 1,
|
||||||
presets: [],
|
presets: [],
|
||||||
|
|||||||
Reference in New Issue
Block a user