Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ts-rest/open-api

Package Overview
Dependencies
Maintainers
1
Versions
117
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ts-rest/open-api - npm Package Compare versions

Comparing version 3.7.0 to 3.8.0

34

index.js

@@ -23,8 +23,8 @@ import { isAppRoute, isZodObject } from '@ts-rest/core';

};
const getResponseSchemaFromZod = (response) => {
const isZodObj = isZodObject(response);
const getJsonSchemaFromZod = (zodObject) => {
const isZodObj = isZodObject(zodObject);
if (!isZodObj) {
return null;
}
const schema = zodToJsonSchema(response, {
const schema = zodToJsonSchema(zodObject, {
name: 'zodObject',

@@ -56,8 +56,9 @@ target: 'openApi3',

.match(/{[^}]+}/g)) === null || _a === void 0 ? void 0 : _a.map((param) => param.slice(1, -1));
const querySchema = getJsonSchemaFromZod(path.route.query);
const bodySchema = ((_b = path.route) === null || _b === void 0 ? void 0 : _b.method) !== 'GET'
? getResponseSchemaFromZod(path.route.body)
? getJsonSchemaFromZod(path.route.body)
: null;
const responses = Object.keys(path.route.responses).reduce((acc, key) => {
const keyAsNumber = Number(key);
const responseSchema = getResponseSchemaFromZod(path.route.responses[keyAsNumber]);
const responseSchema = getJsonSchemaFromZod(path.route.responses[keyAsNumber]);
return Object.assign(Object.assign({}, acc), { [keyAsNumber]: Object.assign({ description: `${keyAsNumber}` }, (responseSchema

@@ -73,7 +74,20 @@ ? {

}, {});
const newPath = Object.assign(Object.assign(Object.assign({ description: path.route.description, summary: path.route.summary, deprecated: path.route.deprecated, tags: path.paths, parameters: paramsFromPath === null || paramsFromPath === void 0 ? void 0 : paramsFromPath.map((param) => ({
name: param,
in: 'path',
required: true,
})) }, (options.setOperationId ? { operationId: path.id } : {})), (bodySchema
const newPath = Object.assign(Object.assign(Object.assign({ description: path.route.description, summary: path.route.summary, deprecated: path.route.deprecated, tags: path.paths, parameters: [
...(paramsFromPath
? paramsFromPath.map((param) => ({
name: param,
in: 'path',
required: true,
}))
: []),
...(querySchema
? [
{
name: 'query',
in: 'query',
schema: querySchema,
},
]
: []),
] }, (options.setOperationId ? { operationId: path.id } : {})), (bodySchema
? {

@@ -80,0 +94,0 @@ requestBody: {

{
"name": "@ts-rest/open-api",
"version": "3.7.0",
"version": "3.8.0",
"peerDependenciesMeta": {

@@ -17,3 +17,3 @@ "zod": {

"zod-to-json-schema": "^3.x.x",
"@ts-rest/core": "3.7.0"
"@ts-rest/core": "3.8.0"
},

@@ -20,0 +20,0 @@ "module": "./index.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc