From dfbbcffa878aab241aae0e24d059738514469d4a Mon Sep 17 00:00:00 2001 From: Viljami Kuosmanen Date: Tue, 10 Sep 2024 13:05:45 +0200 Subject: [PATCH] Improve backend types --- package-lock.json | 4 ++-- package.json | 2 +- src/typegen/typegen.ts | 7 ++++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 28f2877..840410d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "openapicmd", - "version": "2.6.0-beta.1", + "version": "2.6.0-beta.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "openapicmd", - "version": "2.6.0-beta.1", + "version": "2.6.0-beta.2", "license": "MIT", "dependencies": { "@anttiviljami/dtsgenerator": "^3.20.0", diff --git a/package.json b/package.json index 6f0381d..ae53f27 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "openapicmd", "description": "OpenAPI Command Line Tool", - "version": "2.6.0-beta.1", + "version": "2.6.0-beta.2", "author": "Viljami Kuosmanen ", "bin": { "openapi": "./bin/run.js" diff --git a/src/typegen/typegen.ts b/src/typegen/typegen.ts index a779688..c4298ed 100644 --- a/src/typegen/typegen.ts +++ b/src/typegen/typegen.ts @@ -86,9 +86,10 @@ function generateBackendOperationMethodTypes( '}', '', 'export type OperationContext = Operations[operationId]["context"];', - 'export type OperationResponse = Operations[operationId]["response"];', - 'export type OperationResponseCallback = (response: OperationResponse, ...args: unknown[]) => any;', - 'export type OperationHandler = (...params: [OperationContext, ...HandlerArgs]) => Promise | OperationResponse>;', + 'export type OperationResponseBody = Operations[operationId]["response"];', + 'export type TypedApiResponse> = ResponseModel & { _t?: ResponseBody };', + 'export type OperationResponse = TypedApiResponse>;', + 'export type OperationHandler = (...params: [OperationContext, ...HandlerArgs]) => Promise>;', ].join('\n'); }