Skip to content

Commit

Permalink
Improve backend types
Browse files Browse the repository at this point in the history
  • Loading branch information
anttiviljami committed Sep 10, 2024
1 parent b719c5e commit dfbbcff
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>",
"bin": {
"openapi": "./bin/run.js"
Expand Down
7 changes: 4 additions & 3 deletions src/typegen/typegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,10 @@ function generateBackendOperationMethodTypes(
'}',
'',
'export type OperationContext<operationId extends keyof Operations> = Operations[operationId]["context"];',
'export type OperationResponse<operationId extends keyof Operations> = Operations[operationId]["response"];',
'export type OperationResponseCallback<operationId extends keyof Operations> = (response: OperationResponse<operationId>, ...args: unknown[]) => any;',
'export type OperationHandler<operationId extends keyof Operations, HandlerArgs extends unknown[] = unknown[]> = (...params: [OperationContext<operationId>, ...HandlerArgs]) => Promise<OperationResponseCallback<operationId> | OperationResponse<operationId>>;',
'export type OperationResponseBody<operationId extends keyof Operations> = Operations[operationId]["response"];',
'export type TypedApiResponse<ResponseBody, ResponseModel = Record<string, any>> = ResponseModel & { _t?: ResponseBody };',
'export type OperationResponse<operationId extends keyof Operations> = TypedApiResponse<OperationResponseBody<operationId>>;',
'export type OperationHandler<operationId extends keyof Operations, HandlerArgs extends unknown[] = unknown[]> = (...params: [OperationContext<operationId>, ...HandlerArgs]) => Promise<OperationResponse<operationId>>;',
].join('\n');
}

Expand Down

0 comments on commit dfbbcff

Please sign in to comment.