Skip to content
Open
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
20 changes: 6 additions & 14 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ export const mapProperties = (
})
}

const makeRefString = ($ref: string) => !$ref.startsWith('#/components/schemas/')
? `#/components/schemas/${$ref}`
: $ref

const mapTypesResponse = (
types: string[],
schema:
Expand Down Expand Up @@ -81,26 +85,14 @@ const mapTypesResponse = (
schema[Kind] === 'Ref'
? {
...schema,
$ref: `#/components/schemas/${schema.$ref}`
$ref: makeRefString(schema.$ref)
}
: replaceSchemaType(
{ ...(schema as any) },
{
from: t.Ref(''),
// @ts-expect-error
to: ({ $ref, ...options }) => {
if (
!$ref.startsWith(
'#/components/schemas/'
)
)
return t.Ref(
`#/components/schemas/${$ref}`,
options
)

return t.Ref($ref, options)
}
to: ({ $ref, ...options }) => t.Ref(makeRefString($ref), options),
}
)
}
Expand Down
Loading