@ts-rest/open-api
Advanced tools
Comparing version 3.42.0 to 3.43.0
# @ts-rest/open-api | ||
## 3.43.0 | ||
### Minor Changes | ||
- 77f23a8: Add `operationMapper` option to extend OpenAPI operations | ||
## 3.42.0 | ||
@@ -4,0 +10,0 @@ |
@@ -140,3 +140,3 @@ 'use strict'; | ||
var _a, _b, _c, _d; | ||
if (options.setOperationId) { | ||
if (options.setOperationId === true) { | ||
const existingOp = operationIds.get(path.id); | ||
@@ -178,3 +178,3 @@ if (existingOp) { | ||
: 'application/json'; | ||
const newPath = { | ||
const pathOperation = { | ||
description: path.route.description, | ||
@@ -185,3 +185,9 @@ summary: path.route.summary, | ||
parameters: [...pathParams, ...headerParams, ...querySchema], | ||
...(options.setOperationId ? { operationId: path.id } : {}), | ||
...(options.setOperationId | ||
? { | ||
operationId: options.setOperationId === 'concatenated-path' | ||
? [...path.paths, path.id].join('.') | ||
: path.id, | ||
} | ||
: {}), | ||
...(bodySchema | ||
@@ -203,3 +209,5 @@ ? { | ||
...acc[path.path], | ||
[mapMethod[path.route.method]]: newPath, | ||
[mapMethod[path.route.method]]: options.operationMapper | ||
? options.operationMapper(pathOperation, path.route) | ||
: pathOperation, | ||
}; | ||
@@ -206,0 +214,0 @@ return acc; |
@@ -136,3 +136,3 @@ import { isZodType, isAppRoute, isZodObject, extractZodObjectShape } from '@ts-rest/core'; | ||
var _a, _b, _c, _d; | ||
if (options.setOperationId) { | ||
if (options.setOperationId === true) { | ||
const existingOp = operationIds.get(path.id); | ||
@@ -174,3 +174,3 @@ if (existingOp) { | ||
: 'application/json'; | ||
const newPath = { | ||
const pathOperation = { | ||
description: path.route.description, | ||
@@ -181,3 +181,9 @@ summary: path.route.summary, | ||
parameters: [...pathParams, ...headerParams, ...querySchema], | ||
...(options.setOperationId ? { operationId: path.id } : {}), | ||
...(options.setOperationId | ||
? { | ||
operationId: options.setOperationId === 'concatenated-path' | ||
? [...path.paths, path.id].join('.') | ||
: path.id, | ||
} | ||
: {}), | ||
...(bodySchema | ||
@@ -199,3 +205,5 @@ ? { | ||
...acc[path.path], | ||
[mapMethod[path.route.method]]: newPath, | ||
[mapMethod[path.route.method]]: options.operationMapper | ||
? options.operationMapper(pathOperation, path.route) | ||
: pathOperation, | ||
}; | ||
@@ -202,0 +210,0 @@ return acc; |
{ | ||
"name": "@ts-rest/open-api", | ||
"version": "3.42.0", | ||
"version": "3.43.0", | ||
"dependencies": { | ||
@@ -5,0 +5,0 @@ "@anatine/zod-openapi": "^1.12.0", |
@@ -1,3 +0,3 @@ | ||
import { AppRouter } from '@ts-rest/core'; | ||
import { ExamplesObject, InfoObject, OpenAPIObject } from 'openapi3-ts'; | ||
import { AppRoute, AppRouter } from '@ts-rest/core'; | ||
import { ExamplesObject, InfoObject, OpenAPIObject, OperationObject } from 'openapi3-ts'; | ||
declare module 'openapi3-ts' { | ||
@@ -16,4 +16,5 @@ interface SchemaObject { | ||
}, options?: { | ||
setOperationId?: boolean; | ||
jsonQuery?: boolean; | ||
setOperationId?: boolean | "concatenated-path" | undefined; | ||
jsonQuery?: boolean | undefined; | ||
operationMapper?: ((operation: OperationObject, appRoute: AppRoute) => OperationObject) | undefined; | ||
}) => OpenAPIObject; |
33565
450