@@ -122,31 +122,37 @@ export class ServerOperationBuilder {
122122 return `responseValidationFactory([${ pairs } ], ${ defaultResponse ?. schema } )`
123123 }
124124
125- responder ( ) : { implementation : string ; type : string } {
125+ responder (
126+ responderType : string ,
127+ runtimeResponseType : string ,
128+ ) : {
129+ implementation : string
130+ type : string
131+ } {
126132 const { specific, defaultResponse} = this . responseSchemas ( )
127- // TODO: figure out what to do about the KoaRuntimeResponse class
133+
128134 const type = intersect (
129135 object ( [
130136 ...specific . map ( ( it ) =>
131137 it . isWildCard
132- ? `with${ it . statusType } (status: ${ it . statusType } ): KoaRuntimeResponse <${ it . type } >`
133- : `with${ it . statusType } (): KoaRuntimeResponse <${ it . type } >` ,
138+ ? `with${ it . statusType } (status: ${ it . statusType } ): ${ runtimeResponseType } <${ it . type } >`
139+ : `with${ it . statusType } (): ${ runtimeResponseType } <${ it . type } >` ,
134140 ) ,
135141 defaultResponse &&
136- `withDefault(status: StatusCode): KoaRuntimeResponse <${ defaultResponse . type } >` ,
142+ `withDefault(status: StatusCode): ${ runtimeResponseType } <${ defaultResponse . type } >` ,
137143 ] ) ,
138- "KoaRuntimeResponder" ,
144+ responderType ,
139145 )
140146
141147 const implementation = object ( [
142148 ...specific . map ( ( it ) =>
143149 it . isWildCard
144- ? `with${ it . statusType } (status: ${ it . statusType } ) {return new KoaRuntimeResponse <${ it . type } >(status) }`
145- : `with${ it . statusType } () {return new KoaRuntimeResponse <${ it . type } >(${ it . statusType } ) }` ,
150+ ? `with${ it . statusType } (status: ${ it . statusType } ) {return new ${ runtimeResponseType } <${ it . type } >(status) }`
151+ : `with${ it . statusType } () {return new ${ runtimeResponseType } <${ it . type } >(${ it . statusType } ) }` ,
146152 ) ,
147153 defaultResponse &&
148- `withDefault(status: StatusCode) { return new KoaRuntimeResponse <${ defaultResponse . type } >(status) }` ,
149- " withStatus(status: StatusCode) { return new KoaRuntimeResponse (status)}" ,
154+ `withDefault(status: StatusCode) { return new ${ runtimeResponseType } <${ defaultResponse . type } >(status) }` ,
155+ ` withStatus(status: StatusCode) { return new ${ runtimeResponseType } (status)}` ,
150156 ] )
151157
152158 return { implementation, type}
0 commit comments