Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,15 @@ export class TypescriptFetchClientBuilder extends AbstractClientBuilder {
const query = builder.query()
const headers = builder.headers({nullContentTypeValue: "undefined"})

const returnType = builder
.returnType()
.map(({statusType, responseType}) => {
return `Res<${statusType},${responseType}>`
const builderReturnType = builder.returnType()
const nonDefaultStatusTypes = builderReturnType
.filter(({isDefault}) => !isDefault)
.map(({statusType}) => statusType)
const returnType = builderReturnType
.map(({statusType, responseType, isDefault}) => {
return isDefault ?
`Res<Exclude<StatusCode, ${nonDefaultStatusTypes.join(" | ")}>,${responseType}>` :
`Res<${statusType},${responseType}>`
})
.join(" | ")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class KoaRouterBuilder extends AbstractRouterBuilder {
.add("KoaRuntimeError", "RequestInputType")

this.imports.from("koa").addType("Next")
this.imports.from("@koa/router").addType("RouterContext").all("KoaRouter")
this.imports.from("@koa/router").addType("RouterContext").addType("RouterOptions").all("KoaRouter")

const schemaBuilderType = this.schemaBuilder.type

Expand Down Expand Up @@ -258,8 +258,8 @@ ${this.operationTypes.flatMap((it) => it.statements).join("\n\n")}

${this.implementationExport(implementationExportName)}

export function ${createRouterExportName}(implementation: ${implementationExportName}): KoaRouter {
const router = new KoaRouter()
export function ${createRouterExportName}(implementation: ${implementationExportName}, options?: RouterOptions): KoaRouter {
const router = new KoaRouter(options)

${routerStatements.join("\n\n")}

Expand Down