New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@asteasolutions/zod-to-openapi

Package Overview
Dependencies
Maintainers
3
Versions
61
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 6.4.0 to 7.0.0

dist/index.cjs

1

dist/errors.d.ts

@@ -23,2 +23,3 @@ export declare class ZodToOpenAPIError {

}
export declare function enhanceMissingParametersError<T>(action: () => T, paramsToAdd: Partial<MissingParameterDataErrorProps>): T;
interface UnknownZodTypeErrorProps {

@@ -25,0 +26,0 @@ schemaName?: string;

3

dist/lib/zod-is-type.d.ts
import type { z } from 'zod';
type ZodTypes = {
export type ZodTypes = {
ZodAny: z.ZodAny;

@@ -36,2 +36,1 @@ ZodArray: z.ZodArray<any>;

export declare function isAnyZodType(schema: object): schema is z.ZodType;
export {};

@@ -1,10 +0,4 @@

import type { PathItemObject as PathItemObject30, OpenAPIObject as OpenAPIObject30, ComponentsObject as ComponentsObject30, SchemaObject as SchemaObject30 } from 'openapi3-ts/oas30';
import type { PathItemObject as PathItemObject31, OpenAPIObject as OpenAPIObject31, ComponentsObject as ComponentsObject31, SchemaObject as SchemaObject31 } from 'openapi3-ts/oas31';
type PathItemObject = PathItemObject30 & PathItemObject31;
type OpenAPIObject = OpenAPIObject30 & OpenAPIObject31;
type ComponentsObject = ComponentsObject30 & ComponentsObject31;
type SchemaObject = SchemaObject30 & SchemaObject31;
import type { ZodTypeAny } from 'zod';
import { OpenAPIDefinitions, RouteConfig } from './openapi-registry';
import { ZodNumericCheck } from './types';
import { ComponentsObject, OpenAPIObject, PathItemObject, ReferenceObject, SchemaObject, ZodNumericCheck } from './types';
declare const openApiVersions: readonly ["3.0.0", "3.0.1", "3.0.2", "3.0.3", "3.1.0"];

@@ -16,2 +10,8 @@ export type OpenApiVersion = typeof openApiVersions[number];

mapNullableType(type: NonNullable<SchemaObject['type']> | undefined, isNullable: boolean): Pick<SchemaObject, 'type' | 'nullable'>;
mapTupleItems(schemas: (SchemaObject | ReferenceObject)[]): {
items?: SchemaObject | ReferenceObject;
minItems?: number;
maxItems?: number;
prefixItems?: (SchemaObject | ReferenceObject)[];
};
getNumberChecks(checks: ZodNumericCheck[]): any;

@@ -26,2 +26,3 @@ }

private rawComponents;
private openApiTransformer;
constructor(definitions: (OpenAPIDefinitions | ZodTypeAny)[], versionSpecifics: OpenApiVersionSpecifics);

@@ -43,2 +44,6 @@ generateDocumentData(): {

/**
* Same as above but applies nullable
*/
private constructReferencedOpenAPISchema;
/**
* Generates an OpenAPI SchemaObject or a ReferenceObject with all the provided metadata applied

@@ -48,7 +53,2 @@ */

/**
* Generates a whole OpenApi schema and saves it into
* schemaRefs if a `refId` is provided.
*/
private generateSchema;
/**
* Same as `generateSchema` but if the new schema is added into the

@@ -64,2 +64,3 @@ * referenced schemas, it would return a ReferenceObject and not the

private getParameters;
private cleanParameter;
generatePath(route: RouteConfig): PathItemObject;

@@ -70,36 +71,4 @@ private generateSingleRoute;

private getBodyContent;
private getZodStringCheck;
/**
* Attempts to map Zod strings to known formats
* https://json-schema.org/understanding-json-schema/reference/string.html#built-in-formats
*/
private mapStringFormat;
private mapDiscriminator;
private mapNullableOfArray;
private mapNullableType;
private getNumberChecks;
private constructReferencedOpenAPISchema;
private toOpenAPISchema;
private isOptionalSchema;
private getDefaultValue;
private requiredKeysOf;
private toOpenAPIObjectSchema;
private generateAdditionalProperties;
private flattenUnionTypes;
private flattenIntersectionTypes;
private unwrapNullable;
private unwrapChained;
/**
* A method that omits all custom keys added to the regular OpenAPI
* metadata properties
*/
private buildSchemaMetadata;
private buildParameterMetadata;
private getParamMetadata;
private getMetadata;
private getInternalMetadata;
private getRefId;
private applySchemaMetadata;
private enhanceMissingParametersError;
}
export {};

@@ -20,3 +20,3 @@ import { CallbackObject as CallbackObject30, ComponentsObject as ComponentsObject30, EncodingObject as EncodingObject30, ExampleObject as ExampleObject30, ExamplesObject as ExamplesObject30, HeaderObject as HeaderObject30, HeadersObject as HeadersObject30, ISpecificationExtension as ISpecificationExtension30, LinkObject as LinkObject30, LinksObject as LinksObject30, OperationObject as OperationObject30, ParameterObject as ParameterObject30, ReferenceObject as ReferenceObject30, RequestBodyObject as RequestBodyObject30, ResponseObject as ResponseObject30, SchemaObject as SchemaObject30, SecuritySchemeObject as SecuritySchemeObject30 } from 'openapi3-ts/oas30';

type SecuritySchemeObject = SecuritySchemeObject30 | SecuritySchemeObject31;
import type { AnyZodObject, ZodType, ZodTypeAny } from 'zod';
import type { AnyZodObject, ZodEffects, ZodType, ZodTypeAny } from 'zod';
type Method = 'get' | 'post' | 'put' | 'delete' | 'patch' | 'head' | 'options' | 'trace';

@@ -42,2 +42,3 @@ export interface ZodMediaTypeObject {

}
export type RouteParameter = AnyZodObject | ZodEffects<AnyZodObject, unknown, unknown> | undefined;
export type RouteConfig = Omit<OperationObject, 'responses'> & {

@@ -48,6 +49,6 @@ method: Method;

body?: ZodRequestBody;
params?: AnyZodObject;
query?: AnyZodObject;
cookies?: AnyZodObject;
headers?: AnyZodObject | ZodType<unknown>[];
params?: RouteParameter;
query?: RouteParameter;
cookies?: RouteParameter;
headers?: RouteParameter | ZodType<unknown>[];
};

@@ -54,0 +55,0 @@ responses: {

@@ -1,2 +0,23 @@

import { ZodBigIntCheck, ZodNumberCheck } from 'zod';
import { ZodBigIntCheck, ZodNumberCheck, ZodTypeAny } from 'zod';
import type { ReferenceObject as ReferenceObject30, ParameterObject as ParameterObject30, RequestBodyObject as RequestBodyObject30, PathItemObject as PathItemObject30, OpenAPIObject as OpenAPIObject30, ComponentsObject as ComponentsObject30, ParameterLocation as ParameterLocation30, ResponseObject as ResponseObject30, ContentObject as ContentObject30, DiscriminatorObject as DiscriminatorObject30, SchemaObject as SchemaObject30, BaseParameterObject as BaseParameterObject30, HeadersObject as HeadersObject30 } from 'openapi3-ts/oas30';
import type { ReferenceObject as ReferenceObject31, ParameterObject as ParameterObject31, RequestBodyObject as RequestBodyObject31, PathItemObject as PathItemObject31, OpenAPIObject as OpenAPIObject31, ComponentsObject as ComponentsObject31, ParameterLocation as ParameterLocation31, ResponseObject as ResponseObject31, ContentObject as ContentObject31, DiscriminatorObject as DiscriminatorObject31, SchemaObject as SchemaObject31, BaseParameterObject as BaseParameterObject31, HeadersObject as HeadersObject31 } from 'openapi3-ts/oas31';
export type ZodNumericCheck = ZodNumberCheck | ZodBigIntCheck;
export type ReferenceObject = ReferenceObject30 & ReferenceObject31;
export type ParameterObject = ParameterObject30 & ParameterObject31;
export type RequestBodyObject = RequestBodyObject30 & RequestBodyObject31;
export type PathItemObject = PathItemObject30 & PathItemObject31;
export type OpenAPIObject = OpenAPIObject30 & OpenAPIObject31;
export type ComponentsObject = ComponentsObject30 & ComponentsObject31;
export type ParameterLocation = ParameterLocation30 & ParameterLocation31;
export type ResponseObject = ResponseObject30 & ResponseObject31;
export type ContentObject = ContentObject30 & ContentObject31;
export type DiscriminatorObject = DiscriminatorObject30 & DiscriminatorObject31;
export type SchemaObject = SchemaObject30 & SchemaObject31;
export type BaseParameterObject = BaseParameterObject30 & BaseParameterObject31;
export type HeadersObject = HeadersObject30 & HeadersObject31;
export type MapNullableType = (type: NonNullable<SchemaObject['type']> | undefined) => Pick<SchemaObject, 'type' | 'nullable'>;
export type MapNullableTypeWithNullable = (type: NonNullable<SchemaObject['type']> | undefined, isNullable: boolean) => Pick<SchemaObject, 'type' | 'nullable'>;
export type MapNullableOfArray = (objects: (SchemaObject | ReferenceObject)[]) => (SchemaObject | ReferenceObject)[];
export type MapNullableOfArrayWithNullable = (objects: (SchemaObject | ReferenceObject)[], isNullable: boolean) => (SchemaObject | ReferenceObject)[];
export type GetNumberChecks = (checks: ZodNumericCheck[]) => Pick<SchemaObject, 'minimum' | 'exclusiveMinimum' | 'maximum' | 'exclusiveMaximum'>;
export type MapSubSchema = (zodSchema: ZodTypeAny) => SchemaObject | ReferenceObject;
import type { ReferenceObject, SchemaObject } from 'openapi3-ts/oas30';
import { OpenApiVersionSpecifics } from '../openapi-generator';
import { ZodNumericCheck } from '../types';
import { ZodNumericCheck, SchemaObject as CommonSchemaObject } from '../types';
export declare class OpenApiGeneratorV30Specifics implements OpenApiVersionSpecifics {

@@ -10,3 +10,10 @@ get nullType(): {

mapNullableType(type: NonNullable<SchemaObject['type']> | undefined, isNullable: boolean): Pick<SchemaObject, 'type' | 'nullable'>;
mapTupleItems(schemas: (CommonSchemaObject | ReferenceObject)[]): {
items: ReferenceObject | CommonSchemaObject | {
anyOf: (ReferenceObject | CommonSchemaObject)[];
} | undefined;
minItems: number;
maxItems: number;
};
getNumberChecks(checks: ZodNumericCheck[]): Pick<SchemaObject, 'minimum' | 'exclusiveMinimum' | 'maximum' | 'exclusiveMaximum'>;
}
import type { ReferenceObject, SchemaObject } from 'openapi3-ts/oas31';
import { OpenApiVersionSpecifics } from '../openapi-generator';
import { ZodNumericCheck } from '../types';
import { ZodNumericCheck, SchemaObject as CommonSchemaObject } from '../types';
export declare class OpenApiGeneratorV31Specifics implements OpenApiVersionSpecifics {

@@ -12,3 +12,6 @@ get nullType(): {

};
mapTupleItems(schemas: (CommonSchemaObject | ReferenceObject)[]): {
prefixItems: (ReferenceObject | CommonSchemaObject)[];
};
getNumberChecks(checks: ZodNumericCheck[]): Pick<SchemaObject, 'minimum' | 'exclusiveMinimum' | 'maximum' | 'exclusiveMaximum'>;
}
{
"name": "@asteasolutions/zod-to-openapi",
"version": "6.4.0",
"version": "7.0.0",
"description": "Builds OpenAPI schemas from Zod schemas",
"main": "dist/index.js",
"main": "dist/index.cjs",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",

@@ -26,3 +27,3 @@ "files": [

"scripts": {
"build": "tsc -p tsconfig.build.json",
"build": "rollup -c",
"prepare": "npm run build",

@@ -41,5 +42,9 @@ "test": "jest",

"devDependencies": {
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-node-resolve": "^15.2.3",
"@types/jest": "^29.2.5",
"jest": "^29.3.1",
"prettier": "^2.7.1",
"rollup": "^4.13.2",
"rollup-plugin-typescript2": "^0.36.0",
"ts-jest": "^29.0.3",

@@ -46,0 +51,0 @@ "typescript": "^5.2.2",

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