-
Notifications
You must be signed in to change notification settings - Fork 762
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(resolver): collect errors in ParameterMacroVisitor visitor hooks (…
…#2813) This change in specific to OpenAPI 3.1.0 resolution strategy. Errors are now collected, instead of thrown and visitor traversal is not interrupted. Refs #2812
- v3.32.4
- v3.32.3
- v3.32.2
- v3.32.1
- v3.32.0
- v3.31.0
- v3.30.1
- v3.30.0
- v3.29.4
- v3.29.3
- v3.29.2
- v3.29.1
- v3.29.0
- v3.28.3
- v3.28.2
- v3.28.1
- v3.28.0
- v3.27.9
- v3.27.8
- v3.27.7
- v3.27.6
- v3.27.5
- v3.27.4
- v3.27.3
- v3.27.2
- v3.27.1
- v3.27.0
- v3.26.8
- v3.26.7
- v3.26.6
- v3.26.5
- v3.26.4
- v3.26.3
- v3.26.2
- v3.26.1
- v3.26.0
- v3.25.4
- v3.25.3
- v3.25.2
- v3.25.1
- v3.25.0
- v3.24.6
- v3.24.5
- v3.24.4
- v3.24.3
- v3.24.2
- v3.24.1
- v3.24.0
- v3.23.1
- v3.23.0
- v3.22.3
- v3.22.2
- v3.22.1
- v3.22.0
- v3.21.0
- v3.20.2
- v3.20.1
- v3.20.0
- v3.19.11
- v3.19.10
- v3.19.9
- v3.19.8
- v3.19.7
- v3.19.6
- v3.19.5
- v3.19.4
- v3.19.3
- v3.19.2
- v3.19.1
- v3.19.0
- v3.19.0-beta.8
- v3.19.0-beta.7
- v3.19.0-beta.6
- v3.19.0-beta.5
- v3.19.0-beta.4
- v3.19.0-beta.3
- v3.19.0-beta.2
- v3.19.0-beta.1
- v3.19.0-alpha.4
Showing
5 changed files
with
268 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 26 additions & 11 deletions
37
...apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/parameters.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,42 @@ | ||
import { toValue } from '@swagger-api/apidom-core'; | ||
|
||
const ParameterMacroVisitor = ({ parameterMacro }) => { | ||
let macroOperation = null; | ||
import compose from '../utils/compose.js'; | ||
import toPath from '../utils/to-path.js'; | ||
|
||
const ParameterMacroVisitor = compose({ | ||
init({ parameterMacro, options }) { | ||
this.parameterMacro = parameterMacro; | ||
this.options = options; | ||
}, | ||
props: { | ||
parameterMacro: null, | ||
options: null, | ||
macroOperation: null, | ||
|
||
return { | ||
OperationElement: { | ||
enter(operationElement) { | ||
macroOperation = operationElement; | ||
this.macroOperation = operationElement; | ||
}, | ||
leave() { | ||
macroOperation = null; | ||
this.macroOperation = null; | ||
}, | ||
}, | ||
ParameterElement: { | ||
leave(parameterElement) { | ||
const pojoOperation = macroOperation === null ? null : toValue(macroOperation); | ||
leave(parameterElement, key, parent, path, ancestors) { | ||
const pojoOperation = this.macroOperation === null ? null : toValue(this.macroOperation); | ||
const pojoParameter = toValue(parameterElement); | ||
const defaultValue = parameterMacro(pojoOperation, pojoParameter); | ||
|
||
parameterElement.set('default', defaultValue); | ||
try { | ||
const macroValue = this.parameterMacro(pojoOperation, pojoParameter); | ||
parameterElement.set('default', macroValue); | ||
} catch (error) { | ||
const macroError = new Error(error, { cause: error }); | ||
macroError.fullPath = toPath([...ancestors, parent]); | ||
this.options.dereference.dereferenceOpts?.errors?.push?.(macroError); | ||
} | ||
}, | ||
}, | ||
}; | ||
}; | ||
}, | ||
}); | ||
|
||
export default ParameterMacroVisitor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters