Skip to content

Commit

Permalink
Merge pull request #113 from Autumnlight02/main
Browse files Browse the repository at this point in the history
bugfix(accept external swagger paths)
  • Loading branch information
marclave committed Apr 11, 2024
2 parents d63db39 + 7b1d183 commit 9d697b2
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 2 deletions.
60 changes: 60 additions & 0 deletions example/index3.ts
@@ -0,0 +1,60 @@
import { Elysia, InternalRoute } from 'elysia'
import { swagger } from '../src/index'
import { plugin } from './plugin'
import { registerSchemaPath } from '../src/utils'

const app = new Elysia()
.use(
swagger({
provider: 'scalar',
documentation: {
info: {
title: 'Elysia Scalar',
version: '0.8.1'
},
tags: [
{
name: 'Test',
description: 'Hello'
}
],
paths: {
"/b/": {
get: {
operationId: "getB",
summary: "Ping Pong B",
description: "Lorem Ipsum Dolar",
tags: [ "Test" ],
responses: {
"200": {
description: "test"
},
},
},
},
},
components: {
schemas: {
User: {
description: 'string'
}
},
securitySchemes: {
JwtAuth: {
type: 'http',
scheme: 'bearer',
bearerFormat: 'JWT',
description: 'Enter JWT Bearer token **_only_**'
}
}
}
},
swaggerOptions: {
persistAuthorization: true
}
})
)
.use(plugin)
.listen(3000)

console.log(app.rsaoutes)
6 changes: 4 additions & 2 deletions src/index.ts
Expand Up @@ -143,10 +143,12 @@ export const swagger =
...documentation.info
}
},
paths: filterPaths(schema, {
paths: {...filterPaths(schema, {
excludeStaticFile,
exclude: Array.isArray(exclude) ? exclude : [exclude]
}),
}),
...documentation.paths
},
components: {
...documentation.components,
schemas: {
Expand Down

0 comments on commit 9d697b2

Please sign in to comment.