Skip to content

Commit 901425f

Browse files
committed
docs: add description for pathMappingResolver
1 parent 69f4ca9 commit 901425f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/openapi/openapi3.mapping.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,24 @@ export const singleOperationPathMappingResolver: MappingResolver<string> = (befo
3232
return result
3333
}
3434

35+
/**
36+
* Maps OpenAPI path keys between two versions of the spec by considering possible base path changes
37+
* defined in the root object `servers` field and path item object `servers` field.
38+
* This mapping normalizes (unifies) paths by removing any basePath prefixes
39+
* so that equivalent endpoints are recognized and correctly mapped even if the base path (URL prefix)
40+
* has changed. It does *not* handle server base paths defined at the operation level.
41+
* It also maps paths even if path parameters have changed.
42+
*
43+
* @param before - The "before" object representing a set of OpenAPI paths (mapping string keys to PathItemObject)
44+
* @param after - The "after" object representing a set of OpenAPI paths (mapping string keys to PathItemObject)
45+
* @param ctx - The NodeContext, used here to access the root OpenAPI Document for both "before" and "after"
46+
* @returns {MapKeysResult<string>} An object containing arrays of `added` and `removed` path keys, and
47+
* a mapping between old and new keys for matched paths.
48+
*
49+
* @remarks
50+
* This method does not support mapping when the base path is defined in the operation-level `servers`.
51+
* See related test: "Should match operation when prefix moved from operation object servers to path".
52+
*/
3553
export const pathMappingResolver: MappingResolver<string> = (before, after, ctx) => {
3654

3755
const result: MapKeysResult<string> = { added: [], removed: [], mapped: {} }

0 commit comments

Comments
 (0)