mirror of
https://github.com/zoriya/elysia-swagger.git
synced 2025-12-06 08:46:10 +00:00
🔧 fix: 1.3.0-exp.1
This commit is contained in:
50
src/utils.ts
50
src/utils.ts
@@ -151,11 +151,44 @@ export const registerSchemaPath = ({
|
||||
}) => {
|
||||
hook = cloneHook(hook)
|
||||
|
||||
const contentType = hook?.type ?? [
|
||||
'application/json',
|
||||
'multipart/form-data',
|
||||
'text/plain'
|
||||
]
|
||||
if (hook.parse && !Array.isArray(hook.parse)) hook.parse = [hook.parse]
|
||||
|
||||
let contentType = (hook.parse as unknown[])
|
||||
?.map((x) => {
|
||||
switch (typeof x) {
|
||||
case 'string':
|
||||
return x
|
||||
|
||||
case 'object':
|
||||
if (x && typeof x.fn !== 'string') return
|
||||
|
||||
switch (x.fn) {
|
||||
case 'json':
|
||||
case 'application/json':
|
||||
return 'application/json'
|
||||
|
||||
case 'text':
|
||||
case 'text/plain':
|
||||
return 'text/plain'
|
||||
|
||||
case 'urlencoded':
|
||||
case 'application/x-www-form-urlencoded':
|
||||
return 'application/x-www-form-urlencoded'
|
||||
|
||||
case 'arrayBuffer':
|
||||
case 'application/octet-stream':
|
||||
return 'application/octet-stream'
|
||||
|
||||
case 'formdata':
|
||||
case 'multipart/form-data':
|
||||
return 'multipart/form-data'
|
||||
}
|
||||
}
|
||||
})
|
||||
.filter((x) => !!x)
|
||||
|
||||
if (!contentType || contentType.length === 0)
|
||||
contentType = ['application/json', 'multipart/form-data', 'text/plain']
|
||||
|
||||
path = toOpenAPIPath(path)
|
||||
|
||||
@@ -331,7 +364,6 @@ export const registerSchemaPath = ({
|
||||
|
||||
export const filterPaths = (
|
||||
paths: Record<string, any>,
|
||||
docsPath: string,
|
||||
{
|
||||
excludeStaticFile = true,
|
||||
exclude = []
|
||||
@@ -342,11 +374,6 @@ export const filterPaths = (
|
||||
) => {
|
||||
const newPaths: Record<string, any> = {}
|
||||
|
||||
// exclude docs path and OpenAPI json path
|
||||
const excludePaths = [`/${docsPath}`, `/${docsPath}/json`].map((p) =>
|
||||
normalize(p)
|
||||
)
|
||||
|
||||
for (const [key, value] of Object.entries(paths))
|
||||
if (
|
||||
!exclude.some((x) => {
|
||||
@@ -354,7 +381,6 @@ export const filterPaths = (
|
||||
|
||||
return x.test(key)
|
||||
}) &&
|
||||
!excludePaths.includes(key) &&
|
||||
!key.includes('*') &&
|
||||
(excludeStaticFile ? !key.includes('.') : true)
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user