@asteasolutions/zod-to-openapi
Advanced tools
Comparing version 4.7.0 to 4.8.0
@@ -15,6 +15,6 @@ "use strict"; | ||
exports.OpenAPIGenerator = void 0; | ||
const errors_1 = require("./errors"); | ||
const enum_info_1 = require("./lib/enum-info"); | ||
const lodash_1 = require("./lib/lodash"); | ||
const errors_1 = require("./errors"); | ||
const zod_is_type_1 = require("./lib/zod-is-type"); | ||
const enum_info_1 = require("./lib/enum-info"); | ||
// List of Open API Versions. Please make sure these are in ascending order | ||
@@ -21,0 +21,0 @@ const openApiVersions = ['3.0.0', '3.0.1', '3.0.2', '3.0.3', '3.1.0']; |
@@ -1,41 +0,4 @@ | ||
import { ZodSchema } from 'zod'; | ||
export declare function getOpenApiMetadata<T extends ZodSchema<any>>(zodSchema: T): Partial<{ | ||
[x: `x-${string}`]: any; | ||
param?: any; | ||
example?: any; | ||
examples?: any; | ||
default?: any; | ||
nullable?: any; | ||
discriminator?: any; | ||
readOnly?: any; | ||
writeOnly?: any; | ||
xml?: any; | ||
externalDocs?: any; | ||
deprecated?: any; | ||
type?: any; | ||
format?: any; | ||
allOf?: any; | ||
oneOf?: any; | ||
anyOf?: any; | ||
not?: any; | ||
items?: any; | ||
properties?: any; | ||
additionalProperties?: any; | ||
description?: any; | ||
title?: any; | ||
multipleOf?: any; | ||
maximum?: any; | ||
exclusiveMaximum?: any; | ||
minimum?: any; | ||
exclusiveMinimum?: any; | ||
maxLength?: any; | ||
minLength?: any; | ||
pattern?: any; | ||
maxItems?: any; | ||
minItems?: any; | ||
uniqueItems?: any; | ||
maxProperties?: any; | ||
minProperties?: any; | ||
required?: any; | ||
enum?: any; | ||
import { ZodTypeAny } from 'zod'; | ||
export declare function getOpenApiMetadata<T extends ZodTypeAny>(zodSchema: T): Partial<{ | ||
[x: string]: any; | ||
}>; |
import { CallbackObject, ComponentsObject, EncodingObject, ExampleObject, ExamplesObject, HeaderObject, HeadersObject, ISpecificationExtension, LinkObject, LinksObject, OperationObject, ParameterObject, ReferenceObject, RequestBodyObject, ResponseObject, SchemaObject, SecuritySchemeObject } from 'openapi3-ts/oas30'; | ||
import type { AnyZodObject, ZodSchema, ZodType } from 'zod'; | ||
import type { AnyZodObject, ZodType, ZodTypeAny } from 'zod'; | ||
declare type Method = 'get' | 'post' | 'put' | 'delete' | 'patch' | 'head' | 'options' | 'trace'; | ||
@@ -47,6 +47,6 @@ export interface ZodMediaTypeObject { | ||
type: 'schema'; | ||
schema: ZodSchema<any>; | ||
schema: ZodTypeAny; | ||
} | { | ||
type: 'parameter'; | ||
schema: ZodSchema<any>; | ||
schema: ZodTypeAny; | ||
} | { | ||
@@ -67,7 +67,7 @@ type: 'route'; | ||
*/ | ||
register<T extends ZodSchema<any>>(refId: string, zodSchema: T): T; | ||
register<T extends ZodTypeAny>(refId: string, zodSchema: T): T; | ||
/** | ||
* Registers a new parameter schema under /components/parameters/${name} | ||
*/ | ||
registerParameter<T extends ZodSchema<any>>(refId: string, zodSchema: T): T; | ||
registerParameter<T extends ZodTypeAny>(refId: string, zodSchema: T): T; | ||
/** | ||
@@ -74,0 +74,0 @@ * Registers a new path that would be generated under paths: |
import { ParameterObject, SchemaObject } from 'openapi3-ts/oas30'; | ||
import type { z, ZodObject, ZodRawShape } from 'zod'; | ||
import type { z, ZodObject, ZodRawShape, ZodTypeAny } from 'zod'; | ||
declare type ExampleValue<T> = T extends Date ? string : T; | ||
@@ -27,4 +27,4 @@ export interface ZodOpenAPIMetadata<T = any, E = ExampleValue<T>> extends SchemaObject { | ||
} | ||
interface ZodSchema<Output, Def extends ZodTypeDef, Input = Output> { | ||
openapi<T extends ZodSchema<any>>(this: T, metadata: Partial<ZodOpenAPIMetadata<z.infer<T>>>): T; | ||
interface ZodType<Output = any, Def extends ZodTypeDef = ZodTypeDef, Input = Output> { | ||
openapi<T extends ZodTypeAny>(this: T, metadata: Partial<ZodOpenAPIMetadata<z.infer<T>>>): T; | ||
/** | ||
@@ -37,3 +37,3 @@ * This method should NOT be used outside of @astesolution/zod-to-openapi code! | ||
*/ | ||
internal_openapi<T extends ZodSchema<any>>(this: T, metadata: Partial<ZodOpenAPIInternalMetadata>): T; | ||
internal_openapi<T extends ZodTypeAny>(this: T, metadata: Partial<ZodOpenAPIInternalMetadata>): T; | ||
} | ||
@@ -40,0 +40,0 @@ } |
@@ -17,3 +17,3 @@ "use strict"; | ||
function extendZodWithOpenApi(zod) { | ||
if (typeof zod.ZodSchema.prototype.openapi !== 'undefined') { | ||
if (typeof zod.ZodType.prototype.openapi !== 'undefined') { | ||
// This zod instance is already extended with the required methods, | ||
@@ -66,4 +66,4 @@ // doing it again will just result in multiple wrapper methods for | ||
}; | ||
const zodOptional = zod.ZodSchema.prototype.optional; | ||
zod.ZodSchema.prototype.optional = function (...args) { | ||
const zodOptional = zod.ZodType.prototype.optional; | ||
zod.ZodType.prototype.optional = function (...args) { | ||
const result = zodOptional.apply(this, args); | ||
@@ -73,4 +73,4 @@ result._def.openapi = this._def.openapi; | ||
}; | ||
const zodNullable = zod.ZodSchema.prototype.nullable; | ||
zod.ZodSchema.prototype.nullable = function (...args) { | ||
const zodNullable = zod.ZodType.prototype.nullable; | ||
zod.ZodType.prototype.nullable = function (...args) { | ||
const result = zodNullable.apply(this, args); | ||
@@ -80,4 +80,4 @@ result._def.openapi = this._def.openapi; | ||
}; | ||
const zodDefault = zod.ZodSchema.prototype.default; | ||
zod.ZodSchema.prototype.default = function (...args) { | ||
const zodDefault = zod.ZodType.prototype.default; | ||
zod.ZodType.prototype.default = function (...args) { | ||
const result = zodDefault.apply(this, args); | ||
@@ -84,0 +84,0 @@ result._def.openapi = this._def.openapi; |
{ | ||
"name": "@asteasolutions/zod-to-openapi", | ||
"version": "4.7.0", | ||
"version": "4.8.0", | ||
"description": "Builds OpenAPI schemas from Zod schemas", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
79003
1445