Skip to content

Commit f3c0393

Browse files
authored
Merge pull request #314 from Necrelox/hotfix/310
[#310] : [BUG] Handle schema references without full path prefix in toRef (@elysiajs/openapi : 1.4.12)
2 parents 8c3b27a + bce2aa6 commit f3c0393

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/openapi.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ import { defineConfig } from 'tsup'
2626
export const capitalize = (word: string) =>
2727
word.charAt(0).toUpperCase() + word.slice(1)
2828

29-
const toRef = (name: string) => t.Ref(`#/components/schemas/${name}`)
29+
const toRef = (name: string) => t.Ref(
30+
name.startsWith('#/')
31+
? name
32+
: `#/components/schemas/${name}`
33+
)
3034

3135
const toOperationId = (method: string, paths: string) => {
3236
let operationId = method.toLowerCase()
@@ -237,7 +241,7 @@ const normalizeSchemaReference = (
237241

238242
// Convert string reference to t.Ref node
239243
// This allows string aliases to participate in schema composition
240-
return t.Ref(schema)
244+
return toRef(schema)
241245
}
242246

243247
/**

0 commit comments

Comments
 (0)