Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@elysiajs/swagger

Package Overview
Dependencies
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@elysiajs/swagger - npm Package Compare versions

Comparing version 0.7.3 to 0.7.4

10

dist/cjs/index.js

@@ -10,5 +10,5 @@ "use strict";

*/
const swagger = ({ documentation = {}, version = '5.7.2', excludeStaticFile = true, path = '/swagger', exclude = [], swaggerOptions = {}, theme = `https://unpkg.com/swagger-ui-dist@${version}/swagger-ui.css`, autoDarkMode = true } = {
const swagger = ({ documentation = {}, version = '5.9.0', excludeStaticFile = true, path = '/swagger', exclude = [], swaggerOptions = {}, theme = `https://unpkg.com/swagger-ui-dist@${version}/swagger-ui.css`, autoDarkMode = true } = {
documentation: {},
version: '5.7.2',
version: '5.9.0',
excludeStaticFile: true,

@@ -107,3 +107,3 @@ path: '/swagger',

// @ts-ignore
models: app.definitions.type,
models: app.definitions?.type,
contentType: route.hooks.type

@@ -119,3 +119,3 @@ });

title: 'Elysia Documentation',
description: 'Developement documentation',
description: 'Development documentation',
version: '0.0.0',

@@ -133,3 +133,3 @@ ...documentation.info

// @ts-ignore
...app.definitions.type,
...app.definitions?.type,
...documentation.components?.schemas

@@ -136,0 +136,0 @@ }

@@ -22,12 +22,14 @@ "use strict";

throw new Error(`Can't find model ${schema}`);
return Object.entries(schema?.properties ?? []).map(([key, value]) => ({
// @ts-ignore
...value,
in: name,
name: key,
// @ts-ignore
type: value?.type,
// @ts-ignore
required: schema.required?.includes(key) ?? false
}));
return Object.entries(schema?.properties ?? []).map(([key, value]) => {
const { type: valueType = undefined, ...rest } = value;
return {
// @ts-ignore
...rest,
schema: { type: valueType },
in: name,
name: key,
// @ts-ignore
required: schema.required?.includes(key) ?? false,
};
});
};

@@ -86,3 +88,3 @@ exports.mapProperties = mapProperties;

