Skip to content

Commit 0e21f06

Browse files
committed
🔧 fix(type generator): add loose path type matching
1 parent e721283 commit 0e21f06

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 1.3.6 - 3 Sep 2025
2+
Improvement:
3+
- type generator: add loose path type matching
4+
15
# 1.3.5 - 3 Sep 2025
26
Bug fix:
37
- type generator: merge references with existing response status

src/openapi.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ const isValidSchema = (schema: any): schema is TSchema =>
6060
schema.properties ||
6161
schema.items)
6262

63+
export const getLoosePath = (path: string) => {
64+
if (path.charCodeAt(path.length - 1) === 47)
65+
return path.slice(0, path.length - 1)
66+
67+
return path + '/'
68+
}
69+
6370
/**
6471
* Converts Elysia routes to OpenAPI 3.0.3 paths schema
6572
* @param routes Array of Elysia route objects
@@ -115,7 +122,10 @@ export function toOpenAPISchema(
115122

116123
if (references)
117124
for (const reference of references as AdditionalReference[]) {
118-
const refer = reference[route.path]?.[method]
125+
const refer =
126+
reference[route.path]?.[method] ??
127+
reference[getLoosePath(route.path)]?.[method]
128+
119129
if (!refer) continue
120130

121131
if (!hooks.body && isValidSchema(refer.body))

0 commit comments

Comments
 (0)