1- import type { InternalRoute } from 'elysia'
1+ import type { InputSchema , InternalRoute , TSchema } from 'elysia'
22import {
33 readFileSync ,
44 mkdirSync ,
@@ -14,6 +14,7 @@ import { tmpdir } from 'os'
1414import { join } from 'path'
1515import { spawnSync } from 'child_process'
1616import { AdditionalReference , AdditionalReferences } from '../types'
17+ import { Kind , TObject } from '@sinclair/typebox/type'
1718
1819const matchRoute = / : E l y s i a < ( .* ) > / gs
1920const matchStatus = / ( \d { 3 } ) : / gs
@@ -165,17 +166,24 @@ export const fromTypes =
165166
166167 const routes : AdditionalReference = { }
167168
168- for ( let route of routesString . slice ( 1 ) . split ( '} & {' ) ) {
169- route = '{' + route + '}'
170- let schema = TypeBox ( route )
171-
172- if ( schema . type !== 'object' ) continue
169+ // Treaty is a collection of { ... } & { ... } & { ... }
170+ // Each route will be intersected with each other
171+ // instead of being nested in a route object
172+ for ( const route of routesString . slice ( 1 ) . split ( '} & {' ) ) {
173+ // as ' } & {' is removed, we need to add it back
174+ let schema = TypeBox ( `{${ route } }}` )
175+ if ( schema . type !== 'object' ) {
176+ // just in case
177+ schema = TypeBox ( `{${ route } }` )
178+
179+ if ( schema . type !== 'object' ) continue
180+ }
173181
174182 const paths = [ ]
175183
176184 while ( true ) {
177185 const keys = Object . keys ( schema . properties )
178- if ( ! keys . length || keys . length > 1 ) break
186+ if ( keys . length !== 1 ) break
179187
180188 paths . push ( keys [ 0 ] )
181189
0 commit comments