if (typebox_1.Kind in responseSchema) {
const { type, properties, required, ...rest } = responseSchema;
const { type, properties, required, additionalProperties, ...rest } = responseSchema;
responseSchema = {

@@ -108,3 +110,3 @@ '200': {

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { type, properties, required, ...rest } = models[value];
const { type, properties, required, additionalProperties: _, ...rest } = models[value];
responseSchema[key] = {

@@ -117,3 +119,3 @@ ...rest,

else {
const { type, properties, required, ...rest } = value;
const { type, properties, required, additionalProperties, ...rest } = value;
responseSchema[key] = {

@@ -136,3 +138,3 @@ ...rest,

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { type, properties, required, ...rest } = models[responseSchema];
const { type, properties, required, additionalProperties: _, ...rest } = models[responseSchema];
responseSchema = {

@@ -203,5 +205,5 @@ // @ts-ignore

.map((x) => ({
schema: { type: 'string' },
in: 'path',
name: x.slice(1, x.length - 1),
type: 'string',
required: true

@@ -208,0 +210,0 @@ })),

@@ -7,5 +7,5 @@ import { filterPaths, registerSchemaPath } from './utils';

*/
export const swagger = ({ documentation = {}, version = '5.7.2', excludeStaticFile = true, path = '/swagger', exclude = [], swaggerOptions = {}, theme = `https://unpkg.com/swagger-ui-dist@${version}/swagger-ui.css`, autoDarkMode = true } = {
export const swagger = ({ documentation = {}, version = '5.9.0', excludeStaticFile = true, path = '/swagger', exclude = [], swaggerOptions = {}, theme = `https://unpkg.com/swagger-ui-dist@${version}/swagger-ui.css`, autoDarkMode = true } = {
documentation: {},
version: '5.7.2',
version: '5.9.0',
excludeStaticFile: true,

@@ -104,3 +104,3 @@ path: '/swagger',

// @ts-ignore
models: app.definitions.type,
models: app.definitions?.type,
contentType: route.hooks.type

@@ -116,3 +116,3 @@ });

title: 'Elysia Documentation',
description: 'Developement documentation',
description: 'Development documentation',
version: '0.0.0',

@@ -130,3 +130,3 @@ ...documentation.info

// @ts-ignore
...app.definitions.type,
...app.definitions?.type,
...documentation.components?.schemas

@@ -133,0 +133,0 @@ }

@@ -15,12 +15,14 @@ import { Kind } from '@sinclair/typebox';

throw new Error(`Can't find model ${schema}`);
return Object.entries(schema?.properties ?? []).map(([key, value]) => ({
// @ts-ignore
...value,
in: name,
name: key,
// @ts-ignore
type: value?.type,
// @ts-ignore
required: schema.required?.includes(key) ?? false
}));
return Object.entries(schema?.properties ?? []).map(([key, value]) => {
const { type: valueType = undefined, ...rest } = value;
return {
// @ts-ignore
...rest,
schema: { type: valueType },
in: name,
name: key,
// @ts-ignore
required: schema.required?.includes(key) ?? false,
};
});
};

@@ -76,3 +78,3 @@ const mapTypesResponse = (types, schema) => {

if (Kind in responseSchema) {
const { type, properties, required, ...rest } = responseSchema;
const { type, properties, required, additionalProperties, ...rest } = responseSchema;
responseSchema = {

@@ -98,3 +100,3 @@ '200': {

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { type, properties, required, ...rest } = models[value];
const { type, properties, required, additionalProperties: _, ...rest } = models[value];
responseSchema[key] = {

@@ -107,3 +109,3 @@ ...rest,

else {
const { type, properties, required, ...rest } = value;
const { type, properties, required, additionalProperties, ...rest } = value;
responseSchema[key] = {

@@ -126,3 +128,3 @@ ...rest,

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { type, properties, required, ...rest } = models[responseSchema];
const { type, properties, required, additionalProperties: _, ...rest } = models[responseSchema];
responseSchema = {

@@ -192,5 +194,5 @@ // @ts-ignore

.map((x) => ({
schema: { type: 'string' },
in: 'path',
name: x.slice(1, x.length - 1),
type: 'string',
required: true

@@ -197,0 +199,0 @@ })),

{
"name": "@elysiajs/swagger",
"version": "0.7.3",
"version": "0.7.4",
"description": "Plugin for Elysia to auto-generate Swagger page",

@@ -18,3 +18,3 @@ "author": {

},
"types": "./src/index.ts",
"types": "./dist/index.d.ts",
"keywords": [

@@ -42,2 +42,3 @@ "elysia",

"devDependencies": {
"@apidevtools/swagger-parser": "^10.1.0",
"@types/node": "^20.1.4",

@@ -44,0 +45,0 @@ "bun-types": "^0.7.0",

@@ -16,5 +16,3 @@ # @elysiajs/swagger

.use(swagger())
.get('/', () => 'hi')
.get('/unpath/:id', ({ params: { id } }) => id)
.get('/unpath/:id/:name', ({ params: { id, name } }) => `${id} ${name}`)
.get('/', () => 'hi', { response: t.String({ description: 'sample description' }) })
.post(

@@ -28,23 +26,21 @@ '/json/:id',

{
schema: {
params: t.Object({
id: t.String()
}),
query: t.Object({
name: t.String()
}),
body: t.Object({
username: t.String(),
password: t.String()
}),
response: t.Object({
username: t.String(),
password: t.String(),
id: t.String(),
name: t.String()
})
}
params: t.Object({
id: t.String()
}),
query: t.Object({
name: t.String()
}),
body: t.Object({
username: t.String(),
password: t.String()
}),
response: t.Object({
username: t.String(),
password: t.String(),
id: t.String(),
name: t.String()
}, { description: 'sample description' })
}
)
.listen(8080)
.listen(8080);
```

@@ -51,0 +47,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc