@@ -52,18 +52,17 @@ By default, Elysia relies on runtime schema to generate OpenAPI documentation.
52
52
53
53
However, you can also generate OpenAPI documentation from types by using a generator from OpenAPI plugin as follows:
54
54
55
- 1 . Specify the root file of your project (usually ` src/index.ts ` ), and export an instance
55
+ 1 . Specify your Elysia root file (if not specified, Elysia will use ` src/index.ts ` ), and export an instance
56
56
57
57
2 . Import a generator and provide a ** file path from project root** to type generator
58
58
``` ts
59
59
import { Elysia , t } from ' elysia'
60
- import { openapi } from ' @elysiajs/openapi'
61
- import { fromTypes } from ' @elysiajs/openapi/gen' // [!code ++]
60
+ import { openapi , fromTypes } from ' @elysiajs/openapi' // [!code ++]
62
61
63
62
export const app = new Elysia () // [!code ++]
64
63
.use (
65
64
openapi ({
66
- references: fromTypes (' src/index.ts ' ) // [!code ++]
65
+ references: fromTypes () // [!code ++]
67
66
})
68
67
)
69
68
.get (' /' , { test: ' hello' as const })
@@ -86,8 +85,7 @@ It's recommended that you should pre-generate the declaration file (**.d.ts**) t
86
85
87
86
``` ts
88
87
import { Elysia , t } from ' elysia'
89
- import { openapi } from ' @elysiajs/openapi'
90
- import { fromTypes } from ' @elysiajs/openapi/gen'
88
+ import { openapi , fromTypes } from ' @elysiajs/openapi'
91
89
92
90
const app = new Elysia ()
93
91
.use (
@@ -110,8 +108,7 @@ As it's unreliable to guess to root of the project, it's recommended to provide
110
108
111
109
``` ts
112
110
import { Elysia , t } from ' elysia'
113
- import { openapi } from ' @elysiajs/openapi'
114
- import { fromTypes } from ' @elysiajs/openapi/gen'
111
+ import { openapi , fromTypes } from ' @elysiajs/openapi'
115
112
116
113
export const app = new Elysia ()
117
114
.use (
@@ -135,8 +132,7 @@ If you have multiple `tsconfig.json` files, it's important that you must specify
135
132
136
133
``` ts
137
134
import { Elysia , t } from ' elysia'
138
- import { openapi } from ' @elysiajs/openapi'
139
- import { fromTypes } from ' @elysiajs/openapi/gen'
135
+ import { openapi , fromTypes } from ' @elysiajs/openapi'
140
136
141
137
export const app = new Elysia ()
142
138
.use (
0 commit comments