Open cholasimmons opened 1 month ago
hi @cholasimmons whats the error youre seeing? im just looking into this now : )
There's no error at all, the browser screen is actually just throwing a response that it would normally throw when the route exists (but you're not permitted to view it), it's almost like swagger is not loading at all. The minute I downgrade to 1.0.5 it works instantly.
The recent Elysia update 1.1.3 gave me some issues with helmet() so maybe the problem is coming from there? In the past I recall helmet used to prevent swagger from loading without a little "directives" patch.
If it helps @marclave , here's the repo I was using: cholasimmons/bun-elysia-modular_auth
Can confirm, this doesn't work on Swagger 1.1.0, downgraded to 1.0.5 and worked out of the box again.
The /health checks works without a bearer token and the authenticated routes I have after these as well. The Swagger endpoints seems to get routed through the authentication because I get the Unauthorized error.
const app = new Elysia()
.use(
swagger( {
documentation: {
info: {
title: 'LegalFly\'s On Prem Server Documentation',
version: '1.0.0',
},
},
} ),
)
.decorate( "healthController", new HealthController() )
.get( "/health",
async ( { healthController } ) => await healthController.checkHealth() )
.use( bearer() )
.derive( async ( { bearer } ) =>
{
if ( !bearer || bearer !== appConfig.secret ) {
throw new Error( "Unauthorized" );
}
} )
Can confirm, this doesn't work on Swagger 1.1.0, downgraded to 1.0.5 and worked out of the box again.
The /health checks works without a bearer token and the authenticated routes I have after these as well. The Swagger endpoints seems to get routed through the authentication because I get the Unauthorized error.
const app = new Elysia() .use( swagger( { documentation: { info: { title: 'LegalFly\'s On Prem Server Documentation', version: '1.0.0', }, }, } ), ) .decorate( "healthController", new HealthController() ) .get( "/health", async ( { healthController } ) => await healthController.checkHealth() ) .use( bearer() ) .derive( async ( { bearer } ) => { if ( !bearer || bearer !== appConfig.secret ) { throw new Error( "Unauthorized" ); } } )
Same here. Any solution?
investigating today!
immediately im not sure whats up 🤔
I have an error on 1.1.0+ when starting my app , rolled back successfully to 1.05. I think this is probably related Error when starting is : (plugin2 is swagger)
6793 | if (plugin2 instanceof _Elysia) return this._use(plugin2);
6794 | if (typeof plugin2.default === "function")
6795 | return plugin2.default(this);
6796 | if (plugin2.default instanceof _Elysia)
6797 | return this._use(plugin2.default);
6798 | throw new Error(
^
error: Invalid plugin type. Expected Elysia instance, function, or module with "default" as Elysia instance or function that returns Elysia instance.
at [...]/node_modules/elysia/dist/cjs/index.js:6798:17
Same problem here.
3218 | return plugin.default(this)
3219 |
3220 | if (plugin.default instanceof Elysia)
3221 | return this._use(plugin.default)
3222 |
3223 | throw new Error(
^
error: Invalid plugin type. Expected Elysia instance, function, or module with "default" as Elysia instance or function that returns Elysia instance.
at /Users/assaf/code/work/sidedish/apps/api/node_modules/elysia/src/index.ts:3223:13
when using Swagger, the error disappears when commented out.
in package.json: "@elysiajs/swagger": "^1.0.5",
in lock file:
"@elysiajs/swagger@^1.0.5":
version "1.1.1"
resolved "https://registry.npmjs.org/@elysiajs/swagger/-/swagger-1.1.1.tgz"
integrity sha512-fsg5IZaNbgN2kWqSRUntSMqg386cmFbT7IrYm2gH1P9e34ZD2wuKhRCu521+T924UunwIHP2+tj6CoFL4FrsxQ==
dependencies:
lodash.clonedeep "^4.5.0"
openapi-types "^12.1.3
Confirmed to work when pinning the version to 1.0.5
Same here, 404 NOT_FOUND
Edit: It was a malfunctioning middleware called after swagger.
For anyone else facing this issue .. try to move the swagger plugin to the topmost level and see if it works.
For anyone else facing this issue .. try to move the swagger plugin to the topmost level and see if it works.
Tried moving it, still the same. I am facing same issue as @DaniumX - https://github.com/elysiajs/elysia-swagger/issues/133#issuecomment-2270408110.
"@elysiajs/jwt": "^1.1.0",
"@elysiajs/swagger": "^1.1.1",
"elysia": "^1.1.8",
I recently updated Elysia to 1.1.3 and Swagger to 1.1.0, Off the bat helmet() prevented Elysia from running, which was fixed by rolling Elysia back to v1.1.2. Then I noticed Swagger doesn't load at all (in either versions of Elysia), but rolling it back to version v1.0.5 worked instantly