From ade47ca40ec4e46e9b42570576bf71c1d84571e5 Mon Sep 17 00:00:00 2001 From: Kyle Shockey Date: Wed, 29 Nov 2017 15:54:17 -0600 Subject: [PATCH 1/3] Add requestInterceptor to OAuth2 request authorization calls --- src/core/plugins/auth/actions.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/plugins/auth/actions.js b/src/core/plugins/auth/actions.js index 7a41a398..876a677d 100644 --- a/src/core/plugins/auth/actions.js +++ b/src/core/plugins/auth/actions.js @@ -139,7 +139,7 @@ export const authorizeAccessCodeWithBasicAuthentication = ( { auth, redirectUrl return authActions.authorizeRequest({body: buildFormData(form), name, url: schema.get("tokenUrl"), auth, headers}) } -export const authorizeRequest = ( data ) => ( { fn, authActions, errActions, authSelectors } ) => { +export const authorizeRequest = ( data ) => ( { fn, getConfigs, authActions, errActions, authSelectors } ) => { let { body, query={}, headers={}, name, url, auth } = data let { additionalQueryStringParams } = authSelectors.getConfigs() || {} let fetchUrl = url @@ -158,7 +158,8 @@ export const authorizeRequest = ( data ) => ( { fn, authActions, errActions, aut method: "post", headers: _headers, query: query, - body: body + body: body, + requestInterceptor: getConfigs().requestInterceptor }) .then(function (response) { let token = JSON.parse(response.data) From 23251185407ac0fa48eb44effada1fc0873a2ca1 Mon Sep 17 00:00:00 2001 From: Kyle Shockey Date: Wed, 29 Nov 2017 15:55:15 -0600 Subject: [PATCH 2/3] Add responseInterceptor as well --- src/core/plugins/auth/actions.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/plugins/auth/actions.js b/src/core/plugins/auth/actions.js index 876a677d..d264c65d 100644 --- a/src/core/plugins/auth/actions.js +++ b/src/core/plugins/auth/actions.js @@ -159,7 +159,8 @@ export const authorizeRequest = ( data ) => ( { fn, getConfigs, authActions, err headers: _headers, query: query, body: body, - requestInterceptor: getConfigs().requestInterceptor + requestInterceptor: getConfigs().requestInterceptor, + responseInterceptor: getConfigs().responseInterceptor }) .then(function (response) { let token = JSON.parse(response.data) From e6ecb201c78ed35efd046f6f92d2ec59bcc3a65d Mon Sep 17 00:00:00 2001 From: Kyle Shockey Date: Wed, 29 Nov 2017 21:06:25 -0600 Subject: [PATCH 3/3] Update interceptor documentation --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a912fdc3..f517b085 100644 --- a/README.md +++ b/README.md @@ -162,8 +162,8 @@ displayRequestDuration | Controls the display of the request duration (in millis maxDisplayedTags | If set, limits the number of tagged operations displayed to at most this many. The default is to show all operations. filter | If set, enables filtering. The top bar will show an edit box that you can use to filter the tagged operations that are shown. Can be true/false to enable or disable, or an explicit filter string in which case filtering will be enabled using that string as the filter expression. Filtering is case sensitive matching the filter expression anywhere inside the tag. deepLinking | If set to `true`, enables dynamic deep linking for tags and operations. [Docs](https://github.com/swagger-api/swagger-ui/blob/master/docs/deep-linking.md) -requestInterceptor | MUST be a function. Function to intercept try-it-out requests. Accepts one argument requestInterceptor(request) and must return the potentially modified request. -responseInterceptor | MUST be a function. Function to intercept try-it-out responses. Accepts one argument responseInterceptor(response) and must return the potentially modified response. +requestInterceptor | MUST be a function. Function to intercept remote definition, Try-It-Out, and OAuth2 requests. Accepts one argument requestInterceptor(request) and must return the potentially modified request. +responseInterceptor | MUST be a function. Function to intercept remote definition, Try-It-Out, and OAuth2 responses. Accepts one argument responseInterceptor(response) and must return the potentially modified response. showMutatedRequest | If set to `true` (the default), uses the mutated request returned from a rquestInterceptor to produce the curl command in the UI, otherwise the request before the requestInterceptor was applied is used. showExtensions | Controls the display of vendor extension (`x-`) fields and values for Operations, Parameters, and Schema. The default is `false`.