From 5c11bb5a455cc4f668a28b4291d4b1f9324d3087 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Gorej?= Date: Wed, 22 Mar 2023 09:12:27 +0100 Subject: [PATCH] fix(oas31): detect user request body edits in OpenAPI.paths (#8500) Affected wrapped selector was hasUserEditedBody. This commit fixes the bug by calling the original selector when path+method combination is not found in OpenAPI.webhooks field. Refs #8498 --- src/core/plugins/oas31/fn.js | 2 +- src/core/plugins/oas31/oas3-extensions/wrap-selectors.js | 4 +++- src/core/plugins/oas31/spec-extensions/wrap-selectors.js | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/core/plugins/oas31/fn.js b/src/core/plugins/oas31/fn.js index 6ef03e48..70dd5967 100644 --- a/src/core/plugins/oas31/fn.js +++ b/src/core/plugins/oas31/fn.js @@ -46,7 +46,7 @@ export const createOnlyOAS31SelectorWrapper = if (system.getSystem().specSelectors.isOAS31()) { const selectedValue = selector(state, ...args) return typeof selectedValue === "function" - ? selectedValue(system) + ? selectedValue(oriSelector, system) : selectedValue } else { return oriSelector(...args) diff --git a/src/core/plugins/oas31/oas3-extensions/wrap-selectors.js b/src/core/plugins/oas31/oas3-extensions/wrap-selectors.js index 1d6e0b12..5ccc36f5 100644 --- a/src/core/plugins/oas31/oas3-extensions/wrap-selectors.js +++ b/src/core/plugins/oas31/oas3-extensions/wrap-selectors.js @@ -4,12 +4,14 @@ import { createOnlyOAS31SelectorWrapper } from "../fn" export const hasUserEditedBody = createOnlyOAS31SelectorWrapper( - (state, path, method) => (system) => { + (state, path, method) => (oriSelector, system) => { const webhooks = system.specSelectors.webhooks() if (webhooks.hasIn([path, method])) { // try it out functionality is disabled for webhooks return false } + + return oriSelector(path, method) } ) diff --git a/src/core/plugins/oas31/spec-extensions/wrap-selectors.js b/src/core/plugins/oas31/spec-extensions/wrap-selectors.js index 048186ad..1f03ee9d 100644 --- a/src/core/plugins/oas31/spec-extensions/wrap-selectors.js +++ b/src/core/plugins/oas31/spec-extensions/wrap-selectors.js @@ -12,7 +12,7 @@ export const isOAS3 = } export const selectLicenseUrl = createOnlyOAS31SelectorWrapper( - () => (system) => { + () => (oriSelector, system) => { return system.oas31Selectors.selectLicenseUrl() } )