Skip to content

Commit 7b1d183

Browse files
committed
bugfix(accept external swagger paths)
1 parent d63db39 commit 7b1d183

File tree

2 files changed

+64
-2
lines changed

2 files changed

+64
-2
lines changed

Diff for: example/index3.ts

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import { Elysia, InternalRoute } from 'elysia'
2+
import { swagger } from '../src/index'
3+
import { plugin } from './plugin'
4+
import { registerSchemaPath } from '../src/utils'
5+
6+
const app = new Elysia()
7+
.use(
8+
swagger({
9+
provider: 'scalar',
10+
documentation: {
11+
info: {
12+
title: 'Elysia Scalar',
13+
version: '0.8.1'
14+
},
15+
tags: [
16+
{
17+
name: 'Test',
18+
description: 'Hello'
19+
}
20+
],
21+
paths: {
22+
"/b/": {
23+
get: {
24+
operationId: "getB",
25+
summary: "Ping Pong B",
26+
description: "Lorem Ipsum Dolar",
27+
tags: [ "Test" ],
28+
responses: {
29+
"200": {
30+
description: "test"
31+
},
32+
},
33+
},
34+
},
35+
},
36+
components: {
37+
schemas: {
38+
User: {
39+
description: 'string'
40+
}
41+
},
42+
securitySchemes: {
43+
JwtAuth: {
44+
type: 'http',
45+
scheme: 'bearer',
46+
bearerFormat: 'JWT',
47+
description: 'Enter JWT Bearer token **_only_**'
48+
}
49+
}
50+
}
51+
},
52+
swaggerOptions: {
53+
persistAuthorization: true
54+
}
55+
})
56+
)
57+
.use(plugin)
58+
.listen(3000)
59+
60+
console.log(app.rsaoutes)

Diff for: src/index.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,12 @@ export const swagger =
143143
...documentation.info
144144
}
145145
},
146-
paths: filterPaths(schema, {
146+
paths: {...filterPaths(schema, {
147147
excludeStaticFile,
148148
exclude: Array.isArray(exclude) ? exclude : [exclude]
149-
}),
149+
}),
150+
...documentation.paths
151+
},
150152
components: {
151153
...documentation.components,
152154
schemas: {

0 commit comments

Comments
 (0)