File tree Expand file tree Collapse file tree 4 files changed +20
-11
lines changed Expand file tree Collapse file tree 4 files changed +20
-11
lines changed Original file line number Diff line number Diff line change 1+ # 1.3.4 - 3 Sep 2025
2+ Bug fix:
3+ - type generator: exclude unknown type
4+
15# 1.3.3 - 3 Sep 2025
26Bug fix:
37- type generator: collapse path when trying to access from dist
Original file line number Diff line number Diff line change 11{
22 "name" : " @elysiajs/openapi" ,
3- "version" : " 1.3.3 " ,
3+ "version" : " 1.3.4 " ,
44 "description" : " Plugin for Elysia to auto-generate API documentation" ,
55 "author" : {
66 "name" : " saltyAom" ,
Original file line number Diff line number Diff line change @@ -124,14 +124,16 @@ export const fromTypes =
124124 let targetFile =
125125 overrideOutputPath ?.( tmpRoot ) ?? join ( tmpRoot , 'dist' , fileName )
126126
127- // Sometime TypeScript doesn't include the first level directory, eg. src/file.ts -> dist/file.d.ts
128- if ( ! existsSync ( targetFile ) )
129- targetFile = join (
127+ {
128+ const _targetFile = join (
130129 tmpRoot ,
131130 'dist' ,
132131 fileName . slice ( fileName . indexOf ( '/' ) + 1 )
133132 )
134133
134+ if ( existsSync ( _targetFile ) ) targetFile = _targetFile
135+ }
136+
135137 const declaration = readFileSync ( targetFile , 'utf8' )
136138
137139 // Check just in case of race-condition
@@ -200,7 +202,9 @@ export const fromTypes =
200202
201203 return routes
202204 } catch ( error ) {
203- console . warn ( '[@elysiajs/openapi/gen] Failed to generate OpenAPI schema' )
205+ console . warn (
206+ '[@elysiajs/openapi/gen] Failed to generate OpenAPI schema'
207+ )
204208 console . warn ( error )
205209
206210 return
Original file line number Diff line number Diff line change @@ -111,18 +111,19 @@ export function toOpenAPISchema(
111111 const refer = reference [ route . path ] ?. [ method ]
112112 if ( ! refer ) continue
113113
114- if ( ! hooks . body && refer . body ) hooks . body = refer . body
115- if ( ! hooks . query && refer . query ) hooks . query = refer . query
116- if ( ! hooks . params && refer . params ) hooks . params = refer . params
117- if ( ! hooks . headers && refer . headers )
114+ if ( ! hooks . body && refer . body ?. type ) hooks . body = refer . body
115+ if ( ! hooks . query && refer . query ?. type ) hooks . query = refer . query
116+ if ( ! hooks . params && refer . params ?. type )
117+ hooks . params = refer . params
118+ if ( ! hooks . headers && refer . headers ?. type )
118119 hooks . headers = refer . headers
119120 if ( ! hooks . response && refer . response ) {
120121 hooks . response = { }
121122
122123 for ( const [ status , schema ] of Object . entries (
123124 refer . response
124125 ) )
125- if ( ! hooks . response [ status as any ] )
126+ if ( ! hooks . response [ status as any ] && schema ?. type )
126127 hooks . response [ status as any ] = schema
127128 }
128129 }
@@ -224,7 +225,7 @@ export function toOpenAPISchema(
224225 if ( parameters . length > 0 ) operation . parameters = parameters
225226
226227 // Handle request body
227- if ( hooks . body ) {
228+ if ( hooks . body && method !== 'get' && method !== 'head' ) {
228229 if ( typeof hooks . body === 'string' ) hooks . body = toRef ( hooks . body )
229230
230231 // @ts -ignore
You can’t perform that action at this time.
0 commit comments