Add displayRequestDuration configuration option.
This commit is contained in:
@@ -139,6 +139,7 @@ parameterMacro | MUST be a function. Function to set default value to parameters
|
|||||||
modelPropertyMacro | MUST be a function. Function to set default values to each property in model. Accepts one argument modelPropertyMacro(property), property is immutable
|
modelPropertyMacro | MUST be a function. Function to set default values to each property in model. Accepts one argument modelPropertyMacro(property), property is immutable
|
||||||
docExpansion | 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 is 'list'.
|
docExpansion | 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 is 'list'.
|
||||||
displayOperationId | Controls the display of operationId in operations list. The default is `false`.
|
displayOperationId | Controls the display of operationId in operations list. The default is `false`.
|
||||||
|
displayRequestDuration | Controls the display of the request duration (in milliseconds) for `Try it out` requests. The default is `false`.
|
||||||
|
|
||||||
### Plugins
|
### Plugins
|
||||||
|
|
||||||
|
|||||||
@@ -28,11 +28,12 @@ Duration.propTypes = {
|
|||||||
export default class LiveResponse extends React.Component {
|
export default class LiveResponse extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
response: PropTypes.object.isRequired,
|
response: PropTypes.object.isRequired,
|
||||||
getComponent: PropTypes.func.isRequired
|
getComponent: PropTypes.func.isRequired,
|
||||||
|
displayRequestDuration: PropTypes.bool.isRequired
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { request, response, getComponent } = this.props
|
const { request, response, getComponent, displayRequestDuration } = this.props
|
||||||
|
|
||||||
const status = response.get("status")
|
const status = response.get("status")
|
||||||
const url = response.get("url")
|
const url = response.get("url")
|
||||||
@@ -94,7 +95,7 @@ export default class LiveResponse extends React.Component {
|
|||||||
hasHeaders ? <Headers headers={ returnObject }/> : null
|
hasHeaders ? <Headers headers={ returnObject }/> : null
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
duration ? <Duration duration={ duration } /> : null
|
displayRequestDuration && duration ? <Duration duration={ duration } /> : null
|
||||||
}
|
}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ export default class Operation extends PureComponent {
|
|||||||
allowTryItOut: PropTypes.bool,
|
allowTryItOut: PropTypes.bool,
|
||||||
|
|
||||||
displayOperationId: PropTypes.bool,
|
displayOperationId: PropTypes.bool,
|
||||||
|
displayRequestDuration: PropTypes.bool,
|
||||||
|
|
||||||
response: PropTypes.object,
|
response: PropTypes.object,
|
||||||
request: PropTypes.object,
|
request: PropTypes.object,
|
||||||
@@ -37,6 +38,7 @@ export default class Operation extends PureComponent {
|
|||||||
response: null,
|
response: null,
|
||||||
allowTryItOut: true,
|
allowTryItOut: true,
|
||||||
displayOperationId: false,
|
displayOperationId: false,
|
||||||
|
displayRequestDuration: false
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(props, context) {
|
constructor(props, context) {
|
||||||
@@ -107,7 +109,7 @@ export default class Operation extends PureComponent {
|
|||||||
request,
|
request,
|
||||||
allowTryItOut,
|
allowTryItOut,
|
||||||
displayOperationId,
|
displayOperationId,
|
||||||
|
displayRequestDuration,
|
||||||
fn,
|
fn,
|
||||||
getComponent,
|
getComponent,
|
||||||
specActions,
|
specActions,
|
||||||
@@ -250,6 +252,7 @@ export default class Operation extends PureComponent {
|
|||||||
produces={ produces }
|
produces={ produces }
|
||||||
producesValue={ operation.get("produces_value") }
|
producesValue={ operation.get("produces_value") }
|
||||||
pathMethod={ [path, method] }
|
pathMethod={ [path, method] }
|
||||||
|
displayRequestDuration={ displayRequestDuration }
|
||||||
fn={fn} />
|
fn={fn} />
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export default class Operations extends React.Component {
|
|||||||
const Collapse = getComponent("Collapse")
|
const Collapse = getComponent("Collapse")
|
||||||
|
|
||||||
let showSummary = layoutSelectors.showSummary()
|
let showSummary = layoutSelectors.showSummary()
|
||||||
let { docExpansion, displayOperationId } = getConfigs()
|
let { docExpansion, displayOperationId, displayRequestDuration } = getConfigs()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
@@ -87,6 +87,7 @@ export default class Operations extends React.Component {
|
|||||||
allowTryItOut={allowTryItOut}
|
allowTryItOut={allowTryItOut}
|
||||||
|
|
||||||
displayOperationId={displayOperationId}
|
displayOperationId={displayOperationId}
|
||||||
|
displayRequestDuration={displayRequestDuration}
|
||||||
|
|
||||||
specActions={ specActions }
|
specActions={ specActions }
|
||||||
specSelectors={ specSelectors }
|
specSelectors={ specSelectors }
|
||||||
|
|||||||
@@ -14,19 +14,21 @@ export default class Responses extends React.Component {
|
|||||||
specSelectors: PropTypes.object.isRequired,
|
specSelectors: PropTypes.object.isRequired,
|
||||||
specActions: PropTypes.object.isRequired,
|
specActions: PropTypes.object.isRequired,
|
||||||
pathMethod: PropTypes.array.isRequired,
|
pathMethod: PropTypes.array.isRequired,
|
||||||
|
displayRequestDuration: PropTypes.bool.isRequired,
|
||||||
fn: PropTypes.object.isRequired
|
fn: PropTypes.object.isRequired
|
||||||
}
|
}
|
||||||
|
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
request: null,
|
request: null,
|
||||||
tryItOutResponse: null,
|
tryItOutResponse: null,
|
||||||
produces: fromJS(["application/json"])
|
produces: fromJS(["application/json"]),
|
||||||
|
displayRequestDuration: false
|
||||||
}
|
}
|
||||||
|
|
||||||
onChangeProducesWrapper = ( val ) => this.props.specActions.changeProducesValue(this.props.pathMethod, val)
|
onChangeProducesWrapper = ( val ) => this.props.specActions.changeProducesValue(this.props.pathMethod, val)
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let { responses, request, tryItOutResponse, getComponent, specSelectors, fn, producesValue } = this.props
|
let { responses, request, tryItOutResponse, getComponent, specSelectors, fn, producesValue, displayRequestDuration } = this.props
|
||||||
let defaultCode = defaultStatusCode( responses )
|
let defaultCode = defaultStatusCode( responses )
|
||||||
|
|
||||||
const ContentType = getComponent( "contentType" )
|
const ContentType = getComponent( "contentType" )
|
||||||
@@ -53,7 +55,8 @@ export default class Responses extends React.Component {
|
|||||||
: <div>
|
: <div>
|
||||||
<LiveResponse request={ request }
|
<LiveResponse request={ request }
|
||||||
response={ tryItOutResponse }
|
response={ tryItOutResponse }
|
||||||
getComponent={ getComponent } />
|
getComponent={ getComponent }
|
||||||
|
displayRequestDuration={ displayRequestDuration } />
|
||||||
<h4>Responses</h4>
|
<h4>Responses</h4>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { parseSeach, filterConfigs } from "core/utils"
|
|||||||
|
|
||||||
const CONFIGS = [ "url", "spec", "validatorUrl", "onComplete", "onFailure", "authorizations", "docExpansion",
|
const CONFIGS = [ "url", "spec", "validatorUrl", "onComplete", "onFailure", "authorizations", "docExpansion",
|
||||||
"apisSorter", "operationsSorter", "supportedSubmitMethods", "dom_id", "defaultModelRendering", "oauth2RedirectUrl",
|
"apisSorter", "operationsSorter", "supportedSubmitMethods", "dom_id", "defaultModelRendering", "oauth2RedirectUrl",
|
||||||
"showRequestHeaders", "custom", "modelPropertyMacro", "parameterMacro", "displayOperationId" ]
|
"showRequestHeaders", "custom", "modelPropertyMacro", "parameterMacro", "displayOperationId" , "displayRequestDuration"]
|
||||||
|
|
||||||
// eslint-disable-next-line no-undef
|
// eslint-disable-next-line no-undef
|
||||||
const { GIT_DIRTY, GIT_COMMIT, PACKAGE_VERSION } = buildInfo
|
const { GIT_DIRTY, GIT_COMMIT, PACKAGE_VERSION } = buildInfo
|
||||||
@@ -29,6 +29,7 @@ module.exports = function SwaggerUI(opts) {
|
|||||||
configs: {},
|
configs: {},
|
||||||
custom: {},
|
custom: {},
|
||||||
displayOperationId: false,
|
displayOperationId: false,
|
||||||
|
displayRequestDuration: false,
|
||||||
|
|
||||||
// Initial set of plugins ( TODO rename this, or refactor - we don't need presets _and_ plugins. Its just there for performance.
|
// Initial set of plugins ( TODO rename this, or refactor - we don't need presets _and_ plugins. Its just there for performance.
|
||||||
// Instead, we can compile the first plugin ( it can be a collection of plugins ), then batch the rest.
|
// Instead, we can compile the first plugin ( it can be a collection of plugins ), then batch the rest.
|
||||||
|
|||||||
Reference in New Issue
Block a user