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

@asteasolutions/zod-to-openapi

Package Overview
Dependencies
Maintainers
5
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@asteasolutions/zod-to-openapi - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

13

dist/openapi-generator.js

@@ -252,4 +252,6 @@ "use strict";

});
const parameters = this.getParameters(request);
const requestBody = this.getRequestBody(request === null || request === void 0 ? void 0 : request.body);
const routeDoc = {
[method]: Object.assign(Object.assign({}, pathItemConfig), { parameters: this.getParameters(request), requestBody: this.getRequestBody(request === null || request === void 0 ? void 0 : request.body), responses: generatedResponses }),
[method]: Object.assign(Object.assign(Object.assign(Object.assign({}, pathItemConfig), (parameters.length > 0 ? { parameters } : {})), (requestBody ? { requestBody } : {})), { responses: generatedResponses }),
};

@@ -357,3 +359,10 @@ this.pathRefs[path] = Object.assign(Object.assign({}, this.pathRefs[path]), routeDoc);

}
if (hasOpenAPIType) {
if (zodSchema instanceof zod_1.ZodRecord) {
const propertiesType = zodSchema._def.valueType;
return {
type: 'object',
additionalProperties: this.generateInnerSchema(propertiesType),
};
}
if (zodSchema instanceof zod_1.ZodUnknown || hasOpenAPIType) {
return {};

@@ -360,0 +369,0 @@ }

9

dist/zod-extensions.d.ts
import { ParameterObject, SchemaObject } from 'openapi3-ts';
import { z } from 'zod';
export interface ZodOpenAPIMetadata extends SchemaObject {
export interface ZodOpenAPIMetadata<T = any> extends SchemaObject {
refId?: string;
param?: Partial<ParameterObject>;
param?: Partial<ParameterObject> & {
example?: T;
};
example?: T;
}

@@ -12,5 +15,5 @@ declare module 'zod' {

abstract class ZodSchema<Output, Def extends ZodTypeDef, Input = Output> {
openapi<T extends ZodSchema<any>>(this: T, metadata: Partial<ZodOpenAPIMetadata>): T;
openapi<T extends ZodSchema<any>>(this: T, metadata: Partial<ZodOpenAPIMetadata<z.infer<T>>>): T;
}
}
export declare function extendZodWithOpenApi(zod: typeof z): void;
{
"name": "@asteasolutions/zod-to-openapi",
"version": "1.0.1",
"version": "1.1.0",
"description": "Builds OpenAPI schemas from Zod schemas",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

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