From b99ebe7dd3ed411380b487bd719a21b5c0b12b58 Mon Sep 17 00:00:00 2001 From: Tim Lai Date: Wed, 29 Jul 2020 16:11:20 -0700 Subject: [PATCH] feat(swagger-ui-react): option for showMutatedRequest (#6273) Co-authored-by: neel --- flavors/swagger-ui-react/README.md | 6 ++++++ flavors/swagger-ui-react/index.js | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/flavors/swagger-ui-react/README.md b/flavors/swagger-ui-react/README.md index 5986dd2b..26ac238c 100644 --- a/flavors/swagger-ui-react/README.md +++ b/flavors/swagger-ui-react/README.md @@ -95,6 +95,12 @@ HTTP methods that have the Try it out feature enabled. An empty array disables T ⚠️ 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. +#### `showMutatedRequest`: PropTypes.bool + +If set to `true`, uses the mutated request returned from a requestInterceptor to produce the curl command in the UI, otherwise the request before the requestInterceptor was applied is used. + +⚠️ 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 * Not all configuration bindings are available. diff --git a/flavors/swagger-ui-react/index.js b/flavors/swagger-ui-react/index.js index 8a58dd03..361c08bf 100644 --- a/flavors/swagger-ui-react/index.js +++ b/flavors/swagger-ui-react/index.js @@ -21,6 +21,7 @@ export default class SwaggerUI extends React.Component { supportedSubmitMethods: this.props.supportedSubmitMethods, defaultModelExpandDepth: this.props.defaultModelExpandDepth, displayOperationId: this.props.displayOperationId, + showMutatedRequest: typeof this.props.showMutatedRequest === "boolean" ? this.props.showMutatedRequest : true, }) this.system = ui @@ -88,10 +89,11 @@ SwaggerUI.propTypes = { docExpansion: PropTypes.oneOf(['list', 'full', 'none']), supportedSubmitMethods: PropTypes.arrayOf( PropTypes.oneOf(['get', 'put', 'post', 'delete', 'options', 'head', 'patch', 'trace']) - ), + ), defaultModelExpandDepth: PropTypes.number, plugins: PropTypes.arrayOf(PropTypes.object), displayOperationId: PropTypes.bool, + showMutatedRequest: PropTypes.bool, } SwaggerUI.defaultProps = {