Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/great-fans-warn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@gitbook/react-openapi": patch
---

Match OpenAPI operation paths regardless of trailing slash
8 changes: 7 additions & 1 deletion packages/react-openapi/src/resolveOpenAPIOperation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,13 @@ function getPathObject(
schema: OpenAPIV3.Document | OpenAPIV3_1.Document,
path: string
): 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;
}

/**
Expand Down
Loading