mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-21 10:03:31 +00:00
Match OpenAPI operation paths regardless of trailing slash (#4282)
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@gitbook/react-openapi": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Match OpenAPI operation paths regardless of trailing slash
|
||||||
@@ -101,7 +101,13 @@ function getPathObject(
|
|||||||
schema: OpenAPIV3.Document | OpenAPIV3_1.Document,
|
schema: OpenAPIV3.Document | OpenAPIV3_1.Document,
|
||||||
path: string
|
path: string
|
||||||
): OpenAPIV3.PathItemObject | OpenAPIV3_1.PathItemObject | null {
|
): OpenAPIV3.PathItemObject | OpenAPIV3_1.PathItemObject | null {
|
||||||
return schema.paths?.[path] || null;
|
const paths = schema.paths;
|
||||||
|
if (!paths) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
// Match regardless of a trailing slash, which specs may or may not include
|
||||||
|
const alternatePath = path.endsWith('/') ? path.slice(0, -1) : `${path}/`;
|
||||||
|
return paths[path] ?? paths[alternatePath] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user