@elysiajs/swagger
Advanced tools
Comparing version 0.8.4 to 0.8.5
@@ -37,3 +37,3 @@ "use strict"; | ||
const relativePath = path.startsWith('/') ? path.slice(1) : path; | ||
app.get(path, () => { | ||
app.get(path, (() => { | ||
const combinedSwaggerOptions = { | ||
@@ -45,12 +45,10 @@ url: `${relativePath}/json`, | ||
const stringifiedSwaggerOptions = JSON.stringify(combinedSwaggerOptions, (key, value) => { | ||
if (typeof value == 'function') { | ||
if (typeof value == 'function') | ||
return undefined; | ||
} | ||
else { | ||
return value; | ||
} | ||
return value; | ||
}); | ||
const scalarConfiguration = { | ||
spec: { | ||
url: `${relativePath}/json` | ||
...scalarConfig.spec, | ||
url: `${relativePath}/json`, | ||
}, | ||
@@ -66,3 +64,3 @@ ...scalarConfig | ||
}); | ||
}).get(`${path}/json`, () => { | ||
})()).get(`${path}/json`, () => { | ||
const routes = app.routes; | ||
@@ -69,0 +67,0 @@ if (routes.length !== totalRoutes) { |
@@ -31,3 +31,3 @@ "use strict"; | ||
// @ts-ignore | ||
required: schema.required?.includes(key) ?? false, | ||
required: schema.required?.includes(key) ?? false | ||
}; | ||
@@ -38,4 +38,4 @@ }); | ||
const mapTypesResponse = (types, schema) => { | ||
if (typeof schema === 'object' | ||
&& ['void', 'undefined', 'null'].includes(schema.type)) | ||
if (typeof schema === 'object' && | ||
['void', 'undefined', 'null'].includes(schema.type)) | ||
return; | ||
@@ -98,2 +98,3 @@ const responses = {}; | ||
properties, | ||
items: responseSchema.items, | ||
required | ||
@@ -123,7 +124,10 @@ } | ||
description: rest.description, | ||
content: mapTypesResponse(contentTypes, { | ||
type, | ||
properties, | ||
required | ||
}) | ||
content: mapTypesResponse(contentTypes, rest.type === 'object' || rest.type === 'array' | ||
? { | ||
type: rest.type, | ||
properties, | ||
items: value.items, | ||
required | ||
} | ||
: value) | ||
}; | ||
@@ -130,0 +134,0 @@ } |
@@ -34,3 +34,3 @@ import { SwaggerUIRender } from './swagger'; | ||
const relativePath = path.startsWith('/') ? path.slice(1) : path; | ||
app.get(path, () => { | ||
app.get(path, (() => { | ||
const combinedSwaggerOptions = { | ||
@@ -42,12 +42,10 @@ url: `${relativePath}/json`, | ||
const stringifiedSwaggerOptions = JSON.stringify(combinedSwaggerOptions, (key, value) => { | ||
if (typeof value == 'function') { | ||
if (typeof value == 'function') | ||
return undefined; | ||
} | ||
else { | ||
return value; | ||
} | ||
return value; | ||
}); | ||
const scalarConfiguration = { | ||
spec: { | ||
url: `${relativePath}/json` | ||
...scalarConfig.spec, | ||
url: `${relativePath}/json`, | ||
}, | ||
@@ -63,3 +61,3 @@ ...scalarConfig | ||
}); | ||
}).get(`${path}/json`, () => { | ||
})()).get(`${path}/json`, () => { | ||
const routes = app.routes; | ||
@@ -66,0 +64,0 @@ if (routes.length !== totalRoutes) { |
@@ -24,3 +24,3 @@ import { Kind } from '@sinclair/typebox'; | ||
// @ts-ignore | ||
required: schema.required?.includes(key) ?? false, | ||
required: schema.required?.includes(key) ?? false | ||
}; | ||
@@ -30,4 +30,4 @@ }); | ||
const mapTypesResponse = (types, schema) => { | ||
if (typeof schema === 'object' | ||
&& ['void', 'undefined', 'null'].includes(schema.type)) | ||
if (typeof schema === 'object' && | ||
['void', 'undefined', 'null'].includes(schema.type)) | ||
return; | ||
@@ -88,2 +88,3 @@ const responses = {}; | ||
properties, | ||
items: responseSchema.items, | ||
required | ||
@@ -113,7 +114,10 @@ } | ||
description: rest.description, | ||
content: mapTypesResponse(contentTypes, { | ||
type, | ||
properties, | ||
required | ||
}) | ||
content: mapTypesResponse(contentTypes, rest.type === 'object' || rest.type === 'array' | ||
? { | ||
type: rest.type, | ||
properties, | ||
items: value.items, | ||
required | ||
} | ||
: value) | ||
}; | ||
@@ -120,0 +124,0 @@ } |
{ | ||
"name": "@elysiajs/swagger", | ||
"version": "0.8.4", | ||
"version": "0.8.5", | ||
"description": "Plugin for Elysia to auto-generate Swagger page", | ||
@@ -5,0 +5,0 @@ "author": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
159290
4083